akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<cmath>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forl(i,a,b) for (ll i = a; i < b; i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> pi;
int main() {
    ll n,m,sum=0;
    cin>>n>>m;
    forl(i,0,m)
    {
        ll x;
        cin>>x;
        sum+=x;
    }
    if (sum>n)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<(n-sum)<<endl;
    }

	return 0;
}


Measured memory_bytes: 3636
import numpy as np 
from numba import njit
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=np.array(a,np.int64)

@njit(cache=True)
def imo(a):
    imos=np.zeros(n+1,np.int64)
    for i in range(n):
        imos[max(0,i-a[i])]+=1
        imos[min(n,i+a[i]+1)]-=1
    
    immo=np.zeros(n+1,np.int64)
    immo=np.cumsum(imos)
    return immo[:n]


for _ in range(min(k,41)):
    a=imo(a)
    
print(*a)


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

using namespace std;
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef std::vector<bool> vb;
typedef std::vector<std::vector<bool>> vvb;
#define INF 1999999999
#define MODA 1000000007
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define rep1(i,n) for (long long i = 1; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define errvn1(x) cerr << #x <<" "<< x << endl;
#define errvn2(x, y) cerr << #x <<" "<< x <<" "<< #y <<" "<< y << endl;
#define errvn3(x, y, z) cerr << #x <<":"<< x <<" "<< #y <<":"<< y <<" "<< #z <<":"<< z << endl;
#define errvn4(x, y, z, a) cerr << #x <<":"<< x <<" "<< #y <<":"<< y <<" "<< #z <<":"<< z <<" "<< #a <<":"<< a << endl;
#define errop2(x, y) cerr << x <<" "<< y << endl;
#define errop3(x, y, z) cerr << x <<" "<< y <<" "<< z << endl;
#define errop4(x, y, z, a) cerr << x <<" "<< y <<" "<< z <<" "<< a << endl;


int main() {
  ll K;
  cin >> K;

  string acl;
  rep(i, K) {
    acl += "ACL";
  }
  cout << acl << endl;                                                                                                                   
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string s;
    cin >> s;
    int res=700;
    rep(i, s.size()) {
      if (s[i] == 'o') res += 100;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for i in range(M)]
for i in range(M):
  PY[i].append(i)

PY1 = sorted(PY)
#print(PY)

for i in range(M):
  X = str(PY1[i][0])#県の番号
  if i >= 1:#市の番号
    #print(PY)
    if PY1[i][0] == PY1[i-1][0]:
      Y = int(Y) + 1
    else:
      Y = 1
  else:
    Y = 1
  while len(str(X)) <= 5:#6桁にするための処理
    X = "0" + X
  while len(str(Y)) <= 5:
    Y = "0" + str(Y)
  PY1[i][1] = str(X) + str(Y) #文字列の結合
#print(PY)
PY2 = sorted(PY1, key = lambda x:x[2])

for i in range(M):
  print(PY2[i][1])
  


Measured memory_bytes: 40436
#include<iostream>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
using namespace std;

// using ll = long long;
// using P = pair<int, int>;

int main() {
    int N;
    int T[110000];
    int X[110000];
    int Y[110000];

    cin >> N;
    rep(i, N) {
      cin >> T[i] >> X[i] >> Y[i];
    }
    
    // 目的地の数だけループ
    bool can = true;
    rep(i, N) {
        int dt; // 一つ前の目的地からの相対時間
        int dw; // 一つ前の目的地からの相対道のり
        // 相対時間・相対道のりを求める
        if (i == 0) {
            dt = T[i];
            dw = abs(X[i] + Y[i]);
        } else {
            dt = T[i] - T[i-1];
            dw = abs(X[i] - X[i-1]) + abs(Y[i] - Y[i-1]);
        }
        // 相対道のりが相対時間より大きければ当然到達できない
        if (dt < dw) {
            can = false;
            break;
        }
        // あとは偶奇が一致すれば到達できる
        if (dt % 2 != dw % 2) {
            can = false;
        }
    }

    if (can) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll a, b, c;
	cin >>a >>b >>c;
	ll d=a*b*4;
	ll e=c-a-b;
	if (0>=e) {
		cout <<"No" <<endl;
		return 0;
	}
	e *=e;
	if (d<e)
		cout <<"Yes" <<endl;
	else
		cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >>s;
    int n=s.length();
    bool found=false;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]==s[j]){
                found=true;
            }
        }
    }
    cout <<(found?"no":"yes")<<endl;
    return 0;
    
}


Measured memory_bytes: 256
n = input()
s = raw_input()
cnt = 0
for i in range(n):
    judge = False
    p = raw_input()
    for k in range(len(p)):
        if judge: break
        for j in range(1, len(p)):
            if judge: break
            for l in range(len(s)):
                if k+l*j < len(p) and p[k+l*j] == s[l]:
                    if l+1 >= len(s): judge = True
                    continue
                break
    if judge == True: cnt += 1
print cnt

Measured memory_bytes: 6468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] sArray = S.toCharArray();
		String result = "No";
		if ((sArray[0] == sArray[1] && sArray[2] == sArray[3] && sArray[0] != sArray[2])
				|| (sArray[0] == sArray[2] && sArray[1] == sArray[3] && sArray[0] != sArray[1])
				|| (sArray[0] == sArray[3] && sArray[1] == sArray[2] && sArray[0] != sArray[1])) {
			result = "Yes";
		}

		System.out.println(result);
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <set>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')

    #define I_int ll
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
        return x * f ;
    }
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int

}
using namespace io ;

using namespace std ;

#define N 100010

ll n = read(), K = read();
ll a[N], cnt[2];

bool cmp(int a, int b) {
	return a > b;
}

int main() {
	for(int i = 1; i <= n; ++i) a[i] = read();
	ll ans = 0;
	for(ll k = 42; k >= 0; --k) {
		cnt[0] = cnt[1] = 0; 
		for(int i = 1; i <= n; ++i) {
			cnt[(a[i]>>k)&1ll]++;
		}
		if(cnt[0] > cnt[1] && ans + (1ll << k) <= K) ans += (1ll << k);
	}
	ll sum = 0;
	for(int i = 1; i <= n; ++i) {
		sum += ans ^ a[i];
	}
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*SS=SZB,*TT=SZB;
    inline char gc(){   if (SS==TT){  TT=(SS=SZB)+fread(SZB,1,GYN,stdin); if (SS==TT) return '\n';  }   return *SS++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace SHENZHEBEI;
const int N=500105,mod=1e9+7;
ll q[N],sum[N],n,k,top,ans;
ll ppow(ll x,ll k){ll ans=1;for(;k;k>>=1,Mul(x,x))if (k&1)Mul(ans,x);return ans;}
int main(){
	n=read(),k=read();
	for(ll i=1;i*i<=n;i++)if (!(n%i)){
		q[++top]=i;
		if (n!=i*i)q[++top]=n/i;
	}sort(q+1,q+top+1);
	For(i,1,top)sum[i]=ppow(k,(q[i]+1)>>1);
	For(i,1,top){
		rep(j,1,i)if (!(q[i]%q[j]))Add(sum[i],-sum[j]+mod);
		Add(ans,sum[i]*((q[i]&1)?q[i]:(q[i]>>1)));
	}Add(ans,mod);
	writeln(ans);
}
/*
11221122
12211221
22112211
21122112
*/

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <functional>
#include <string.h>

using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<ll,ll>P;
#define INF (1LL<<61)

ll a[500005];
ll b[500005];
int n;
ll d[500005];
ll D;
int q,Q;
 
int main(){
	scanf("%d %lld ", &n, &D);
	rep(i, n) {
		scanf("%lld ", &d[i]);
	}
	a[0] = D;
	rep(i, n) {
		a[i+1] = min(a[i], abs(a[i]-d[i]));
	}
	b[n] = 1;
	for (int i = n; i >= 1; i--) {
		if (b[i] <= d[i-1] / 2)
			b[i - 1] = b[i];
		else
			b[i - 1] = b[i] + d[i-1];
	}
	scanf("%d ", &Q);
	rep(i, Q) {
		scanf("%d ", &q); q;
		if (a[q - 1] >= b[q])
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 13696
# PROBLEM D
h, w, d = [int(s) for s in input().split()]
Aij = [[int(s) for s in input().split()] for _ in range(h)]
q = int(input())
lrs = [[int(s) for s in input().split()] for _ in range(q)]

a2ij = {Aij[i][j]: (i, j) for i in range(h) for j in range(w)}
#print(a2ij)

cs = [0 for _ in range(h * w)]
for a in range(d + 1, h * w + 1):
    prev_sum = cs[a - d - 1]
    i0, j0 = a2ij[a - d]
    i1, j1 = a2ij[a]
    dist = abs(i0 - i1) + abs(j0 - j1)
    cs[a - 1] = prev_sum + dist
#print(cs)
    
for l, r in lrs:
    print(cs[r-1] - cs[l-1])

Measured memory_bytes: 41460
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		int matrix[][] = new int[h][w];

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				matrix[i][j] = sc.nextInt();
			}
		}

		int num = 0;
		StringBuffer sb = new StringBuffer();
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(matrix[i][j] % 2 == 1){
					if(i == h - 1 && j == w - 1){
						break;
					}
					num++;
					if(j != w - 1){
						matrix[i][j + 1]++;
						sb.append((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2) + "\n");
					}
					else {
						matrix[i + 1][j]++;
						sb.append((i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1) + "\n");
					}
				}
			}
		}

		System.out.println(num);
		System.out.print(sb);

	}

}


Measured memory_bytes: 94784
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;


int main() {
  int N;
  int64_t a[1000010][3];
  int64_t dp[1000010][3];
  
  cin>>N;
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
     cin>>a[i][j];
    }
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k){continue;}
        chmax(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }
  cout<<max({dp[N][0],dp[N][1],dp[N][2]})<<endl;

  return 0;
  }

Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll a[5],b[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  rep(i,4)b[i]=0;
  rep(i,4)if(a[i]==1)b[0]=1;
  rep(i,4)if(a[i]==9)b[1]=1;
  rep(i,4)if(a[i]==7)b[2]=1;
  rep(i,4)if(a[i]==4)b[3]=1;
  if(b[0]==1&&b[1]==1&&b[2]==1&&b[3]==1)printf("YES");
  else cout << "NO";
}

Measured memory_bytes: 256
/*
    Created by Rahul Goel.
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*******************************************************************************/
using namespace std;
using namespace __gnu_pbds;
template < typename T >
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*******************************************************************************/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
ll mod_sum() { return 0LL; }
template < typename T, typename... Args >
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%MOD + MOD)%MOD; }
/*******************************************************************************/
ll mod_prod() { return 1LL; }
template< typename T, typename... Args >
T mod_prod(T a, Args... args) { return (a * mod_prod(args...))%MOD; }
/*******************************************************************************/
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
/*******************************************************************************/
//.-.. . -. -.- .- .. ... .-.. --- ...- .
/*
    Code begins after this.
*/

ll solve() {
    ll x, k, d;
    cin >> x >> k >> d;
    if (x == 0) {
        if (k & 1) {
            cout << d << endl;
        } else {
            cout << 0 << endl;
        }
    } else {
        if (x < 0) { 
            x = -x;
        }
        ll cross = (x + d - 1) / d;
        if (k >= cross) {
            k -= cross;
            x -= cross * d;
            if (k & 1) {
                cout << llabs(x + d) << endl;
            } else {
                cout << llabs(x) << endl;
            }
        } else {
            cout << llabs(x - k * d) << endl;
        }
    }
    return 0;
}

signed main() {
    fastio;

    ll t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
const int N=200005;
int n;
vector <int> e[N];
int depth[N],I[N],O[N],fa[N],Time=0;
int s[N];
void dfs(int x,int pre){
	fa[x]=pre,I[x]=++Time,depth[x]=depth[pre]+1;
	for (auto y : e[x])
		if (y!=pre)
			dfs(y,x);
	O[x]=Time;
}
int ST[N],top=0,d[N];
void solve(int x,int pre,int m1,int m2){
	if (x>m1)
		m2=m1,m1=x;
	else if (x>m2)
		m2=x;
	ST[d[x]=++top]=x;
	if (x>1){
		int f=depth[m1]>depth[m2]?m1:ST[d[m1]+1];
		s[I[f]]++,s[O[f]+1]--;
	}
	for (auto y : e[x])
		if (y!=pre)
			solve(y,x,m1,m2);
	top--;
}
int main(){
	n=read();
	for (int i=1;i<n;i++){
		int x=read(),y=read();
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,0);
	solve(1,0,0,0);
	for (int i=1;i<=n;i++)
		s[i]+=s[i-1];
	for (int i=2;i<=n;i++)
		printf("%d ",s[I[i]]);
	return 0;
}

Measured memory_bytes: 30464
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int M = 1e5+2;
ll N, A[M], B[M], C[M], ans;
int main() {
  scanf("%ld", &N);
  for(int i = 1; i <= N; ++i) scanf("%ld", &A[i]);
  for(int i = 1; i <= N; ++i) scanf("%ld", &B[i]);
  for(int i = 1; i <= N; ++i) scanf("%ld", &C[i]);
  sort(A, A+N+1); sort(B, B+N+1); sort(C, C+N+1);
  for(int i = 1; i <= N; ++i) {
    auto itrA = lower_bound(A, A+N+1, B[i]);
    auto itrC = upper_bound(C, C+N+1, B[i]);
    ans += (itrA-A-1)*(C+N+1-itrC);
  }
  printf("%ld\n", ans);
}

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

long long gcd(long long a, long long b){
  if(a==0) return b;
  else return gcd(b%a, a);
}

int main(){
  long long A,B,C,D;
  cin >> A >> B >> C >> D;
  cout <<B-A+1-( B/C - (A-1)/C + B/D - (A-1)/D -B/(C*D/gcd(C,D)) + (A-1)/(C*D/gcd(C,D))) <<endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Array.IO
import Control.Monad
import Control.Applicative
import Data.Maybe
import qualified Data.Map as Map
import Data.List
import Data.Maybe

type UnionFindIO = IOArray Int (Int,Int)
 
newUFIO :: Int -> IO UnionFindIO
newUFIO n = newListArray (1,n) (zip [1..n] (repeat 1))
 
findUFIO :: UnionFindIO -> Int -> IO Int
findUFIO uf x = do
  (parent,size) <- readArray uf x
  if parent == x then
    return x
    else do
    next <- findUFIO uf parent
    writeArray uf x (next,size)
    return next
 
sameUFIO :: UnionFindIO -> Int -> Int -> IO Bool
sameUFIO uf x y = do
  xx <- findUFIO uf x
  yy <- findUFIO uf y
  return $ xx == yy
 
uniteUFIO :: UnionFindIO -> Int -> Int -> IO ()
uniteUFIO uf x y = do
  xx <- findUFIO uf x
  yy <- findUFIO uf y
  (_,xs) <- readArray uf xx
  (_,ys) <- readArray uf yy

  if xx == yy then
    return ()
    else if xs < ys then do
    writeArray uf xx (yy,0)
    else if xs > ys then do
    writeArray uf yy (xx,0)
    else do
    writeArray uf yy (xx,0)
    writeArray uf xx (xx,xs+1)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
readIntBS = fst . fromJust . BS.readInt

main = do
  (n,k,l) <- listToTuple3 . map readIntBS . BS.words <$> BS.getLine :: IO (Int,Int,Int)

  uf1 <- newUFIO n
  replicateM k $ do
    (p,q) <- listToTuple2 . map readIntBS . BS.words <$> BS.getLine :: IO (Int,Int)
    uniteUFIO uf1 p q

  list1 <- forM [1..n] $ \i -> do
    findUFIO uf1 i

  
  uf2 <- newUFIO n
  replicateM l $ do
    (r,s) <- listToTuple2 . map readIntBS . BS.words <$> BS.getLine :: IO (Int,Int)
    uniteUFIO uf2 r s

  list2 <- forM [1..n] $ \i -> do
    findUFIO uf2 i

  let
    pairs = zip list1 list2
    dict = Map.fromList . map (\xs -> (head xs, length xs)) . group . sort $ pairs

  putStrLn $ unwords . map show . catMaybes $ map (\p -> Map.lookup p dict) pairs


Measured memory_bytes: 89980
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll N;
  cin >> N;
  if(N==0) {
    fin(0);
    return 0;
  }
  
  string s;
  while(N) {
    int md = abs(N % 2);
    s.push_back((char)(md + '0'));
    N = (N - md) / (-2);
  } 
  reverse(all(s));
  fin(s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)
using ll = long long;

void solve(long long N, std::vector<long long> A) {
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        for (ll j = i + 1; j < N; j++) {
            ans = max(ans, abs(A[i] - A[j]));
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3668
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());
vector<pair<ll,ll> > g[100005];

int a[100005],vis[100005];

void dfs(ll x)
{
	// debug(x);
	vis[x]=1;
	for(auto q:g[x])
	{
		if(vis[q.ff]==0 && q.ss%2==0)
			a[q.ff]=a[x];
		else if(vis[q.ff]==0)
			a[q.ff]=!(a[x]);
		// debug3(x,q.ff,q.ss);
		// debug2(a[x],a[q.ff]);
		if(vis[q.ff]==0) dfs(q.ff);
	}
}


int main()
{
	SPEED;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		memset(vis,0,sizeof(vis));
		// n=s.length();
		// ll a[n];
		rep(i,n-1)
		{
			cin>>j>>k>>m;
			if(i==0) c=j;
			g[j].pb({k,m});
			g[k].pb({j,m});
		}
		repe(i,1,n+1)
		{
			if(vis[i]==0)
			{
				a[c]=0;
				dfs(c);
			}
		}
		repe(i,1,n+1)
			cout<<a[i]<<"\n";
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;
bool compare(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    return a.second < b.second;
}
int main(){
     ll a,b,c,k;
     cin >> a >> b >> c >> k;
    c = a -b;
    if(abs(c) > 1e18){
        cout << "Unfair" << endl;
    }else if(k % 2 == 0){
        cout << c << endl;
    }else{
        cout << -c << endl;
    }
}

Measured memory_bytes: 256
MOD = 10**9+7
N = int(input())
x = list(map(int, input().split()))

def mod_pow(x, n, mod):
	res = 1
	while n > 0 : 
		if n&1 : 
			res = res * x % mod
		x = x * x % mod
		n >>= 1
	return res

ans = 0

prob = []
a = 0
for i in range(1, N):
	a += mod_pow(i, MOD-2, MOD)
	a %= MOD
	prob.append(a)
for i in range(1, N):
	ans += prob[i-1] * (x[i] - x[i-1])
	ans %= MOD

#factor = 0

#for i in range(1, N):
#	factor += mod_pow(i, MOD-2, MOD)
#	factor %= MOD
#	ans += factor * (x[i] - x[i-1])
#	ans %= MOD

for i in range(1, N):
	ans = ans * i % MOD
print(ans)

Measured memory_bytes: 14480
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    P = 0
    for i in range(1, N + 1):
        coins = 0
        k = i
        while k < K:
            coins += 1
            k *= 2
        P += pow(0.5, coins) / N
    print(P)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long const MAX=1e9+5;
int main()
{long long i,j,k,l,m,n,x,y,z,q,t,sum,d;
char c;
cin>>n;
long long a[n+1];
a[0]=0;
for(i=1;i<=n;i++)
{cin>>c;
if(c=='R')a[i]=a[i-1]+1;
else a[i]=a[i-1];}
sum=min(a[n],n-a[n]);
for(i=1;i<n;i++)
{if(a[i]==a[i-1]);
else{y=min(i-a[i],a[n]-a[i]);
if(y==i-a[i])
x=a[n]-a[i];
else x=i-a[i];
sum=min(sum,x);}}cout<<sum;
return 0;}

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

ll doublepow(ll m, ll n);

int main(){
    ll m,n; cin >> m >> n;
    ll ans = doublepow(m,n);
    cout << ans << endl;
    return 0;
}

ll doublepow(ll m, ll n){
    if(n == 0) return 1;
    ll a = doublepow(m,n/2);  
    if(n%2 == 0) return (a*a)%mod;
    else return ((a*a)%mod*m)%mod;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
string s;
map<char, int> m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s;
  FOR(i, 0, n) m[s[i]]++;
  cout << ((m['R'] > m['B']) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
var
	x, y, z : integer;
	i : integer;
    ok : boolean;
begin
	ok := false;
    i := x;
	readln(x);
    readln(y, z);
    while i <= z do
    begin
    	if (i >= y) and (i <= z) then
        	ok := true;
        i := i + x;
    end;
    if ok then
    	writeln('OK')
    else
    	writeln('NG');
end.

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n; cin >> n;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        string s; cin >> s;
        mp[s]++;
    }
    
    int i_max = 0;
    for(auto itr = mp.begin();itr != mp.end();itr++){
        i_max = max(itr->second,i_max);
        
    }
    for(auto itr = mp.begin();itr != mp.end();itr++){
        if(itr->second == i_max)cout << itr->first <<endl;
    }
}
    

Measured memory_bytes: 25216
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 2e5+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

    
int main()
{
    
     
        int n;
        scf(n);
        
        map<string,int>m;
        
        rep(i,0,n)
        {
            string a;
            cin>>a;
            
            m[a]++;
        
        }
        
        cout<<"AC x "<<m["AC"]<<"\n";
        cout<<"WA x "<<m["WA"]<<"\n";
        cout<<"TLE x "<<m["TLE"]<<"\n";
                cout<<"RE x "<<m["RE"]<<"\n";
         
    
        
}

Measured memory_bytes: 3696
#include<stdio.h>
#define N 100
#define INF 1<<21

int G[N][N],p[N],H[N],L[N];

int min(int c,int r){
  if(c<r) return c;
  else return r;
  
}


int main(){
  
  int x,i,j,l,a,b,c;
  
  scanf("%d",&x);
  
  for(i=1;i<=x;i++){
    G[i][i]=0;
  }
for(i=1;i<=x;i++){
scanf("%d%d",&H[i],&L[i]);
}

  

 p[0]=H[1];
 p[1] = L[1];

 for(i=2;i<=x;i++){
   p[i] = L[i];
 }
  
  for(i=2;i<=x;i++){
    for(j = 1;j<=x-i+1;j++){
      a=j+i-1;
      G[j][a] = INF;
      for(l = j;l<=a-1;l++){
	b = G[j][l] + G[l+1][a] + p[j-1]*p[l]*p[a];
	G[j][a] = min(G[j][a],b);
      }
    }
  }
      
  printf("%d\n",G[1][x]);


return 0;
}



Measured memory_bytes: 2104
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, d;
	while (cin>>a >> b >> d,a) {
		int x, y;
		int tmp = INF, ans = INF;
		REP(i, 100000) {
			if (a*i >= d && (a*i - d) % b == 0) {
				if (i + (a*i - d) / b < tmp) {
					x = i; y = (a*i - d) / b;
					tmp = x + y;
					ans = x*a + y*b;
				}
				else if (i + (a*i - d) / b == tmp) {
					if (2 * i*a - d < ans) {
						x = i; y = (a*i - d) / b;
						tmp = x + y;
						ans = x*a + y*b;
					}
				}
			}
			if ( (a*i + d) % b == 0) {
				if (i + (a*i + d) / b < tmp) {
					x = i; y = (a*i + d) / b;
					tmp = x + y;
					ans = x*a + y*b;
				}
				else if (i + (a*i + d) / b == tmp) {
					if (2 * i*a + d < ans) {
						x = i; y = (a*i + d) / b;
						tmp = x + y;
						ans = x*a + y*b;
					}
				}
			}
			if (d >= a*i && (d - a*i) % b == 0) {
				if (i + (d - a*i) / b < tmp) {
					x = i; y = (d-a*i )/ b;
					tmp = x + y;
					ans = x*a + y*b;
				}
				else if (i + (d - a*i) / b == tmp) {
					if (d < ans) {
						x = i; y = (d- a*i) / b;
						tmp = x + y;
						ans = x*a + y*b;
					}
				}
			}
		}
		cout << x << " " << y << endl;
	}
}

Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
    int a;
    int b;
    int sum;
    while(cin >> a >> b)
    {
        sum = a + b;
        string sum = to_string(a + b);
        cout << sum.length() << endl;
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <string>

constexpr int max_size()
{
    return static_cast<int>(1e+2);
}

void print(int* a, int n, int i) {
    if (i == n - 1) {
        std::cout << a[i] << std::endl;
        return;
    }

    std::cout << a[i] << " ";
    return print(a, n, i + 1);
}

void print(int* a, int n) {
    print(a, n, 0);
    return;
}

std::vector<int>
split(const std::string &s, const char delim) {
    std::vector<int> ret;
    std::string item;
    for (const char ch : s) {
        if (ch == delim) {
            if (!item.empty()) {
                ret.push_back(std::atoi(item.c_str()));
            }
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty()) {
        ret.push_back(std::atoi(item.c_str()));
    }
    return ret;
}

int rise(int* a, int i, int j) {
    if (j == i) {
        return 0;
    }

    const bool is_swap = (a[j - 1] > a[j]);
    if (is_swap) {
        std::swap(a[j - 1], a[j]);
    }

    return (is_swap ? 1 : 0) + rise(a, i, j - 1);
}

int bubble_sort(int* a, int n, int i) {
    if (i == n) {
        return 0;
    }
    
    return rise(a, i, n - 1) + bubble_sort(a, n, i + 1);
}

int bubble_sort(int* a, int n) {
    return bubble_sort(a, n, 0);
}

int main() {
    int n;
    std::cin >> n;
    std::cin.ignore();  //ignore \n

    constexpr int N = max_size();
    std::string buf;
    getline(std::cin, buf);

    std::vector<int> a = split(buf, ' ');
    int counter = bubble_sort(&a[0], n);
    print(&a[0], a.size());
    std::cout << counter << std::endl;

    return 0;
}

Measured memory_bytes: 3176
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n;
	int ban,tan,buy,flg,ff[4001];
	long long int sum[4001];
	while(1) {
		scanf("%d",&n);
		if(n==0) break;
		flg=0;
		for(i=0;i<4000;i++) {
			ff[i]=0;
			sum[i]=0;
		}
		for(i=0;i<n;i++) {
			scanf("%d %d %d",&ban,&tan,&buy);
			sum[ban]+=(long long)tan*buy;
			if(sum[ban]>=1000000) {
				flg=1;	
				if(ff[ban]==0) {
					ff[ban]=1;
					printf("%d\n",ban);
				}
			}
		}
		if(flg==0) printf("NA\n");
	}
	return 0;
}

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

int main(){
    double x1, y1, x2, y2, d;
    cin >> x1 >> y1 >> x2 >> y2;
    d = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    printf("%.8f\n", d);
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(50000, prime);

    vector<int> num;
    for(int i=0; i<=50000; ++i){
        if(prime[i])
            num.push_back(i);
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int ret = 0;
        for(unsigned i=0; num[i]<=n/2; ++i){
            if(prime[n-num[i]])
                ++ ret;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 968
#include<bits/stdc++.h>
using namespace std;
int get(int num) {
    int ans = 0;
    while (num) {
        ans += num % 10;
        num = num / 10;
    }
    return ans;
}
int main() {
    int n;
    cin >> n;
    int ans = INT_MAX;
    for (int i = 1; i < n; i++) {
        ans = min(ans, get(i) + get(n-i));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,r=0,l=0;
  cin>>n;
  char c[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(c[i]=='(')
      l++;
    else{
      if(l>0)
        l--;
      else
        r++;
    }
  }
  for(int i=0;i<r;i++){
    cout<<'(';
  }
  for(int i=0;i<n;i++){
    cout<<c[i];
  }
  for(int i=0;i<l;i++){
    cout<<')';
  }
}

Measured memory_bytes: 256
S = input()

T = ["A", "C", "G", "T"]
max_length = 0

for start in range(len(S)):
    for end in reversed(range(len(S) + 1)):
        checked = False
        if start > end:
            break
        else:
            sub_str = S[start:end]
            check_str = (
                sub_str.replace("A", "")
                .replace("C", "")
                .replace("G", "")
                .replace("T", "")
            )

            if len(check_str) != 0:
                checked = True
            else:
                if max_length < len(sub_str):
                    max_length = len(sub_str)

print(max_length)



Measured memory_bytes: 3064
#include <stdio.h>
#define N 36

struct trump{
  char c;
  int num;
  int order;
};

void bubble(struct trump *, int);
void select(struct trump *, int);
int judge(int, int);

struct trump card[N],card2[N] ,sub;

int main(){

  int n, i, j, fc=0, rs=1;
  char ct[N][2];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",ct[i]);
    card[i].c=ct[i][0];
    card[i].num=((int)ct[i][1])-48;
    card[i].order=i;
  }

  for(i=0;i<N;i++){
    card2[i]=card[i];
  }

  bubble(card, n);
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(card[i].num==card[j].num){
         rs=judge(card[i].order, card[j].order);
         if(rs==0) fc++;
      }
    }
  }
  
  for(i=0;i<n;i++){
    printf("%c%d",card[i].c, card[i].num);
    if(i<n-1) printf(" ");
  }
  if(fc==0) printf("\nStable\n");
  else printf("\nNot stable\n");
  
  fc=0;

  select(card2, n);
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(card[i].num==card[j].num){
         rs=judge(card2[i].order, card2[j].order);
         if(rs==0) fc++;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%c%d",card2[i].c, card2[i].num);
    if(i<n-1) printf(" ");
  }
  if(fc==0) printf("\nStable\n");
  else printf("\nNot stable\n");

  return 0;
}
void bubble(struct trump *C,int n){

  int i, j;

  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(C[j].num<C[j-1].num){
        sub=C[j];
        C[j]=C[j-1];
        C[j-1]=sub;
      }
    }
  }
}

void select(struct trump *C,int n){

 int i, j, minj;

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(C[j].num<C[minj].num)
         minj=j;
    }
    sub=C[i];
    C[i]=C[minj];
    C[minj]=sub;
  }
}

int judge(int a, int b){
  if(a<b) return 1;
   else return 0;
}
  
 

  


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

using namespace std;

typedef long long ll;

ll n,k;

int main()
{
	ll i,a,e,o,e_,o_;
	
	scanf("%lld%lld",&n,&k);
	
	e = 1, o = 0;
	
	for(i=0;i<n;i++){
		scanf("%lld",&a);
		if(a & 1){
			e_ = e + o;
			o_ = e + o;
		}
		else{
			e_ = e + e;
			o_ = o + o;
		}
		
		e = e_, o = o_;
	}
	
	if(k == 1) printf("%lld\n",o);
	else printf("%lld\n",e);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    string S;
    cin >> S;
    vi a;
    int N = S.length();
    rep(i,N) a.pb(S[N-1-i]-'0');
    a.pb(0);
    ll ans = 0;
    
    rep(i,N){
        if(a[i] >= 10){
            a[i+1]++;
        }else if(a[i] < 10-a[i]){
            ans += a[i];
        }else if(a[i] > 10-a[i]){
            ans += 10-a[i];
            a[i+1]++;
        }else{
            if(a[i+1] > 4){
                ans += 10-a[i];
                a[i+1]++;
            }else ans += a[i];
        }
    }
    ans += a[N];
    cout << ans << endl;

    
    
    
    

    return 0;
}


Measured memory_bytes: 7804