akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int N;
  cin>>N;
  int route;
  route = floor(sqrt(2 * N));

  if(route * (route + 1) != 2 * N) {
    cout << "No" << endl;
    return 0;
  } else {
    cout << "Yes" << endl;
  }
  int n = route + 1;
  cout << n << endl;

  vector<int> v[n + 1];

  int cnt = 1;
  for(int i = 1; i <= n; i++)
  {
    for(int j = i + 1; j <= n; j++)
    {
      v[i].push_back(cnt);
      v[j].push_back(cnt);
      cnt++;
    }
  }
  
  for(int i = 1; i <= n; i++)
  {
    cout << n - 1 << " ";
    for(int j = 0; j < n - 1; j++)
    {
      cout << v[i][j] << " ";
    }
    cout << endl;
  }
  



  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2==0&&a%3!=0&&a%5!=0){
            cout<<"DENIED";
            return 0;
        }
    }
    cout<<"APPROVED";
}


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF 1e18
#define MOD 1e9 + 7

typedef long long ll;
typedef pair<ll, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n;
    P a[112345];

    a[0] = {0, 0};

    cin >> n;
    REP(i, n)
    {
        cin >> a[i + 1].first;
        a[i + 1].second = i + 1;
    }

    sort(a, a + n + 1);

    ll res[112345];
    fill(res, res + n + 1, 0);

    int i = n;

    int mi = a[i].second;

    while (i > 0)
    {
        mi = min(mi, a[i].second);
        while (a[i].first == a[i - 1].first)
        {
            i--;
            mi = min(mi, a[i].second);
        }

        res[mi] += (n - i + 1) * (a[i].first - a[i - 1].first);

        i--;
    }

    for (int i = 1; i <= n; i++)
        cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define int long long

#define INF 1e+9
#define MAX_V 100008


signed main() {
    string s;
    
    int k;
    cin >> k;
    cin >> s;
    if(s.size() <= k){
        cout << s << endl;
        return 0;
    }

    for (int i=0; i<k; i++){
        cout << s[i];
    }
    cout << "..." << endl;
} 



Measured memory_bytes: 3592
n = int(input())
a = str(input()).split()
for i in range(0,n):
    a[i] = int(a[i])
a.sort(reverse=True)

sumn = 0
summ = 0
for i in range(0,n,2):
    sumn += a[i]     
for i in range(1,n,2):
    summ += a[i]
print(sumn-summ)


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

using namespace std;
int n,a[100001],f[100001],res;
int main()
{
    //freopen("main.inp","r",stdin);
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    for(int i=1;i<=n;++i){
        f[a[i]]++;
        if(a[i]-1>=0)f[a[i]-1]++;
        f[a[i]+1]++;
        res=max(res,f[a[i]+1]);
        res=max(res,f[a[i]]);
        if(a[i]-1>=0)res=max(res,f[a[i]-1]);
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
#define MOD3 999999937
ll power(ll a, ll b){ll res=1;a=a%MOD1;while(b>0){if(b&1){res=(res*a)%MOD1;}a=(a*a)%MOD1;b>>=1;}return res;}
ll fermat_inv(ll y){return power(y,MOD1-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo INT_MAX

void solve(){
   ll n;
   cin>>n;
   string a[n];
   fo(i,n)cin>>a[i];
   map<string,ll> m;
   fo(i,n)m[a[i]]++;
   string s = "AC";
   cout<<s<<" x "<<m[s]<<"\n";
   s = "WA";
    cout<<s<<" x "<<m[s]<<"\n";
    s = "TLE"; 
     cout<<s<<" x "<<m[s]<<"\n";
     s = "RE";
      cout<<s<<" x "<<m[s]<<"\n";
}

int main(){
    Boost();
    #ifndef ONLINE_JUDGE 
    kill
    #endif
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}
 
 
 
 
 

Measured memory_bytes: 6752
#define N 1000
#define M -1
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int m[N][N] = {};
int d[N] = {};
int n;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)d[i] = M;
	int j;
	for (int i = 0; i < n; i++) {
		int k;
		int u;
		int v;
		cin >> u;
		cin >> k;
		for (j = 0; j < k; j++) {
			cin >> v;
			m[u][v] = 1;
		}
	}
	queue<int> q;
	q.push(1);
	d[1] = 0;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		if (d[u] != M) {
			for (int i = 1; i <= n; i++) {
				if (m[u][i]) {
					if (d[i] == M) {
						d[i] = d[u] + 1;
						q.push(i);
						//cout << "a" << endl;
					}
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3380
#include <stdio.h>

#pragma warning(disable : 4996)

int a, b, c;

int main()
{
	while (true)
	{
		scanf("%d", &a);
		scanf("%d", &b);
		scanf("%d", &c);

		if (a == 0 && b == 0 && c == 0) break;

		int ret = 0;

		for (int i = 1; i <= 2000; i++)
		{
			for (int j = 1; j <= 2000; j++)
			{
				int s1 = i * (100 + a) / 100;
				int s2 = j * (100 + a) / 100;
				int t1 = i * (100 + b) / 100;
				int t2 = j * (100 + b) / 100;

				if (s1 + s2 == c)
				{
					ret = ret > (t1 + t2) ? ret : (t1 + t2);
				}
			}
		}

		printf("%d\n", ret);
	}

	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << setprecision(4) << setiosflags(ios::fixed); // printf("%.4f", x);

    int n;
    cin >> n;
    vector<double> t(n + 1), v(n + 1);
    for (int i = 1; i <= n; ++i) cin >> t[i];
    for (int i = 1; i <= n; ++i) cin >> v[i];
    for (int i = 1; i <= n; ++i) t[i] += t[i - 1];

    int T = 2 * t[n];
    vector<double> ub(T + 1, 200);
    ub[0] = ub[T] = 0.0;
    for (int i = 0; i <= T; ++i) {
        double cur = 0.5 * i;
        for (int j = 1; j <= n; ++j) {
            if (t[j] == cur) {
                ub[i] = min(ub[i], v[j]);
                if (j + 1 <= n) ub[i] = min(ub[i], v[j + 1]);
                break;
            }
            else if (t[j - 1] < cur && cur < t[j]) {
                ub[i] = min(ub[i], v[j]);
                break;
            }
        }
    }

    for (int i = 1; i < T; ++i)
        ub[i] = min(ub[i], ub[i - 1] + 0.5);
    for (int i = T - 1; 0 < i; --i)
        ub[i] = min(ub[i], ub[i + 1] + 0.5);

    double len = 0.0;
    for (int i = 1; i <= T; ++i) {
        if (ub[i - 1] == ub[i]) len += 0.5 * ub[i];
        else if (ub[i - 1] < ub[i]) len += 0.5 * ub[i - 1] + 0.125;
        else len += 0.5 * ub[i] + 0.125;
    }

    cout << len << endl;

    return 0;
}


Measured memory_bytes: 640
#include <cstdio>

main(){
	while(1){
		int h[5] = {0}, t[4] = {0}, w = 0;
		for(;w<5;w++){
			scanf("%d", h+w);t[h[w]]++;
			if(!*h)break;
		}
		if(!*h)break;

		if(t[1] && t[2] && t[3])
			w = -1;
		else if(t[1] && t[2])
			w = 1;
		else if(t[2] && t[3])
			w = 2;
		else if(t[1] && t[3])
			w = 3;
		else
			w = -1;
		for(int i=0;i<5;i++){
			if(w < 0)
				puts("3");
			else if(h[i] - w)
				puts("2");
			else
				puts("1");
		}
	}
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 10 ** 9
for i in range(a[0], a[-1] + 1):
    tc = 0
    for j in a:
        tc += (j - i) ** 2
    c = min(c, tc)
print(c)


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

int main(){
	int temp, n, l, i, kecil=1000, jumlah=0, simpen;
	cin>>n>>l; 
	for(i=0;i<n;i++){
		jumlah+=l+i;
		temp=l+i;
		if(temp<0){
			temp=-temp;
		}
		if(temp<kecil){
			kecil=temp;
			simpen=l+i;
		}
	}
	cout<<jumlah-simpen<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int s,w;
  cin >> s >> w;
  cout << (w>=s ? "unsafe" : "safe") << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long n, d, x, y, ans = 0;
    cin >> n >> d;
    for(int i = 0; i < n; i++)
    {
        cin >> x >> y;
        if(x * x + y * y <= d * d)
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3552
#include<stdio.h>
#include<algorithm>
using namespace std;
char A[110000];
char B[110000];
char C[110000];
char ret[110000];
int c[5];
int d[3];
int e[3];
int chk(){
	for(int i=0;i<3;i++)e[i]=d[i];
	int rem=c[1];
	int tmp=min(rem,e[2]);
	rem-=tmp;e[2]-=tmp;
	e[0]-=rem;e[1]-=rem;
	if(e[0]<0||e[1]<0)return 0;
	rem=c[2];
	tmp=min(rem,e[1]);
	rem-=tmp;e[1]-=tmp;
	e[0]-=rem;e[2]-=rem;
	if(e[0]<0||e[2]<0)return 0;
	rem=c[3];
	tmp=min(rem,e[0]);
	rem-=tmp;e[0]-=tmp;
	e[2]-=rem;e[1]-=rem;
	if(e[2]<0||e[1]<0)return 0;
	int mv=max(e[0],max(e[1],e[2]));
	int sum=e[0]+e[1]+e[2];
	int can=min(sum-mv,sum/2);
	if(can<c[4])return 0;
	return 1;
}
char ko[5];
int ty[110000];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		scanf("%s%s%s",A,B,C);
		for(int i=0;i<5;i++)c[i]=0;
		for(int i=0;i<a;i++){
			if(A[i]==B[i]&&B[i]==C[i])ty[i]=0;
			else if(A[i]==B[i])ty[i]=1;
			else if(A[i]==C[i])ty[i]=2;
			else if(C[i]==B[i])ty[i]=3;
			else ty[i]=4;
			c[ty[i]]++;
		}
	//	for(int i=0;i<5;i++)printf("%d ",c[i]);
		for(int i=0;i<3;i++)d[i]=b;
		if(!chk()){
			printf("-1\n");continue;
		}
		ret[a]=0;
		for(int i=0;i<a;i++){
			c[ty[i]]--;
			ko[0]='A';ko[1]=A[i];ko[2]=B[i];ko[3]=C[i];
			std::sort(ko,ko+4);
			for(int j=0;j<4;j++){
				if(A[i]!=ko[j])d[0]--;
				if(B[i]!=ko[j])d[1]--;
				if(C[i]!=ko[j])d[2]--;
				if(chk()){ret[i]=ko[j];break;}
				if(A[i]!=ko[j])d[0]++;
				if(B[i]!=ko[j])d[1]++;
				if(C[i]!=ko[j])d[2]++;
			}
		}
		printf("%s\n",ret);
	}
}

Measured memory_bytes: 1812
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define rep(i,l,r)  for(int i=l;i<=r;i++)
#define pre(i,r,l)  for(int i=r;i>=l;i--)
#define pii pair<int,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int maxn = 1000005;
inline int read(){
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
int main() {
   char c; cin >> c;
   if(c >= 'A' && c <= 'Z') cout <<'A' << endl;
   else cout << 'a' << endl;
}


Measured memory_bytes: 3600
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
    int n,i;
    cin>>n;
    bool w=0;
    f(i,0,n+1)
    {
    	ld z=1.08*i;
    	if(int(z)==n)
    	{
    		w=1;
    		cout<<i<<'\n';
    		break;
    	}
    }
    if(!w)
    	cout<<":(";

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define REPS(i, n) for (int i = 1; i <= (n); i++)
#define RREPS(i, n) for (int i = (n); i > 0; i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((abs(a - c) <= d) || (abs(a - b) <= d && abs(b - c) <= d)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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; }

template <typename T> T mod_pow(T n, T r, T m)
{
	T ret = 1;
	T tmp = n;
	
	while(r != 0) {
		if(r % 2) {
			ret *= tmp;
		}
		tmp *= tmp;
		tmp %= m;
		ret %= m;
		r /= 2;
	}
	return ret;
}


int main()
{
    int N;
    cin >> N;

    vector<int> A(N);
    rep(i,N) cin >> A[i];

    multiset<int> key;
    set<int> roop_key;
    rep(i,N)
    {
        key.insert(A[i]);
        roop_key.insert(A[i]);
    }

    bool flag=true;
    for( set<int>::iterator it = roop_key.begin(); it != roop_key.end(); it++ )
    {
        if( key.count( *it ) != 2 )
        {
            if(flag && *it==0) flag=false;
            else
            {
                cout << 0 << endl;
                return 0;
            }
        }

        if( N%2==0 && (*it+2)%2==0 )
        {
            cout << 0 << endl;
            return 0;
        }
        else if( N%2!=0 && (*it+2)%2!=0 )
        {
            cout << 0 << endl;
            return 0;
        }
    }

    if( flag && N%2==0 ) cout << mod_pow( (ll)2, (ll)N/2, MOD ) << endl;
    else if( !flag && N%2!= 0 ) cout << mod_pow( (ll)2, (ll)(N-1)/2, MOD ) << endl;

}


Measured memory_bytes: 8320
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int w,n,a,b,x[30],i;
	cin>>w>>n;
	for(i=1;i<=w;i++){
		x[i]=i;
	}
	for(i=1;i<=n;i++){
		scanf("%d,%d",&a,&b);
		swap(x[a],x[b]);
	}
	for(i=1;i<=w;i++){
		cout<<x[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3152
a=input()
num=1
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        num+=1
if num==len(a):
    print("No")
else:
    print("Yes")

# if a[0]==a[1] and a[1]==a[2]:
#     print("No")
# else:
#     print("Yes")

Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <memory.h>


int main(void)
{	
	int n,i,count=0,change=0,conc=0;
	int a[100];
	int b[9]={0};
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0;i<n;i++){
		if(a[i]>=1 && a[i]<=399){
			b[0]++;
		} else if(a[i]>=400 && a[i]<=799){
			b[1]++;
		} else if(a[i]>=800 && a[i]<=1199){
			b[2]++;
		} else if(a[i]>=1200 && a[i]<=1599){
			b[3]++;
		} else if(a[i]>=1600 && a[i]<=1999){
			b[4]++;
		} else if(a[i]>=2000 && a[i]<=2399){
			b[5]++;
		} else if(a[i]>=2400 && a[i]<=2799){
			b[6]++;
		} else if(a[i]>=2800 && a[i]<=3199){
			b[7]++;
		} else {
			b[8]++;
		}
	}
	
	if(b[8]==0){
		for(i=0;i<9;i++){
			if(b[i]!=0){
				count++;
			}
		}
		printf("%d %d\n",count,count);
	} else if(b[8]==n){
			printf("1 %d\n",n);
		} else {
		for(i=0;i<8;i++){
			if(b[i]!=0){
				count++;
			}
		}
		change=b[8];
		
		printf("%d %d\n",count,count+change);
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n;
    cin >> n;
    vector<int> a(n+5, 0);

    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j += i) {
            a[j]++;
        }
    }
    int sum = 0;
    for(int i = 1; i <= n; i++) if(a[i] == 8 and i%2) sum++;

    
    cout << sum << endl;

  
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  int X , K, D;
  cin >> X >> K >> D;
  if(X < 0) X = X * -1;
  int cnt = min(K , X / D);
  K -= cnt;
  X -= (cnt * D);
  if(K % 2 == 0) {
    cout << X << '\n';
  } else{
    cout << D - X << '\n';
  }
}

Measured memory_bytes: 3652
a=int(input())
moji=input()
r=[]
g=[]
b=[]
for i in range(a):
    if moji[i]=="R":
        r.append(i)
    elif moji[i]=="G":
        g.append(i)
    else:
        b.append(i)
res=len(r)*len(g)*len(b)
if len(r)==0 or len(g)==0 or len(b)==0:
    print(0)
else:
    min_len={0:r,1:g,2:b}
    if len(min_len[0])>len(min_len[1]):
        tmp=min_len[0]
        min_len[0]=min_len[1]
        min_len[1]=tmp
    if len(min_len[1])>len(min_len[2]):
        tmp=min_len[1]
        min_len[1]=min_len[2]
        min_len[2]=tmp
    if len(min_len[0])>len(min_len[1]):
        tmp=min_len[0]
        min_len[0]=min_len[1]
        min_len[1]=tmp
    a1=[]
    for i in range(3):
        a1.append(min_len[i])
    A=set(a1[0])
    B=set(a1[1])
    C=set(a1[2])
    for i in A:
        for j in B:
            if -abs(i-j)+min(i,j) in C:
                res-=1
            if abs(i-j)+max(i,j) in C:
                res-=1
            if abs(i-j)%2==0 and  int(abs(i-j)/2)+min(i,j) in C:
                res-=1
    print(res)


Measured memory_bytes: 9492
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define ls(_o) (_o<<1)
#define rs(_o) ((_o<<1)|1)
#define abs(_o) ((_o<0)?-(_o):_o)
using namespace std;
namespace ywy{
	inline int get(){
		int n=0;char c;while((c=getchar())||23333){
			if(c>='0'&&c<='9')break;if(c=='-')goto s;
		}n=c-'0';while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10+c-'0';else return(n);
		}s:while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10-c+'0';else return(n);
		}
	}ll min1[1000001],min2[1000001],adds[1000001];int x[200001];
	inline void down(int tree){
		if(!adds[tree])return;ll c=adds[tree];adds[tree]=0;adds[ls(tree)]+=c;adds[rs(tree)]+=c;
		min1[ls(tree)]+=c;min2[ls(tree)]+=c;min1[rs(tree)]+=c;min2[rs(tree)]+=c;
	}
	inline void up(int tree){
		min1[tree]=min(min1[ls(tree)],min1[rs(tree)]);min2[tree]=min(min2[ls(tree)],min2[rs(tree)]);
	}
	void setpt(int l,int r,int tree,int pt,ll num){
		if(l==r){
			min1[tree]=min(min1[tree],num-l);min2[tree]=min(min2[tree],num+l);return;
		}int mid=(l+r)>>1;down(tree);if(pt<=mid)setpt(l,mid,ls(tree),pt,num);else setpt(mid+1,r,rs(tree),pt,num);up(tree);
	}
	ll query1(int rl,int rr,int l,int r,int tree){
		if(rl==l&&rr==r)return(min1[tree]);int mid=(l+r)>>1;down(tree);
		if(rl>mid)return(query1(rl,rr,mid+1,r,rs(tree)));if(rr<=mid)return(query1(rl,rr,l,mid,ls(tree)));
		return(min(query1(rl,mid,l,mid,ls(tree)),query1(mid+1,rr,mid+1,r,rs(tree))));
	}
	ll query2(int rl,int rr,int l,int r,int tree){
		if(rl==l&&rr==r)return(min2[tree]);int mid=(l+r)>>1;down(tree);
		if(rl>mid)return(query2(rl,rr,mid+1,r,rs(tree)));if(rr<=mid)return(query2(rl,rr,l,mid,ls(tree)));
		return(min(query2(rl,mid,l,mid,ls(tree)),query2(mid+1,rr,mid+1,r,rs(tree))));
	}
	ll query(int l,int r,int tree){
		if(l==r)return(min1[tree]+l);int mid=(l+r)>>1;down(tree);return(min(query(l,mid,ls(tree)),query(mid+1,r,rs(tree))));
	}
	void ywymain(){
		int n=get(),q=get(),a=get(),b=get();x[0]=a;memset(min1,0x3f,sizeof(min1));
		memset(min2,0x3f,sizeof(min2));setpt(1,n,1,b,0);for(register int i=1;i<=q;i++){
			x[i]=get();ll cjr=min(query1(1,x[i],1,n,1)+x[i],query2(x[i],n,1,n,1)-x[i]);
			adds[1]+=abs(x[i]-x[i-1]);min1[1]+=abs(x[i]-x[i-1]);min2[1]+=abs(x[i]-x[i-1]);
			setpt(1,n,1,x[i-1],cjr);
		}cout<<query(1,n,1)<<endl;
	}
}
int main(){
	ywy::ywymain();return(0);
}

Measured memory_bytes: 22400
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N;
    cin >> N;
    int count = 0;
    rep(i, N) {
        int D1, D2;
        cin >> D1 >> D2;
        if (count == 3) {
            break;
        }
        if (D1 == D2) {
            count++;
        }
        else {
            count = 0;
        }
    }
    if (count == 3) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const int N = 1e5 + 5;
vi g[N];
void solve(){
   int n,m;
   cin >> n >> m;
   int ans = n;
   int a[n+1];
   f(i,1,n+1)  cin >> a[i];

   f(i,0,m) {
      int u,v;
      cin >> u >> v;
      g[u].pb(v);
      g[v].pb(u);
   }

   for(int i=1 ; i<=n ; i++) {
      int ok = 0;
      for(auto v : g[i] ) if(a[i] <= a[v]) ok = 1;
      ans -= ok;
   }
   cout << ans;
}

int32_t main(){
   fast;
   int t = 1;
//   cin >> t;
   while(t--)  solve();   
}

Measured memory_bytes: 10276
#include <bits/stdc++.h>
using namespace std;
int h, n;
int dp[1010][10100];
int main() {
    cin >> h >> n;
    vector<int> a(n, 0);
    vector<int> b(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i) >> b.at(i);
    }

    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= h; ++j) {
            dp[i][j] = 1e9+7;
        }
    }

    for(int i = 0; i <= n; ++i) dp[i][0] = 0;

    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= h; ++j) {
            if(a[i-1] <= j) {
                dp[i][j] = min(dp[i-1][j], dp[i][j-a[i-1]]+b[i-1]);
            }else {
                dp[i][j] = min(dp[i-1][j], b[i-1]);
            }
        }
    }

    cout << dp[n][h] << endl;
}

Measured memory_bytes: 39808
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int A, B;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> A >> B;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  int ans = -1;
  for (int i = 1; i <= 2000; i++) {
    int a = i * 0.08;
    int b = i * 0.1;
    if (a == A && b == B) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s=int(input())
l=[s]
a=s
for i in range(1000000):
      if a%2==0:
            a=int(a/2)
            l.append(a)
      else:
            a=3*a+1
            l.append(a)
      if l.count(a)==2:
            print(len(l))
            break


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
   long long int n;
   cin>>n;

   for(int i=1;i<=n;i++){
         if(n==1){
         cout<<"1"<<endl;
         return 0;
         }
      if(i*i>n){
          cout<<(i-1)*(i-1)<<endl;
          return 0;
      }
   }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	unsigned long long int n;
	cin >> n;
	unsigned long long int result = 0;
	
	unsigned long long int cnt[31] = {};

	for(unsigned long long int i=0;i<n;++i){
		char c;
		cin >> c;
		cnt[c - 'a']++;
	}
	
	for(int i=0;i<30;++i){
		unsigned long long int ncnt = cnt[i];
		for(int j=i+1;j<30;++j){
			ncnt = ncnt * (cnt[j] + 1) % (1000000000+ 7);
		}
		result += (ncnt % (1000000000+ 7));
		
	
	}
	cout << (result % (1000000000+ 7)) << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n; i++){
            p[i] = sc.nextInt();
        }
        
        int count = 0;
        for(int i = 1; i < n-1; i++){
            if((p[i-1] < p[i]) && (p[i] < p[i+1])){
                count++;
            }else if((p[i-1] > p[i]) && (p[i] > p[i+1])){
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 21716
/*
  AOJ 0278
  Title: 
  @kankichi573
*/
#include <stdio.h>
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))

int N;
int pool_p,bath_p;
int pool_n,bath_n;

int solve()
{
        int ret1,ret2;

        ret1=pool_p*pool_n+bath_p*bath_n;
        ret2=(pool_p*max(2,pool_n)+bath_p*max(5,bath_n))*4/5;
        return(min(ret1,ret2));
}

main()
{
        int i;

        scanf("%d",&N);
        for(i=0;i<N;i++)
        {
                scanf("%d %d %d %d",&bath_p,&pool_p,&bath_n,&pool_n);
                printf("%d\n",solve());
        }

  return(0);
}

Measured memory_bytes: 600
import math
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
    x = math.ceil(math.log2(k/i))
    if x < 0:
        x = 0
    ans += (1/n) * (1/2)**x
print("{:.15f}".format(ans))


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

constexpr int N = 1e5;

int n;

int a[N];
char op[N];

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    std::cin >> n;
    std::cin >> a[0];
    int64_t sum = a[0];
    for (int i = 1; i < n; ++i) {
        std::cin >> op[i] >> a[i];
        sum += op[i] == '-' ? -a[i] : a[i];
    }
    
    int64_t ans = sum;
    int64_t cur = 0;
    
    for (int i = n - 1; i >= 1; --i) {
        cur += a[i];
        if (op[i] == '-') {
            sum += 2 * a[i];
            ans = std::max(ans, sum - 2 * cur);
            cur = 0;
        }
    }
    
    std::cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 4128
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
  ll n, x, count = 0;
  cin >> n >> x;
  vector<ll> c(n);
  scan(c);

  REP(i, 1, n) {
    ll left = c[i - 1] + c[i];

    if (left > x) {
      ll diff = ((left - x) <= c[i]) ? left - x : c[i];
      count += diff;
      c[i] -= diff;
    }
  }

  for (int i = n - 2; i >= 0; i--) {
    ll right = c[i] + c[i + 1];

    if (right > x) {
      ll diff = ((right - x) <= c[i]) ? right - x : c[i];
      count += diff;
      c[i] -= diff;
    }
  }
  cout << count << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdio.h>
#define Max 100005

typedef struct p{
  char N[100];
  int t;
}P;

P Q[Max];
int head,tail,n;

void enqueue(P x);

P dequeue();

int min(int a,int b){return a < b ? a : b;}

int main(){
  int sum = 0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);

  for(i=1;i<=n;i++){
    scanf("%s",Q[i].N);
    scanf("%d",&Q[i].t);
  }
  head = 1; tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    sum += c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.N,sum);
    }
  }
  return 0 ;
}
 

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1)% Max;
}
P dequeue(){
  P x = Q[head];
  head = (head + 1)% Max;
  return x;
}

Measured memory_bytes: 10756
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.PrintWriter;
import java.util.Arrays;;
import java.util.StringTokenizer;

/**
 * The Java template file for AtCoder online judge.
 */
public class Main {

  private static FastScanner scanner;
  private static PrintWriter printer;

  public static void solve() {
    int n = scanner.nextInt();
    int[][] activities = new int[n][3];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) {
        activities[i][j] = scanner.nextInt();
      }
    }
    for (int i = 1; i < n; i++) {
      activities[i][0] += Math.max(activities[i - 1][1], activities[i - 1][2]);
      activities[i][1] += Math.max(activities[i - 1][0], activities[i - 1][2]);
      activities[i][2] += Math.max(activities[i - 1][0], activities[i - 1][1]);
    }
    int result = 0;
    for (int i = 0; i < 3; i++) {
      result = Math.max(result, activities[n - 1][i]);
    }
    printer.println(result);
  }

  public static void main(String[] args) {
    scanner = new FastScanner();
    printer = new PrintWriter(System.out);
    solve();
    printer.flush();
  }

  private static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(Reader in) {
      br = new BufferedReader(in);
    }

    public FastScanner() {
      this(new InputStreamReader(System.in));
    }

    public String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    public int[] readIntArray(int size) {
      int[] ret = new int[size];
      for (int i = 0; i < size; i++) {
        ret[i] = nextInt();
      }
      return ret;
    }
  }
}


Measured memory_bytes: 46572
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int A,B;
    cin >> A >> B;
    cout << max({A+B, A-B, A*B}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int n;
ll ans;
ll a[3005][3005];

int main(void) {
    cin >> n;
    rep(i, 0, n) rep(j, 0, n) scanf("%lld", &a[i][j]);
    
    rep(i, 0, n) rep(j, i+1, n) {
      bool path = true;
      rep(k, 0, n) {
        if (i==k || j==k) continue;
        if (a[i][k]+a[k][j]<a[i][j]) {
          puts("-1");
          return 0;
        }
        if (a[i][k]+a[k][j]==a[i][j]) path = false;
        
      }
      if (path) ans += a[i][j];
    
    }
  
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 6912
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            Console.WriteLine(6 - a - b);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

bool isPrime(int num){	
	if (num < 2) return false;
	if (num == 2 ) return true;
	for (int i = 2; i <= sqrt(num) + 1; i++){
		if (num % i == 0) return false;
	}
	return true;
}
int main(){
	while(1){
		int a,d,n; cin >> a >> d >> n;
		int cnt = 0;
		int ans;
		if (a + d + n == 0) break;
		for (int i = a;;i += d){
			if (isPrime(i)){
				cnt++;
			}
			if (cnt == n){
				ans = i;
				break;
			}
		}
		cout << ans << endl;
	}
return 0;
}

Measured memory_bytes: 2980
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int n; cin >> n;
  int tmp;
  REP(i,n){
    cin >> tmp; 
    if(tmp %2 == 0){
      if(tmp %3 != 0&&tmp %5 != 0){
	cout << "DENIED" << endl;
	return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    string s;
    cin >> s;
    
    int a=0;
    for (int i=0;i<=s.length()-1;i++)
    {
        a=a+int(s[i])-48;
    }

    if (a%9==0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    ll m,n;
    if(a%d==0) m=a/d;
    else m=a/d+1; //打死a的次数 
    
     n=(c+b-1)/b;  // m==n
    if(m>=n) 
    {
    	cout<<"Yes";
	}
    else
      cout<<"No";

return 0;
}


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

int main() {
	// your code goes here
int x,a,b,c,total=0;
cin>>a;
cin>>b;
cin>>c;
cin>>x;
int a1=(x/500)+1,b1=(x/100)+1,c1=(x/50)+1;
if(a1>a)
a1=a;
if(b1>b)
b1=b;
if(c1>c)
c1=c;
for(int i=0;i<=a1;i++)
{
	for(int j=0;j<=b1;j++)
	{
		for(int k=0;k<=c1;k++)
		{
			if(i+j+k>0)
			{
				if(x==500*i+100*j+50*k)
				total++;
			}
		}
	}
}
cout<<total;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>

using namespace std;


int main(){

    string s;
    cin >> s;

    long long len = s.size();
    long long cnt = 0, ans = 0;
    
    for(int i = 0; i < len; i++){
        if(s[i] == 'A') cnt++;
        else if(s[i] == 'B' && s[i+1] == 'C'){
            ans += cnt;
            i++;
        }
        else cnt = 0;
    }

    cout << ans << endl;

}






Measured memory_bytes: 832
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

bool f[1010101];

int main(){
	int n; cin >> n;
	vl v(n); rep(i,n) cin >> v[i];
	rep(i,n){
		f[v[i]] = true;
		ll t = v[i];
		REP(j,i+1,min(n,i+6)){
			t = t*10 + v[j];
			f[t] = true;
		}
	}
	rep(i,1000000){
		if(!f[i]){
			cout << i << endl;
			return 0;
		}
	}
}


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

#define MAX 100002

int n;
vector<int> v;
#define MOD 998244353
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	long long int ans=1;
	for(int i=0;i<v.size();i++){
		ans*=__gcd(v[i],i);
		ans%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 892
n = int(input())
h = [int(c) for c in input().split(' ')]
maxlen = 0
current = 0
for i in range(len(h)-1):
    if h[i+1] <= h[i]:
        current += 1
        if current >= maxlen:
            maxlen = current
    else:
        current = 0
print(maxlen)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  int k;
  cin >> k;
  bool flag = false;

  rep(i,k) {
    if(g <= r) {
      g = g * 2;
      continue;
    }
    if(b <= g) {
      b = b*2;
      continue;
    }
  }
  if(b > g and g > r) {
    flag = true;
  }

  Yes(flag);

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
	
using namespace std;
void cha(int n) {
	int x = 5, y = n;
	while (n / 10 > 0) {
		x--;
		n /= 10;
	}
	for (int i = 0;i < x;i++) {
		cout << 0;
	}
	cout << y;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<pair<int, int>>> da(n);
	vector<int> pr(m), num(m);
	for (int i = 0;i < m;i++) {
		int x;
		cin >> pr[i] >> x;
		pair<int, int>  g;
		g.first = x;
		g.second = i;
		da[pr[i]-1].push_back(g);
	}
	for (int i = 0;i < n;i++) {
		if (da[i].size() > 0) {
			sort(da[i].begin(), da[i].end());
			for (int j = 0;j < da[i].size();j++) {
				num[da[i][j].second] = j + 1;
			}
		}
	}
	for (int i = 0;i < m;i++) {
		cha(pr[i]);
		cha(num[i]);
		cout << endl;
	}
}

Measured memory_bytes: 7808
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

void Solve()
{
	int k,a,b;
	cin>>k>>a>>b;
	
	f(i,a,b)
	{
		if(i%k ==0)
		{
			cout<<"OK";
			return;
				}		
}
		cout<<"NG";
}


signed main() 
{
	speed		
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 3640