solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
#include <bits/stdc++.h> using namespace std; int main() { int a, b, i = 0; cin >> a >> b; while (a != 0) { a--; i++; if (i % b == 0) a++; } cout << i << endl; }
7
CPP
a,b=list(map(int,input().split())) s=0 while a-b>=0: a-=b-1 s+=b print(s+a)
7
PYTHON3
a,b=[int(x) for x in input().split()] hour=a while a>=b: c=a//b hour+=c a=a-(a//b)*b+c print(hour)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; while (~scanf("%d%d", &a, &b)) { int t = 0; while (a != 0) { if (a >= b) t += b; else { t += a; break; } a = a - b + 1; } printf("%d\n", t); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; template <class T> inline T cal(T n, T k) { T sum = n, m; while (n >= k) { m = n % k; n /= k; sum += n; n += m; } return sum; } int main() { int a, b; scanf("%d%d", &a, &b); printf("%d\n", cal(a, b)); return 0; }
7
CPP
a,b=map(int,input().split());d=lambda v:v//b and v//b+d(v//b+v%b) print(d(a*b))
7
PYTHON3
a, b = map(int, input().split()) count = a while(1): d = a // b count += d rem = a % b a = d + rem if a < b: break print(count)
7
PYTHON3
#!/usr/bin/env python3 a, b = [int(x) for x in input().split()] candles_off = a nb_candles = a while (candles_off > 0): if candles_off>=b: nb_candles += int(candles_off / b) candles_off = int(candles_off / b) + (candles_off % b) else: break print(nb_candles)
7
PYTHON3
import sys candles = sys.stdin.readline().strip().split(' ') a = int(candles[0]) b = int(candles[1]) c = 0 while(a >= b): c += b a -= b a += 1 print(c + a)
7
PYTHON3
a,b=map(int,input().split()) s=(a*b-1)//(b-1) print(s)
7
PYTHON3
x,y=map(int, input().split()) print((x*y-1)//(y-1))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, cnt = 0; scanf("%d%d", &a, &b); cnt += a; while (a >= b) { cnt += a / b; a = a / b + a % b; } printf("%d", cnt); return 0; }
7
CPP
a,b=[int(i)for i in input().split()] n=0 n+=a resi=a%b c=int((a-resi)/b) while c>=1: n+=c a=c+resi resi=a%b c=int((a-resi)/b) print(n)
7
PYTHON3
def candles(a,b): c = a while(a >= b): c += a//b x = a % b a //= b a += x return c a,b = input().split() a,b = int(a),int(b) print(candles(a,b))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int x = a; while (a >= b) { x = x + (a / b); a = (a / b) + (a % b); } cout << x << endl; return 0; }
7
CPP
# coding: utf-8 a, b = [int(i) for i in input().split()] aa = 0 cnt = 0 while a: cnt += a aa += a a = aa//b aa = aa%b print(cnt)
7
PYTHON3
a, b = map(int, input().split()) t = 0 while a > 0: a -= 1 t += 1 if t % b == 0: a += 1 print(t)
7
PYTHON3
a, b = map(int,input().split()) cnt = a while a>=b: a = a-b+1 cnt+=1 print(cnt)
7
PYTHON3
a, b = map(int, input().split()) used = 0 while a > 0: used += 1 if used % b == 0: a += 1 a -= 1 print(used)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int total, v, n; cin >> v >> n; total = v; while ((v / n) > 0) { total = total + v / n; v = v / n + v % n; } cout << total; return 0; }
7
CPP
a, b = map(int, input().split()) duration = 0 remains = 0 while a > 0: duration += a a += remains remains = a % b a //= b print(duration + remains // b)
7
PYTHON3
a, b=map(int, input().split()) hours=a cur_a=a cur_b=0 while cur_a>0: cur_b+=cur_a cur_a=cur_b//b cur_b%=b hours+=cur_a print(hours)
7
PYTHON3
l1 = [int(x) for x in input().split()] candles, mod = l1[0],l1[1] ans = 0 unused = 0 while candles: #print(candles,unused) ans+=candles if int((unused+candles)/mod)>int(candles/mod): temp = (unused+candles)%mod candles = int((unused+candles)/mod) unused = temp else: unused+=candles%mod candles =int(candles/mod) print(ans)
7
PYTHON3
l=input().split() a=int(l[0]) b=int(l[1]) s=a while a/b>=1: s+=int(a/b) a=int(a/b)+a%b print(s)
7
PYTHON3
a, b = input().split() a = int(a) b = int(b) candles = a stumps = 0 hours = 0 while candles>0: candles-=1 stumps+=1 hours+=1 if stumps==b: stumps = 0 candles+=1 print(hours)
7
PYTHON3
a, b = map(int, input().split()) count = 0 while a: count += 1 a -= 1 if not count % b: a += 1 print(count)
7
PYTHON3
a, b = list(map(int, input().split())) h = 1 lo = 0 while True: a -= 1 lo += 1 if lo == b: a += 1 lo = 0 if a == 0: print(h) break h += 1
7
PYTHON3
def solver(candles:int, to_reproduce:int): count = 0 while candles >= to_reproduce: candles = candles - to_reproduce + 1 count+= 1 return count st = input() list = [int(s) for s in st.split() if s.isdigit()] candles = list[0] to_reproduce = list[1] if candles >= to_reproduce: print(solver(candles, to_reproduce) + candles) else: print(candles)
7
PYTHON3
a, b = map(int, input().split()) c = 0 while a >= b: c += b a -= b a += 1 print(a + c)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int n, k, cnt; int main() { cin >> n >> k; while (n - k + 1 > 0) { n -= k; cnt += k; n++; } cout << cnt + n; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; int main() { int a, b, res = 0; cin >> a >> b; res = a; while (a / b > 0) { res += a / b; a = a / b + a % b; } cout << res << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int a, b, c; int main() { cin >> a >> b; while (a > 0) { if (a >= b) { a = a - b + 1; c = c + b; } else { c = c + a; break; } } cout << c; }
7
CPP
a,b = map(int,input().split()) k=0 k1=0 while a>0: k+=1 k1+=1 a-=1 if (k1==b): a+=1 k1=0 print(k)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, q, s = 0, n, r, flag = 0, x = 3, r1; cin >> a >> b; n = a; q = a / b; r = a % b; while (q + r >= b) { flag = 1; s += q; r1 = r; r = (q + r) % b; q = (q + r1) / b; } s += q; if (flag == 1) cout << s + a; else cout << q + a; return 0; }
7
CPP
a, b = [int(x) for x in input().split()] hours = a while (a >= b): hours += (a // b) a = (a // b) + (a % b) print(hours)
7
PYTHON3
n, x = map(int, input().split()) c = 0 s = 0 while(n > 0): c += n s += n%x n = n//x + s//x s = s%x print(c)
7
PYTHON3
n,k=input().split() count=int(n) while int(n)>=int(k): count=count+int(n)//int(k) n=int(n)//int(k)+int(n)%int(k) print(count)
7
PYTHON3
n, m = (int(i) for i in input().split()) days = n rem = 0 while n: rem += n%m n = n//m n += rem//m rem = rem%m days += n print(days)
7
PYTHON3
import math a,b=map(int,input().split()) sum=a while a>=b: sum+=a//b a=a//b+a%b sum=int(sum) print(sum)
7
PYTHON3
a,b = map(int,input().split()) t = 0 l = 0 while a >0: t +=1 a -=1 l +=1 if l >= b: a +=1 l -=b print(t)
7
PYTHON3
a,b = map(int,input().split()) total = 0 residual = 0 while a!=0: total+=a residual += a%b a = a//b if residual >= b: a += residual//b residual = residual%b print(total)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const long long int INF = LLONG_MAX / 2; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int t = 1, i, j; while (t--) { long long int a, b; cin >> a >> b; long long int ans = a, temp; while (a >= b) { temp = a % b; a /= b; ans += a; a += temp; } cout << ans << "\n"; } return 0; }
7
CPP
a,b=map(int,input().split()) ans,rest=0,0 while a or rest>=b: ans+=a rest+=a a-=a a+=rest//b rest-=(rest//b)*b print(ans)
7
PYTHON3
a,b=[int(x) for x in input().split()] print((a*b-1)//(b-1))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int counter = a; int rem, quo; while (a >= b) { rem = a % b; quo = a / b; a = quo + rem; counter += quo; } cout << counter; return 0; }
7
CPP
a,b=map(int,input().split()) num=0 while a//b>=1: a-=b a+=1 num+=b print(num+a)
7
PYTHON3
a, b = map(int, input().split()) ans = a burnt = 0 hours = 0 while ans > 0 or burnt >= b: ans = ans - 1 burnt = burnt + 1 if burnt > b: burnt = burnt - b ans = ans + 1 hours = hours + 1 print(hours)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int ans = (a * b - 1) / (b - 1); cout << ans; }
7
CPP
a,b = map(int,input().split()) ans = a while a>=b: ans += a//b rem = a%b a = a//b a += rem print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long a, b, d, k; int main() { cin >> a >> b; while (a > 0) { k = k + a; d = d + a; a = d / b; d %= b; } cout << k << endl; return 0; }
7
CPP
a,b=map(int,input().split()) n=a; while(a>=b): t=a a=a//b n=n+a a=a+(t%b) print(n)
7
PYTHON3
a, b = map(int, input().split()) c = a while a//b>0: c += a//b a = a//b + a%b print(c)
7
PYTHON3
candle, b = [int(x) for x in input().split()] hours = 0 burnt_out = 0 while True: if candle <= 0: break hours += candle burnt_out += candle candle = int((burnt_out) / b) burnt_out = burnt_out % b print(hours)
7
PYTHON3
def main(): a, b = map(int, input().split()) hours = a spare = a while spare >= b: new = spare // b hold = spare % b hours += new spare = hold + new print(hours) main()
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, cnt = 0; cin >> a >> b; cnt += a; while (a >= b) { cnt += a / b; a = a / b + a % b; } cout << cnt << endl; return 0; }
7
CPP
a,b = map(int,input().split()) hourslit = a oldcandles = a while oldcandles >= b: q = oldcandles // b oldcandles -= q*(b-1) hourslit += q print(hourslit)
7
PYTHON3
import os import sys import math import collections #from bisect import bisect_left as bl #c++ lowerbound bl(array,element) #from bisect import bisect_right as br #c++ upperbound br(array,element) def get_int(): return int(input()) def get_ints(): return map(int, input().split()) def get_strs(): return input().split() def get_float(): return float(input()) def get_floats(): return map(float, input().split()) def list_strs(): return list(input().split()) def list_ints(): return list(map(int, input().split())) def list_floats(): return list(map(float, input.split())) def post(x): print(x, end=' ') a,b = get_ints() res = a mod = 0 diff = 0 while a >= b: diff = a//b res += diff mod = a%b a = diff + mod print(res)
7
PYTHON3
a,b = map(int,input().split()) total = 0 burned = 0 while(a>0): total += a burned += a a = burned//b burned = burned%b print(total)
7
PYTHON3
a,b=map(int,input().split()) sum=a p=0 y=0 while(a>=b): y=a%b a=int(a/b) sum=sum+a a=a+y print(sum)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long int drunk = 0; long long int n, k, temp1, butt; cin >> n >> k; drunk = n; butt = n; while (butt >= k) { temp1 = butt / k; drunk += temp1; butt = (butt % k) + temp1; } cout << drunk << endl; return 0; }
7
CPP
a,b=map(int,input().split()) s=0 c=0 from math import floor new=a old=c while new>0: s=s+new old=old+new new=0 new=floor(old/b) old=old-b*new print(s)
7
PYTHON3
a, b = map(int, input().split()) sum = 0 while a != 0: if a < b: print(sum + a) break else: sum += b a = a - b + 1
7
PYTHON3
n,m = map(int,input().split()) c=n while n>=m : k=int(n%m) n=(n//m) c=c+n n=k+n print(int(c))
7
PYTHON3
a,b=[int(x) for x in input().split()] sum=a while a//b: sum+=a//b a-=(a//b)*(b-1) print(sum)
7
PYTHON3
#include <bits/stdc++.h> int main() { int a, b, c = 0; scanf("%d%d", &a, &b); int s = 0; while (a > 0) { s = s + a; int xx = a; a = (xx + c) / b; c = (xx + c) % b; } printf("%d\n", s); return 0; }
7
CPP
a,b = map(int,input().split()) copy_of_a = a while a//b > 0: c = a//b copy_of_a += c a = c + a%b print(copy_of_a)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; while (cin >> a >> b) { int m = a; while (a / b > 0) { m += a / b; a = a % b + a / b; } cout << m << endl; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int a, b, cont = 0, c = 0; cin >> a >> b; cont += a; while (a >= 0) { a -= b; if (a >= 0) { cont++; a++; } else { break; } } cout << cont << endl; return 0; }
7
CPP
a,b=map(int,input().split()) cnt=0 cnt=cnt+a while(a>=b): cnt=cnt+a//b a=a//b+a%b print(cnt)
7
PYTHON3
x,y = map(int,input().split(" ")) a = 0;c = 0 while x>0.1: a += x x = x/y pass print(int(a))
7
PYTHON3
n,m=[int(x) for x in input().split()] a=n while int(n/m)>=1: a+=int(n/m) n=int(n/m)+n%m print(a)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, ab = 0, hours = 0; cin >> a >> b; while (a != 0) { a--; ab++; hours++; if (ab == b) { a++; ab = 0; } } cout << hours; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int a, b; int ans = 0; cin >> a >> b; ans += a; while (a >= b) { ans += (a / b); a = (a / b) + (a % b); } cout << ans; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, b, ans = 0; cin >> n >> b; if (n % (b - 1)) ans = n + n / (b - 1); else ans = -1 + n + n / (b - 1); cout << ans; return 0; }
7
CPP
a,b=map(int,input().split()) ncount=a while a>=b: c=a%b a=a//b ncount+=a a=a+c print(ncount)
7
PYTHON3
a,b=map(int,input().split()) s=0 r=a i=0 while r>0: i=i+1 r=r-1 s=s+1 if s==b: s=0 r=r+1 print(i)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int ss(int a, int b) { int total = a; while (a >= b) { int div = a / b; total += div; int rem = a % b; a = div + rem; } return total; } int main() { int a, b; cin >> a >> b; cout << ss(a, b); }
7
CPP
a, b = [int(i) for i in input().split()] print(a + int((a-1)/(b-1)))
7
PYTHON3
while True: try: loi=list(map(int, input().split(' '))) a=loi[0] b=loi[1] numUsedCandles=0 numHours=0 while a>0 and numUsedCandles<b: a-=1 numUsedCandles+=1 if numUsedCandles>=b: numUsedCandles-=b a+=1 numHours+=1 print(numHours) except (EOFError, ValueError): exit()
7
PYTHON3
a,b = map(int, input().strip().split(" ")) time = a while True: rem = a % b a = int(a/b) time += a a = a + rem if int(a / b) == 0: break else: continue print(int(time))
7
PYTHON3
# -*- coding: utf-8 -*- """ Created on Wed Jul 10 20:06:42 2019 @author: avina """ a,b = map(int, input().split()) w = a q = 0 while a>= b: w+= a//b q= a%b a = a//b + q print(w)
7
PYTHON3
a,b=map(int,input().split()) c=0;time=0 while a!=0: time+=a a,c=(a+c)//b,(a+c)%b print(time)
7
PYTHON3
a = list(map(int, input().split())) i = 1 while a[0]>0: if i % a[1] == 0: a[0] = a[0] + 1 a[0] = a[0] - 1 i = i + 1 print(i - 1)
7
PYTHON3
#include <bits/stdc++.h> void solve() { int n, b; std::cin >> n >> b; int s = 0; while (n) { if (n < b) { s += n; break; } s += b * (n / b); n = n / b + n % b; } std::cout << s; } int main() { solve(); return 0; }
7
CPP
a,b=map(int,input().split()) count=0 count+=a x=a//b while x!=0: count+=x a=x+a%b x=a//b print(count)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int new_year_candles(int a, int b) { int new_a; if (a / b >= 1) { new_a = a / b + a % b; } else { new_a = a; } return new_a; } int main(int argc, char** argv) { int a, b, result; cin >> a; cin >> b; result = 0; result += a; for (;;) { int res; res = a / b; a = new_year_candles(a, b); result += res; if (a < b) { break; } } cout << result; return 0; }
7
CPP
container,b = map(int,input().split()) day = 0 burnt = 0 while container != 0: container -= 1 day += 1 burnt += 1 if burnt==b: container += 1 burnt = 0 print(day)
7
PYTHON3
n,m=tuple(input().split(" ")) n=int(n) m=int(m) stock=n day=0 while stock>0: stock-=1 day+=1 if day%m==0: stock+=1 print(day)
7
PYTHON3
a,b=map(int,input().split()) t=0 while a>0: t=t+1 a=a-1 if t%b==0: a=a+1 print(t)
7
PYTHON3
a,b=map(int,input().split()) saat = 0 yananlar = 0 while a != 0 : saat += 1 a-=1 yananlar += 1 if yananlar == b: yananlar = 0 a+=1 print(saat)
7
PYTHON3
a, b = map(int, input().split()) hours = 0 used = 0 while a > 0: hours += 1 used += 1 a -= 1 if used >= b: used -= b a += 1 print(hours)
7
PYTHON3
def squizer(candels): global b global answer global ost while candels >= b: ost.append(candels % b) candels = candels // b answer.append(candels) ost.append(candels) a, b = list(map(int, input().split())) ost = [] answer = [a] squizer(a) c = sum(ost) while c >= b: ost.clear() squizer(c) c = sum(ost) print(sum(answer))
7
PYTHON3
a, b = map(int, input().split()) sum = 0 c = 0 while (a > 0) or (c >= b): sum += a c += a a, c = c // b, c % b print(sum)
7
PYTHON3
a, b = map(int, input().split()) h = 0 while a > 0: h += 1 a -= 1 if h % b == 0: a += 1 print(h)
7
PYTHON3
a = input().split() b = int(a[1]) a = int(a[0]) answ = 0 x = 0 while a != 0: a -= 1 answ += 1 x += 1 if x == b: x = 0 a += 1 print(answ)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, m, ans = 0, du = 0; cin >> n >> m; ans = n; while (n > 0) { ans += (n / m); int nc = n / m; n -= m * (n / m); n += nc; if (nc == 0) break; } cout << ans << endl; return 0; }
7
CPP
a, b = [int(x) for x in input().split()] ans = (a - 1) // (b - 1) ans += a print(ans)
7
PYTHON3
n,m = [int(x) for x in input().split()] r = n c = n while c >= m: a = c//m b = c%m r += a c = a+b print(r)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, i = 0; cin >> a >> b; int c = a; while (c > 0) { i++; c--; if (i % b == 0) { c++; } } cout << i; }
7
CPP
import math a, b = map(int, input().split()) t = 0 c = 0 while c >= b or a: t += a c += a a = math.floor(c / b) c = c % b print(t)
7
PYTHON3