akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

vector<pair<unsigned long long, int> > factorize(unsigned long long n)
{
    vector<pair<unsigned long long, int> >result;
    for (unsigned long long d = 2; d * d <= n; ++d) {
        int count = 0;
        while (n % d == 0) {
            n /= d;
            ++count;
        }
        if (count) {
            result.push_back(pair<unsigned long long, int>(d, count));
            if (n == 1) {
                break;
            }
        }
    }
    if (n > 1) {
        result.push_back(pair<unsigned long long, int>(n, 1));
    }
    return result;
}

unsigned long long powull(unsigned long long base, unsigned long long exponent)
{
    unsigned long long result = 1;
    while (exponent) {
        if (exponent & 1) {
            result *= base;
        }
        base *= base;
        exponent >>= 1;
    }
    return result;
}

unsigned long long totient(unsigned long long n)
{
    unsigned long long result = 1;
    vector<pair<unsigned long long, int> > fac = factorize(n);
    for (const pair<unsigned long long, int> &f: fac) {
        unsigned long long p = f.first;
        unsigned long long e = f.second;
        result *= powull(p, e - 1) * (p - 1);
    }
    return result;
}

int main(void)
{
    int n;
    cin >> n;
    cout << totient(n) << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
using namespace std;
typedef long long LL;

LL n,ans = 0;
LL a[200005],b[200005];
LL c[200005];

struct node{
	LL id,val;
	bool operator < (const node &nd)const{
		return nd.val > val;
	}
}h,t;
priority_queue <node> q;

bool cmp(LL x,LL y){
	return b[x] > b[y];
}

LL getnum(LL x){
	if(x == 0) return n;
	if(x == n + 1) return 1;
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i <= n;i ++) cin >> b[i];
	for(LL i = 1;i <= n;i ++){
		if(a[i] < b[i]){
			t.id = i; t.val = b[i];
			q.push(t);
		}
	}
	
	while(!q.empty()){
		LL del,mns,i = q.top().id; q.pop();
		del = b[i] - a[i];
		mns = b[getnum(i - 1)] + b[getnum(i + 1)];
		
		if(del / mns == 0 && b[i] != a[i]){ cout << -1 << endl; return 0; }
		
		ans += del / mns;
		b[i] -= (del / mns) * mns;
		if(b[i] > a[i]){
			t.id = i; t.val = b[i];
			q.push(t);
		}
	}
	cout << ans << endl;
	return 0;
}
//

Measured memory_bytes: 9456
N = int(input())
x = 0
for i in range(1, N + 1):
    if i % 3 == 0:
        print(" %d"%i, end="")
    else:
        x = i
        while (x):
            if x % 10 == 3:
                print(" %d"%i, end="")
                break
            x //= 10
print()




Measured memory_bytes: 5872
N = int(input())
n = len(list(str(N)))
if n >= 6:
  ans = 90909
elif n >= 5:
  ans = 909 + (N - 9999)
elif n >= 4:
  ans = 909
elif n >= 3:
  ans = 9 + (N - 99)
elif n >= 2:
  ans = 9
else:
  ans = N
print(ans)

Measured memory_bytes: 3060
n = int(input())
#a, b = map(int, input().split())
#x, y, z = map(int, input().split())
#a, b, c, d = map(int, input().split())
#arr = list(map(int, input().split()))
#s = input()

if n % 10 in [2, 4, 5, 7, 9]:
	print('hon')
elif n % 10 == 3:
	print('bon')
else:
	print('pon')

Measured memory_bytes: 9168
#include <iostream>
#include <queue>
using namespace std;
class State{
public:
  string s;
  int rem;
  State(){}
  State(string s, int rem) :
    s(s), rem(rem){}
};
int main(){
  int n, q;
  queue<State> que;
  while(cin >> n >> q){
    for(int i = 0; i < n; i++){
      string name;
      int rem;
      cin >> name >> rem;
      que.push(State(name, rem));
    }
    int now = 0;
    while(!que.empty()){
      State st = que.front(); que.pop();

      if(st.rem <= q){
        now += st.rem;
        cout << st.s << " " << now << endl;
      }
      else{
        now += q;
        st.rem -= q;
        que.push(st);
      }
    }
  }
}



Measured memory_bytes: 6264
#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll ar[200005];

int main()
{
	ll n, i, ans, x, m, sum=0;

	cin>>n>>m;

	for(i=1; i<=n; i++)
	{
		cin>>ar[i];
	}
	sort(ar,ar+n+1);

   for(i=1; i<=n-m; i++)
   {
   	sum+=ar[i];
   }
   cout<<sum<<endl;
}

Measured memory_bytes: 1792
n, c = input().split()
n = int(n)
c = int(c)
x = [0]
v = [0]
gs1 = [0]
gs2 = [0]
gs3 = [0]
gs4 = [0]
s = 0
for i in range(n):
    xx, vv = input().split()
    xx = int(xx)
    vv = int(vv)
    x.append(xx)
    v.append(vv)
    s += vv
    f = s - xx
    gs1.append(max(gs1[-1], f))
    f = s - 2 * xx
    gs2.append(max(gs2[-1], f))
s = 0
for i in range(-1, -n - 1, -1):
    s += v[i]
    f = s - (c - x[i])
    gs3.append(max(gs3[-1], f))
    f = s - 2 * (c - x[i])
    gs4.append(max(gs4[-1], f))
ans = 0
for i in range(n + 1):
    ans = max(ans, gs1[i] + gs4[n - i], gs2[i] + gs3[n - i])
print(ans)

Measured memory_bytes: 23576
#include <iostream>
#include <string>

using namespace std;

string s;

int main(void)
{
	cin >> s;
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  char X;
  cin >> X;
  if(X >= 'a'&&X <= 'z'){
    cout << 'a';
  }
  else{
    cout << 'A';
  }
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

const int mod=1e9+7;
#define ll long long

ll dp[110][21];


int main(){
	int r;
	cin>>r;
	cout<<r*r<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353

n = int(input())
P = [list(map(int, input().split())) for i in range(n)]

A = [e[0] for e in P]
B = [e[1] for e in P]
A.sort()
B.sort()

if n%2 == 1:
    piv = (n+1)//2
    start = A[piv-1]
    end = B[-piv]
    # print(start, end)
    print(end - start + 1)
else:
    piv = n//2
    start = (A[piv-1] + A[piv])/2
    end = (B[-piv] + B[-piv-1])/2
    # print(start, end)
    print(int((end - start)*2 + 1))


Measured memory_bytes: 130176
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	string s;

	cin >> s;

	if (s.size() == 2)cout << s << "\n";
	else if (s.size() == 3)cout << s[2] << s[1] << s[0] << "\n";


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define mod 1000000007
#define point complex<long long>
#define pi acos(-1)
#define pb push_back


typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
double dis(int x1, int x2, int y1, int y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
bool check(int x1, int x2, int x3, int x4, int y1, int y2, int y3, int y4){
    double res1, res2, res3, res4;
    res1=dis(x1, x2, y1, y2);
    res2=dis(x2, x3, y2, y3);
    res3=dis(x3, x4, y3, y4);
    res4=dis(x4, x1, y4, y1);
    double res5, res6;
    res5=dis(x1, x3, y1, y3);
    res6=dis(x2, x4, y2, y4);
    return (res1==res2 && res1==res3 && res1==res4 && res5==res6 && (sqrt(2*res1*res1))==res5);
}
int main()
{
    Fastio();
    int ttt=1; //cin>>ttt;
    while(ttt--){
        ll x1, x2, y1, y2;
        cin>>x1>>y1>>x2>>y2;
        /*for(int x3=-1000; x3<=1000; x3++){
            for(int y3=-1000; y3<=1000; y3++){
                if(x1==x3 && y1==y3)continue;
                int x4=x3+abs(x1-x2), y4=y3+abs(y1-y2);
                bool st=0;
                st=check(x1, x2, x3, x4, y1, y2, y3, y4);
                if(st)return cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<'\n', 0;

                x4=x3+abs(x1-x2), y4=y3-abs(y1-y2);
                st=check(x1, x2, x3, x4, y1, y2, y3, y4);
                if(st)return cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<'\n', 0;

                x4=x3-abs(x1-x2), y4=y3-abs(y1-y2);
                st=check(x1, x2, x3, x4, y1, y2, y3, y4);
                if(st)return cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<'\n', 0;

                x4=x3-abs(x1-x2), y4=y3+abs(y1-y2);
                st=check(x1, x2, x3, x4, y1, y2, y3, y4);
                if(st)return cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<'\n', 0;
            }
        }*/
        int dx=x2-x1, dy=y2-y1;
        cout<<x2-dy<<" "<<y2+dx<<" "<<x1-dy<<" "<<y1+dx<<'\n';
    }

    return 0;
}


Measured memory_bytes: 3676
n = gets.to_i
P_arr = gets.split.map(&:to_i)
arr = []
counter = 0

(1..(n-2)).each do |i|
  arr << P_arr[i-1]
  arr << P_arr[i]
  arr << P_arr[i+1]
  arr.sort!
    if P_arr[i] == arr[1]
      counter += 1
    end
  arr = []
end

p counter


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    string s;
    cin >> s;
    
    int cnt = 0;
    rep(i, sz(s)) {
        int j = sz(s) - 1 - i;
        if (j <= i) break;
        if (s[i] != s[j]) ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

// if 0 -> (i-1,j) ;if 1 -> (i,j-1) ;if 2 -> pick and (i-1,j-1);

int dp[3000][3000];
int choice[3000][3000];

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    dp[0][0]=0;
    if(s[0]==t[0]){
        dp[0][0]=1;
        choice[0][0]=2;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            //not pick character
            if(i>0){
                choice[i][j]=0;
                dp[i][j]=dp[i-1][j];
            }
            if(j>0){
                if(dp[i][j-1]>dp[i][j]){
                    choice[i][j]=1;
                    dp[i][j]=dp[i][j-1];
                }
            }
            //pick character
            if(s[i]==t[j]){
                int ans=1;
                if(i>0 and j>0){
                    ans=1+dp[i-1][j-1];
                }
                if(ans>dp[i][j]){
                    choice[i][j]=2;
                    dp[i][j]=ans;
                }
            }
        }
    }

    int i=n-1,j=m-1;
    string subseq;
    while(i>=0 and j>=0){
        if(choice[i][j]==0){
            i--;
        }
        else if(choice[i][j]==1){
            j--;
        }
        else if(choice[i][j]==2){
            subseq.push_back(s[i]);
            i--;
            j--;
        }
    }
    reverse(subseq.begin(),subseq.end());
    cout<<subseq;
    // cout<<dp[n-1][m-1];
}

Measured memory_bytes: 73888
input = raw_input
n, a, b = map(int, input().split(" "))

diff = b - a
if diff % 2 == 0:
    out = diff // 2
else:
    diff1 = a - 1
    diff2 = n - b
    if diff1 <= diff2:
        out = a - 1 + 1
        a2 = 1
        b2 = b - a
    else:
        out = n -b + 1
        b2 = n
        a2 = a + (n-b+1)

    difff = (b2 - a2)
    assert difff % 2 == 0
    out += diff // 2

print(out)

Measured memory_bytes: 28012
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

using namespace std;
const int MOD = 1000000007;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y; cin >> x >> y;
    if (y & 1 || x * 4 < y || x * 2 > y) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}



Measured memory_bytes: 3620
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int64_t n;
  cin>>n;
  cout<<(n)*(n-1)/2<<endl;



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    double s = w*h*0.5;

    int c=0;
    if(x*2==w && y*2==h) c=1;

    cout << fixed << setprecision(7) << s << ' ';
    cout << c << endl;
}

Measured memory_bytes: 3772
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
int n,a[200000],k;
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int main()
{
	scanf("%d%d",&n,&k);
	int max=0;
	set<int> s;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		max=max>a[i]?max:a[i];
		if(a[i]==k){puts("POSSIBLE");return 0;}
		s.insert(a[i]%k);
	}
	if(max<k){puts("IMPOSSIBLE");return 0;}
	if(n==1){puts("IMPOSSIBLE");return 0;}
	sort(a,a+n);
	int x=a[0];
	for(int i=1;i<n&&x>1;i++)x=gcd(x,a[i]);
	puts(k%x?"IMPOSSIBLE":"POSSIBLE");
	return 0;
}


Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;*/
#define int long long
#define fastr ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define mp make_pair
double jk=0.4;
#define power(x,y) pow(x,y)+jk
#define endl "\n"
#define mod 1000000007
#define N 1000000000
int in(){
int n;cin>>n;
return n;}
void _do_(){
		int y;cin>>y;
		int x=100;int count=0;
		while(x<y){
			x=x+x/100;
			count++;}
			cout<<count<<endl;

}signed main(){fastr
//int tc=in();
int tc=1;
while(tc--)_do_();
cerr<<"Time elapsed:";
cerr<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
return 0;}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<iomanip>

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(m);
    for(int i=0;i<m;++i){
        int c;cin>>c;
        for(int j=0;j<c;++j){
            int sw;
            cin>>sw;
            sw--;
            s[i].push_back(sw);
        }
    }
    int ret = 0;
    vector<int> p(m);
    for(auto &a : p) cin>>a;
    for(int i=0;i<(1<<n);++i){
        int right = 0;
        for(int j=0;j<m;++j){
            int on = 0;
            for(auto a : s[j]){
                if(i&(1<<a)) on = on ^ 1; 
            }
            if(on == p[j])right++;
        }
        if(right == m)ret++;
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n,p;
    int stone[64]={};
    cin >> n >> p;
    stone[n]=p;
    if(!n&&!p) return 0;
    for(int pos=0;;pos=(pos+1)%n){
      if(stone[n]){
	stone[n]--;
	stone[pos]++;
	if(stone[pos]==p){
	  cout << pos << endl;
	  break;
	}
      }else{
	stone[n]+=stone[pos];
	stone[pos]=0;
      }
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	while(true){
		int N;
		double p[100000],dp[100001]={},inf=1e20;
		vector<int> vc;
		cin>>N;
		if(N==0) break;
		rep(i,N) cin>>p[i];
		rep(i,N) if(p[i]!=1) vc.pb(i);
		vc.pb(N);
		rep(i,N+1) dp[i]=inf;
		dp[N]=0;
		for(int i=N-1;i>=0;i--){
			int id=lower_bound(all(vc),i+1)-vc.begin();
			double ex=0;
			int pre=i;
			for(int j=id,cnt=0;j<vc.size()&&cnt<30;j++,cnt++){
				int v=vc[j];
				ex=(ex+1)/p[pre]+(v-pre-1);
				chmin(dp[i],ex+(v==N?0:1)+dp[v]);
				pre=v;
			}
		}
		printf("%.12f\n",dp[0]);
	}
}

Measured memory_bytes: 3712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuLCS solver = new AizuLCS();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuLCS {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int tt = in.nextInt();

            while (tt-- != 0) {
                final String x = in.next();
                final String y = in.next();

                out.printf("%d\n", lcs(x, y));
            }
        }

        private int lcs(final String a, final String b) {
            int n = a.length();
            int m = b.length();

            int[][] dp = new int[n + 1][m + 1];
            for (int i = 1; i < n + 1; i++) {
                for (int j = 1; j < m + 1; j++) {
                    int insertion = dp[i][j - 1];
                    int deletion = dp[i - 1][j];
                    int match = dp[i - 1][j - 1] + 1;

                    if (a.charAt(i - 1) == b.charAt(j - 1)) {
                        dp[i][j] = match;
                    } else {
                        dp[i][j] = Math.max(insertion, deletion);
                    }
                }
            }

            return dp[n][m];
        }

    }
}




Measured memory_bytes: 64032
#include<iostream>
#include<cstdio>
#define MAX 100000
using namespace std;
int parent(int i)
{
  return i/2;
}
int left(int i )
{
  return 2*i;
}
int right (int i)
{
  return 2*i+1;
}
int main ()
{
  int H,i,a[MAX+1];
  cin>>H;
  for( i = 1;i<=H;i++) cin>>a[i];
  for( i = 1;i<=H;i++)
    {
    cout<<"node "<<i<<": key = "<<a[i]<<", ";
    if(parent(i)>=1)cout<<"parent key = "<<a[parent(i)]<<", ";
    if(left(i)<=H)  cout<<"left key = "<<a[left(i)]<<", ";
    if(right(i)<=H) cout<<"right key = "<<a[right(i)]<<", ";
    cout<<endl;
    }
  return  0 ;
  }



Measured memory_bytes: 3096
#include<iostream>

using namespace std;

int cell[5], k[5];
int sum = 0;
int tmp = 9;
int tmp_i = 0;

int main(){
  for(int i = 0; i < 5; ++i){
    cin >> cell[i];
    if(cell[i] % 10 <= tmp && cell[i] % 10 != 0){
      tmp = cell[i] % 10;
      tmp_i = i;
    }
    //sum += cell[i];
  }
  for(int i = 0; i < 5; ++i){
    if(i != tmp_i && (cell[i] % 10) != 0){
      k[i] = cell[i];
      k[i] += 10 - (cell[i] % 10);
      sum += k[i];
    }else{
      k[i] = cell[i];
      sum += cell[i];
    }
  }
  cout << sum << endl;
  //cout << tmp_i << endl;
  /*
  for(int i = 0; i < 5; ++i){
    cout << k[i] << endl;
  }
  */
  
}

Measured memory_bytes: 256
#C - Exception Handling(ABC134)
N=int(input())
B=0
b=0
C=0
for i in range(N):
    A=int(input())
    if B<A:
        B=A
        b=i
    elif C<A:
        C=A
for i in range(N):
    if b==i:
        print(C)
    else:
        print(B)

Measured memory_bytes: 4540
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>
#include <queue>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int N, H;
	cin >> N >> H;

	int max_a = 0;
	vector<int> b(N, 0);

	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a >> b[i];

		max_a = max(max_a, a);
	}

	sort(b.begin(), b.end(), [](const int& l, const int& r)
	{
		return l > r;
	});

	int result = 0;
	for (int e : b)
	{
		if (e > max_a && H > 0)
		{
			H -= e;
			result++;
		}
		else
		{
			break;
		}
	}

	if (H > 0)
	{
		result += (H / max_a) + (H % max_a != 0);
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

#define MAX 100000

int A[MAX];

int partition(int p,int r){
  int x,i,j,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

int main(){
  int i,q,n;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  q=partition(0,n-1);

  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q)printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>


struct Node {
    int idx;
    int parent = -1;
    std::vector<int> childs;
};

long long int N, K;
long long int MOD = 1000000007;

long long int search(int idx, long long int val, std::vector<Node>& nodes) {
    long long int next_val = std::max(val - 1, K - 2);
    for (int i = 0; i < nodes[idx].childs.size(); i++) {
        val = (val * search(nodes[idx].childs[i], next_val - i, nodes)) % MOD;
    }
    return val;
}

int main() {
    std::cin >> N >> K;

    std::vector<std::vector<int>> linked_list(N);
    std::vector<Node> nodes(N);

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        a--;
        b--;
        linked_list[a].emplace_back(b);
        linked_list[b].emplace_back(a);
    }

    nodes[0].parent = 0;
    std::queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int idx = que.front();
        que.pop();
        for (auto next_idx : linked_list[idx]) {
            if (nodes[next_idx].parent == -1) {
                que.push(next_idx);
                nodes[next_idx].parent = idx;
                nodes[idx].childs.emplace_back(next_idx);
            }
        }
    }


    std::cout << search(0, K, nodes) << std::endl;;
}


Measured memory_bytes: 19528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> as(N);
    vector<bool> bs(1000005, false);
    for(int i=0; i<N; i++)
    {
        cin >> as.at(i);
        bs.at(as.at(i)) = true;
    }

    sort(as.begin(), as.end());
    vector<bool> used(1000005, false);
    for(auto a : as)
    {
        if(!bs.at(a)) continue;
        if(used.at(a))
        {
            bs.at(a) = false;
            continue;
        }
        used.at(a) = true;
        for(int i=2*a; i<=1000000; i+=a)
        {
            bs.at(i) = false;
        }
    }
    int ans = 0;
    for(auto b : bs)
    {
        if(b) ans++;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;

int main(){
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int a, n, h;
    long long sum = 0;
    cin >> h >> n;
    for(int i = 0; i < n; ++i){
        cin >> a;
        sum += a;
    }
    cout << (sum >= h ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

int main() {
    init_io();
    ll N;
    cin >> N;
    V<ll> A(N), B(N);
    for(ll &e : A) cin >> e;
    for(ll &e : B) cin >> e;
    ll ans = 0;
    for(ll i = 0; i < 30; i++) {
        V<ll> am, bm;
        ll cnt = 0;
        ll mod = (1ll << (i + 1));
        for(ll i = 0; i < N; i++) {
            am.push_back(A[i] % mod);
            bm.push_back(B[i] % mod);
        }
        sort(ALL(bm));
        ll dig1 = (1ll << i);
        ll dig2 = mod;
        V<PLL> ranges = {
            PLL(dig1, dig2),
            PLL(dig1 + dig2, dig2 * 2),
        };
        for(ll e : am) {
            for(const auto &p : ranges) {
                ll l, r;
                tie(l, r) = p;
                ll el = l - e;
                ll er = r - e;
                auto itel = lower_bound(ALL(bm), el);
                auto iter = lower_bound(ALL(bm), er);
                cnt += distance(itel, iter) % 2;
            }
        }
        ans += (cnt & 1 ? (1ll << i) : 0);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8432
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char s;
	cin >>s;
	if(s=='a' || s=='e' ||s=='i' || s=='o' || s=='u'){
		cout <<"vowel"<<endl;
	}else{
		cout <<"consonant"<<endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,x,t,y,flag=1;
    scanf("%d",&n);
    while(n--)
    {
       scanf("%d%d%d",&t,&x,&y);
        if(t<(x+y))
            flag=0;
        else if(t%2==1&&(x+y)%2==0||t%2==0&&(x+y)%2==1)
           flag=0;
    }
         if(flag)
            printf("Yes\n");
        else
            printf("No\n");
            return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

double a, b, h, m, pi, x, y;
int main() {
	cin >> a >> b >> h >> m;
	pi = acos(-1.0);
	x = 2 * pi * (h/12 + m/60/12 - m/60);
	y = a*a + b*b - 2*a*b*cos(x);
	printf("%.15f", sqrt(y));
	return 0;
}

Measured memory_bytes: 4220
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	string s;
	cin>>s;
	int cnt=0;
	rep(i,s.size()){
		if(s[i]=='S')++cnt;
		else if(cnt>0)--cnt;
	}
	cout<<2*cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
A = list(input())
B = list(input())
C = list(input())

s = A.pop(0)
while True:
    if s == 'a':
        if A:
            s = A.pop(0)
        else:
            print('A')
            exit(0)
    elif s == 'b':
        if B:
            s = B.pop(0)
        else:
            print('B')
            exit(0)
    else:
        if C:
            s = C.pop(0)
        else:
            print('C')
            exit(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  ll n,k,sum=0;
  cin>>n>>k;
  ll a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  if(k>=n)
  {
    cout<<0<<endl;
  }
  else
  {
    for(int i=0;i<n-k;i++)
    {
       sum+=a[i];
    }
  
cout<<sum<<endl;
  }
}
return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e5+1;
vector<int> isprime(N1,1);
set<int>prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.insert(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.insert(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};
void solve(){
  string s;
  cin>>s;
  int x,y;
  cin>>x>>y;

  vector<int> v1;
  rep(i,0,s.length()) if(s[i]=='T') v1.pb(i);

  if(v1.size()==0){
    if(x==s.length() && y==0) cout<<"Yes";
    else cout<<"No";
    return;
  }

  int posx=v1[0];
  vector<int> bothx,bothy;
  int flag=1;
  rep(i,1,v1.size()){
    int num=v1[i]-v1[i-1]-1;
    if(num>0 && flag==0) bothx.pb(num);
    if(num>0 && flag==1) bothy.pb(num);
    flag^=1;
  }
  int num=s.length()-v1[v1.size()-1]-1;
  if(num>0 && flag==0) bothx.pb(num);
  if(num>0 && flag==1) bothy.pb(num);

  set<int> sx,sy;

  sx.insert(posx);
  rep(i,0,bothx.size()){
    set<int> s2;
    for(auto j:sx){
      s2.insert(j+bothx[i]);
      s2.insert(j-bothx[i]);
    }
    sx=s2;
  }

  sy.insert(0);
  rep(i,0,bothy.size()){
    set<int> s2;
    for(auto j:sy){
      s2.insert(j+bothy[i]);
      s2.insert(j-bothy[i]);
    }
    sy=s2;
  }
  if(sx.find(x)!=sx.end() && sy.find(y)!=sy.end()) cout<<"Yes";
  else cout<<"No";
}

int main(){
    optimizeIO();

    {solve();}
}


Measured memory_bytes: 4240
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <queue>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;
LL cost;

vector<LL> x;

LL ans;

LL f(LL qsize) {
    vector<LL> y = x;

    LL res = 0;

    queue<PLL> q;

    FORN(i, qsize) {
        auto e = y.back();
        y.pop_back();

        res += e + cost;

        q.push(MP(e, 1));
    }

    while (!y.empty()) {
        auto e = y.back();
        y.pop_back();

        auto f = q.front();
        q.pop();

        res += (f.FF - e) * (f.SS + 1) * (f.SS + 1) + cost;

        q.push(MP(e, f.SS + 1));
    }

    while (!q.empty()) {
        auto f = q.front();
        q.pop();

        res += f.FF * (f.SS + 1) * (f.SS + 1) + cost;
    }

    ans = min(ans, res);
    return res;
}

int main() {
    GI(n);
    GLL(cost);

    x.resize(n);

    FORN(i, n) {
        GLL(x[i]);
    }

    ans = 1LL * INF * INF;

    LL lo = 1;
    LL hi = n;
    
    while (lo < hi) {
        auto mid = (lo + hi) / 2;

        if (f(mid) < f(mid + 1)) {
            hi = mid;
        }
        else {
            lo = mid + 1;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 5136
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    if ((r * 100 + g * 10 + b) % 4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int r,d,x[15];
    cin >> r >> d >> x[0];
    rep(i,10){
        x[i+1] = r*x[i]-d;
        cout << x[i+1] << endl;
    }
	return 0;
}

Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;

long long n,w,we[100004],v[100004],dp[102][100004];

int main() {
    scanf("%lld%lld",&n,&w);
    for(int i=0;i<n;++i)    scanf("%lld%lld",we+i,v+i);
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;++i)
        for(int j=0;j<=w;++j) {
            dp[i+1][j] = max(dp[i][j],dp[i+1][j]);//atleast equivalent to old items profit
            if(j+we[i]>w) {
                dp[i+1][w] = max(dp[i+1][w],dp[i][j]);
                continue;
            }
            dp[i+1][j+we[i]] = max(dp[i+1][j+we[i]],dp[i][j] + v[i]);
        }

//    for(int i=0;i<=n;++i) {
//        for(int j=0;j<=w;++j)
//            printf("%lld ",dp[i][j]);
//        cout<<endl;
//    }
    printf("%lld",dp[n][w]);
    return 0;
}


Measured memory_bytes: 80128
n, k = [ int(v) for v in input().split() ]
jewel_list = [ int(v) for v in input().split() ]

ans = 0

for i in range(k+1):
    l = min(i,n)
    for j in range(l+1):
        left_gain = jewel_list[:j]
        if l-j != 0:
            right_gain = jewel_list[-l+j:]
        else:
            right_gain = []
        
        gabage = sorted(left_gain+right_gain)[:k-i]

        total = sum(left_gain+right_gain)
        for p in gabage:
            if p < 0:
                total -= p
            else:
                break
        ans = max(ans,total)

print(ans)

Measured memory_bytes: 41712
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B, S;

  std::cin >> A >> B;

  S = A + B;

  if (S < 10) {
    std::cout << S << std::endl;
  }
  else {
    std::cout << "error" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    
    int K;
    cin >> K;
 
    if (K == 1) {
        cout << "1"<<endl;;
        return 0;
    }
    if (K % 2 == 0 || K % 5 == 0) {
        cout << "-1"<<endl;;
        return 0;
    }
    K *= 9;
    int a = 10;
    for (int i = 0; i <= 10 * K; i++) {
        if ((7 * (a - 1 + K)) % K == 0) {
            cout << i + 1 << endl;;
            return 0;
        }
        a = (a * 10) % K;
    }
   
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string A, B, C; std::cin >> A >> B >> C;
  if ( A.back() == B.front() && B.back() == C.front() ) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define t(x) cerr<<#x<<":"<<x<<'\n';
#define t2(a,n) { cerr<<#a<<" = "; for(int i=0; i<n; ++i){ cerr << a[i] << ' '; } ; cerr <<'\n'; }
#define t3(a){ cerr<<#a<<" = "; for(auto i: a){ cerr<<i<<" "; } cerr<<'\n'; }



int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	vector<int> pre(n,0);
	pre[0] = 0;
	for(int i=1; i<n; ++i){
		pre[i] = pre[i-1];
		if( s[i-1] == 'A' and s[i] == 'C' ){
			pre[i]++;
		}
	}
	while(q--){
		int l, r;
		cin>>l>>r; l--; r--;
		cout<<pre[r] - pre[l] << endl;
	}


	#ifdef LOL
	    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    int h[n];
    ll dp[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
        dp[i]=INT_MAX;   
    }    
    dp[0]=0;    
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
          if(i-j>=0)
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }    
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1408
N = int(input())
MAX=110000
S = [_+2 for _ in range(MAX)]
old = S
i = 0
while True:
  new = set([])
  t = old[i]
  for j in range(len(old)):
    if old[j] == t or old[j]%t != 0:
      new.add(old[j])
  if len(old) == len(new):
    break
  old = list(new)
  old.sort()
  i += 1


#print(old)
A = [0 for _ in range(MAX)]  
for i in range(MAX):
  if i%2 == 0:
    continue
  if i in new and (i+1)//2 in new:
    A[i] = 1
SUM = [0 for _ in range(MAX)] 
for i in range(1,MAX):
  SUM[i] += A[i]+SUM[i-1]
#print(SUM)

for i in range(N):
  l,r = map(int,input().split())
  ans = SUM[r]-SUM[l-1]
  print(ans)

Measured memory_bytes: 15396
n, m = map(int, input().split())
a = list(map(int, input().split()))

count = 0

a.sort(reverse=True)
sum_a = sum(a)
thresh = sum_a * (1/(4*m))

for i in range(m):
    if a[i] >= thresh:
        count += 1
    else:
        break

if count < m:
    print("No")
else:
    print('Yes')


Measured memory_bytes: 9152
n = int(input())
b = list(map(int, input().split()))

procedure = [-1]*n
tmp_n = n
for m in range(n-1,-1,-1):
	for i in range(tmp_n-1, -1, -1):
		if b[i] == i+1:
			procedure[m] = i+1
			del b[i]
			tmp_n -= 1
			break
	else:
		print(-1)
		exit()

for i in range(n):
	print(procedure[i])

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;

int n, k, cnt, pl, ans;
string a;
int main()
{
	int i;
	cin >> n >> k;
	cin >> a;
	for (i = 1; i < n; i++) {
//		if (i > 1 && a[i] != a[i - 1]) cnt++;
		if (a[i] == a[i - 1]) ans++;
	}
//	cnt++;
//	pl = min(k * 2, cnt - 1);
	cout << min(ans + k * 2, n - 1);
    return 0;
}


Measured memory_bytes: 512