akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
using vi = vector<int>;
using vll = vector<ll>;
const ll INF = 1LL<<60;

int main(){
  int n; cin >> n;
  vector<int> a(n+1), b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll ans = 0;
  for(int i = 0; i < n; i++){
    if(a[i] < b[i]){
      ans += a[i];
      b[i] -= a[i];
      if(a[i+1] < b[i]){
        ans += a[i+1];
        a[i+1] = 0;
      }else{
        ans += b[i];
        a[i+1] -= b[i];
      }
    }else{
      ans += b[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

long long find_min(function<bool(long long)> solve, long long low, long long high) {
	long long ng = low, ok = high;
	while (ok - ng > 1) {
		long long mid = (ok + ng) / 2;
		if (solve(mid)) {
			ok = mid;
		} else {
			ng = mid;
		}
	}
	return ok;
}

int main() {
	long long n, k;
	cin >> n >> k;
	vector<long long> A(n), F(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> F[i];
	}
	sort(A.begin(), A.end());
	sort(F.begin(), F.end(), greater<long long>());
	auto g = [&](long long x) {
		long long res = 0;
		for (int i = 0; i < n; i++) {
			res += max(0ll, A[i] - x / F[i]);
		}
		return res;
	};
	function<bool(long long)> f = [&](long long x) {
		return g(x) <= k;
	};
	long long ans = find_min(f, -1, (long long)1e13);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6436
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (LL I = 0; I < (N); ++I)
#define REPP(I, A, B) for (LL I = (A); I < (B); ++I)
#define RI(X) scanf("%lld", &(X))
#define RII(X, Y) scanf("%lld%lld", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define DRI(X) LL (X); scanf("%lld", &X)
#define DRII(X, Y) LL X, Y; scanf("%lld%lld", &X, &Y)
#define DRIII(X, Y, Z) LL X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
LL A[(int)2.5e5],ans[(int)2.5e5];
int main(){
    DRI(n);
    REP(i,n)RI(A[i]);
    reverse(A,A+n);
    LL l=0,r=n-1;
    REP(i,n){
        if(i%2==0){
            ans[l++]=A[i];
        }else{
            ans[r--]=A[i];
        }
    }REP(i,n)printf("%lld%c",ans[i]," \n"[i==n-1]);
}

Measured memory_bytes: 5248
n=int(input())
x=[list(map(int, input().split())) for i in range(n)]
dp=[[0]*3 for i in range(n+1)]
for i in range(n):
    for j in range(3):
        dp[i+1][j]=max(dp[i][(j+1)%3],dp[i][(j+2)%3])+x[i][j]
print(max(dp[-1]))

Measured memory_bytes: 74968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    cin>>n>>q;
    vector<vector<ll>> g(n+1);
    vector<ll> d(n+1,0);
    rep(i,n-1){
      ll a,b;
      cin>>a>>b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    rep(loop,q){
      ll p,x;
      cin>>p>>x;
      d[p]+=x;
    }
    queue<ll> que;
    que.push(1);
    vector<bool> used(n+1,false);
    while(!que.empty()){
      ll v=que.front();
      que.pop();
      used[v]=true;
      for(auto itr:g[v]){
        if(used[itr]) continue;
        d[itr]+=d[v];
        que.push(itr);
      }
    }
    FOR(i,1,n+1){
      cout<<d[i]<<' ';
    }
    cout<<endl;
}


Measured memory_bytes: 17904
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A

#include <set>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<int> nums /* = {1, 5, 7, 10, 21}*/;
    vector<int> probs /* = {2, 4, 17, 8}*/;
    int n /* = 5*/;

    cin >> n; // 20以下
    for (int i = 0; i < n; i++)
    {
        int num;
        cin >> num;
        nums.push_back(num);
    }
    int q /* = 4*/;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int prob;
        cin >> prob;
        probs.push_back(prob);
    }
    int sumsSize = ((uint32_t)1) << (int)nums.size();
    vector<int> sums;
    sums.resize(sumsSize);
    sums[0] = 0;
    for (int i = 0; i < (int)nums.size(); i++)
    {
        uint32_t end = (uint32_t)1 << i;
        for (uint32_t j = 0; j < end; j++)
        {
            sums[end + j] = sums[j] + nums[i];
        }
    }
    set<int> sumSet(sums.begin(), sums.end());

    for (int p : probs)
    {
        if (sumSet.find(p) != sumSet.end())
        {
            cout << "yes" << endl;
        }
        else
        {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 7012
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.insert(0,[0,0,0])
f=1
for i in range(n):
  ti=l[i+1][0]-l[i][0]
  dist=abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])
  if dist>ti:
    f=0
    break
  elif ti%2==0 and dist%2>0:
    f=0
    break
  elif ti%2>0 and dist%2==0:
    f=0
    break
if f==1:
  print("Yes")
else:
  print("No")

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

int main() {
  int N,K,ans;
  cin >> N >> K;
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    ans += 2*min(x,K-x);
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, M; cin >> N >> M;
  bool red[N] = {}; red[0] = true;
  int num[N]; fill_n(num,N,1);
  rep(i,M) {
    int x, y; cin >> x >> y; x--; y--;
    red[y] |= red[x];
    num[y]++; num[x]--;
    if (!num[x]) red[x] = false;
  }
  int result = 0;
  rep(i,N) result += red[i]&&num[i];
  cout << result << endl;
  return 0;
}

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

int main() {
  
  int n=0,k=0;
  
  cin >> n >> k;
  
  int count=0;
  
  while(n) {
    
    n /= k; 
    
    count++;
  
  }
  
  cout << count << endl;
  
  return 0; 
  
}

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

int main(void)
{
    double r;
    cin >> r;

    cout << 2*M_PI*r << endl;

    return 0;
}


Measured memory_bytes: 3800
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while ( 1 ) {
		minv = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if ( minv > d[i] && color[i] != BLACK ) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)
			break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++ ) {
			if ( color[v] != BLACK && M[u][v] != INFTY ) {
				if (d[v] > M[u][v] ) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++ ) {
		if (p[i] != -1 ) sum += M[i][p[i]];
	}

	return sum;
}

int main() {
	cin >> n;

	for (int i = 0; i < n; i++ ) {
		for (int j = 0; j < n; j++ ) {
			int e; cin >> e;
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}

	cout << prim() << endl;

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

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

int main(){
    int h,w,k;
    cin >>h >>w >>k;
    vector<string> f(h);
    rep(i,h) cin >>f[i];

    vector<pi> a;
    pi start,goal;
    rep(i,h)rep(j,w){
        if(f[i][j]=='a') a.pb({i,j});
        if(f[i][j]=='s') start = {i,j};
        if(f[i][j]=='e') goal = {i,j};
    }
    int A = a.size();

    auto IN = [&](int y, int x){
        return 0<=y && y<h && 0<=x && x<w;
    };

    auto BFS = [&](pi s){
        vector<vector<int>> d(h,vector<int>(w,INF));
        d[s.fi][s.se] = 0;
        queue<pi> que({s});
        while(!que.empty()){
            pi now = que.front();
            que.pop();
            rep(i,4){
                int ny = now.fi+dy[i], nx = now.se+dx[i];
                if(IN(ny,nx) && f[ny][nx]!='#' && d[ny][nx] > d[now.fi][now.se]+1){
                    d[ny][nx] = d[now.fi][now.se]+1;
                    que.push({ny,nx});
                }
            }
        }
        return d;
    };

    vector<vector<int>> ds = BFS(start), dg = BFS(goal);

    vector<vector<int>> da(A, vector<int>(A,INF));
    rep(i,A){
        vector<vector<int>> d = BFS(a[i]);
        rep(j,A) da[i][j] = d[a[j].fi][a[j].se];
    }

    vector<vector<int>> dp(1<<A,vector<int>(A,INF));
    rep(i,A) dp[1<<i][i] = ds[a[i].fi][a[i].se];

    rep(mask,1<<A)rep(i,A)if(mask>>i&1){
        rep(j,A)if(!(mask>>j&1)){
            int nx = mask|(1<<j);
            dp[nx][j] = min(dp[nx][j], dp[mask][i]+da[i][j]);
        }
    }

    int ans = INF;
    rep(mask,1<<A)rep(i,A)if((mask>>i&1) && __builtin_popcount(mask)>=k){
        int t = dp[mask][i];
        t += dg[a[i].fi][a[i].se];
        ans = min(ans, t);
    }

    if(ans == INF) ans = -1;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 134764
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int arr[30] = {};

int main(void) {

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int a;
			cin >> a;
			a--;
			arr[a]++;
		}
	}

	int count = 0;
	for (int i = 0; i < m; i++) {
		if (arr[i] == n) {
			count++;
		}
	}

	COUT(count);



	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	static long mod = (long)(1e9+7);
	public static void main(String[] args) { //Ball out 
		/*
		 * */
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int x  = I.nextInt();
		O.pln(x==0?1:0);
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25568
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

ll lcm(ll a, ll b) {
    return (a / __gcd(a, b)) * b;
}

int main() {
    int n;
    cin >> n;
    vector<ll> arr(n, 0);
    for(ll& val: arr)
        cin >> val;
    if (n == 1) {
        cout << arr[0] << endl;
        return 0;
    }
    ll ans = lcm(arr[0], arr[1]);
    for(int i = 2; i < n; i++) {
        ans = lcm(ans, arr[i]);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int num = N / 500;
        if(A + 500 * num >= N){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }

}

Measured memory_bytes: 21588
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

int main() {

  string a, b;cin >> a >> b;

  if( a.size() > b.size() ){
    cout << "GREATER" << endl;
  }else if( a.size() < b.size() ){
    cout << "LESS" << endl;
  }else{
    int n = a.size();
    for(int i=0; i<n; i++){
      if( a[i] > b[i] ){
        cout << "GREATER" << endl;
        return 0;
      }else if(a[i] < b[i]){
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v; cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  lint ans = 1;
  vector<lint> dp(n, 0);
  dp[0] = 1;
  for (int v = 1; v < n; v++) {
    dp[v] = dp[v - 1] + 1 + v;
    for (auto nxt : g[v]) {
      if (nxt < v) {
        dp[v] -= nxt + 1;
      }
    }
    ans += dp[v];
    // cerr << "dp[" << v + 1 << "] = " << dp[v] << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 16560
let () = Scanf.scanf "%d %d\n" @@ fun n k ->
    let a =
        Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun a b -> (a, b) in
    Array.sort (fun (x, _) (y, _) -> x - y) a;
    let rec f acc i =
        if (snd a.(i)) + acc >= k then fst a.(i) else f ((snd a.(i)) + acc) (i+1)
    in f 0 0 |> Printf.printf "%d"

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

int N,K;
char S[310],T[310];
int dp[310][310][310] = {0};
int ans = 0;

int main()
{
    scanf("%s %d",S + 1,&K);

    N = strlen(S + 1);
    if(N == 1)
    {
        printf("1\n");
        return 0;
    }
    if(N == 2)
    {
        if(K || S[1] == S[2])printf("2\n");
        else printf("1\n");
        return 0;
    }
    for(int i = 1; i <= N; i++)T[i] = S[i];
    reverse(T + 1,T + 1 + N);

    for(int i = 0; i <= K; i++)
    {
        for(int j = 1; j <= N; j++)
        {
            for(int k = 1; k <= N; k++)
            {
                dp[j][k][i] = max(dp[j - 1][k][i],dp[j][k - 1][i]);
                if(S[j] == T[k])dp[j][k][i] = max(dp[j][k][i],dp[j - 1][k - 1][i] + 1);
                if(i != 0)dp[j][k][i] = max(dp[j][k][i],dp[j - 1][k - 1][i - 1] + 1);
                if(j + k == N)ans = max(ans,dp[j][k][i] * 2);
                if(j + k == N - 1)ans = max(ans,dp[j][k][i] * 2 + 1);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n,0);
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  int res = 0;
  for (int i = 0; i < n; i++){
    int tmp = abs(v[i] - k);
    res += 2*min(tmp, v[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll a;
    string s;
    cin>>a>>s;
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)
#define INF 100000000000 // long only


int main(){
  long x;
  scanf("%ld",&x);
  long a=100;
  int iter=0;
  while(1){
    iter++;
    a *= 1.01;
    if(a>=x){
      printf("%d\n",iter);
      return 0;
    }

  }
  
  return 0;
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

const ll inf = 1LL << 61;
int t;
ll n, a, b, cc, d;

void add(priority_queue<ll> & q, unordered_map<ll, ll> & c, ll cn, ll on, ll co) {
  if (0 < on && on < cn && !c.count(on))
    q.push(on), c[on] = c[cn] + co;
  else if (0 < on && on < cn)
    c[on] = min(c[on], c[cn] + co);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> t;
  while (t--) {
    cin >> n >> a >> b >> cc >> d;
    ll r = inf;
    unordered_map<ll, ll> c;
    c[n] = 0;
    priority_queue<ll> q;
    q.push(n);
    while (!q.empty()) {
      ll cn = q.top();
      q.pop();
      if (cn <= inf / d)
        r = min(r, cn * d + c[cn]);
      if (cn % 2 == 0)
        add(q, c, cn, cn / 2, a);
      else {
        add(q, c, cn, (cn + 1) / 2, a + d);
        add(q, c, cn, (cn - 1) / 2, a + d);
      }
      if (cn % 3 == 0)
        add(q, c, cn, cn / 3, b);
      else if (cn % 3 == 1)
        add(q, c, cn, (cn - 1) / 3, b + d);
      else
        add(q, c, cn, (cn + 1) / 3, b + d);
      if (cn % 5 == 0)
        add(q, c, cn, cn / 5, cc);
      else if (cn % 5 == 1)
        add(q, c, cn, (cn - 1) / 5, cc + d);
      else if (cn % 5 == 2)
        add(q, c, cn, (cn - 2) / 5, cc + 2 * d);
      else if (cn % 5 == 3)
        add(q, c, cn, (cn + 2) / 5, cc + 2 * d);
      else
        add(q, c, cn, (cn + 1) / 5, cc + d);
    }
    cout << r << "\n";
  }
}


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

ll n;
ll w[100000];
ll v[100000];
ll dp[102][100002];

ll solve(ll i, ll W)
{
	if (i == 0 || W == 0)
	{
		return 0;
	}
	if (dp[i][W] != -1)
	{
		return dp[i][W];
	}

	ll value = 0;
	if (w[i - 1] <= W)
	{
		value = max(v[i - 1] + solve(i - 1, W - w[i - 1]), solve(i - 1, W));

	}
	else if (w[i - 1] > W)
	{
		value = solve(i - 1, W);
	}

	return dp[i][W] = value;
}

int main()
{
	ll weight;
	cin >> n >> weight;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i] >> v[i];
	}

	memset(dp, -1, sizeof(dp));
	cout << solve(n, weight) << endl;
	return 0;
}

Measured memory_bytes: 83336
a, b = map(int, input().split())
MOD = int(1e9 + 7)

def calc(x, y):
    right = above = 0
    while x>0 and y>0:
        if x>y:
            x -= 2
            y -= 1
            right += 1
        else:
            x -= 1
            y -= 2
            above += 1

    return (True, right, above) if x==0 and y==0 else (False, None, None)


def res(n, k):
    # print(n, k)
    total = 1
    if k < n-k:
        k = n-k
    for i in range(k+1, n+1):
        total = (total * i)% MOD
        total *= pow(i-k, MOD-2, MOD)
    return total

r, right, above = calc(a, b)
if not r:
    print(0)
else:
    print(int(res(above+right, right) % MOD))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct BIT{
    int n;//元の数列のサイズ
    vector<T> bit[2];//データ収納用
    void init(int n_){
        n=n_+1;
        for(int j=0;j<2;j++){
            bit[j].assign(n,0);
        }
    }
    void add_sub(int p,int i,T x){
        for(int j=i;j<n;j+=j&-j){
            bit[p][j]+=x;
        }
    }
    void add(int l,int r,T x){//[l,r]に加算
        add_sub(0,l,-x*(l-1));
        add_sub(0,r+1,x*r);
        add_sub(1,l,x);
        add_sub(1,r+1,-x);
    }
    T sum_sub(int p,int i){
        T s(0);
        for (int j=i;j>0;j-=j&-j){
            s+=bit[p][j];
        }
        return s;
    }
    T sum(int i,int j){//[i,j]のΣを計算
        return sum_sub(0,j)+sum_sub(1,j)*j-sum_sub(0,i-1)-sum_sub(1,i-1)*(i-1);
    }
};
int main(){
    int N, Q;
    scanf("%d", &N);
    scanf("%d", &Q);
    vector<int> C(N);//i番目の石の色
    for (int i = 0; i < N; i++) {
        scanf("%d", &C.at(i));
    }
    map<pair<int, int>, vector<int>> query;
    //左端がl,右端がrの時の答えを求めるクエリは何番目のクエリか
    vector<vector<int>> left(N);
    //Q個のクエリで右端がiであるようなクエリの左端の値
    for (int i = 0; i < Q; i++) {
        int l, r;
        scanf("%d", &l);
        scanf("%d", &r);
        query[make_pair(l - 1, r - 1)].push_back(i);
        //左端がl,右端がrであるクエリが何番目であるかを配列に持たせる
        //(同じ内容のクエリが複数あるかもしれないのでintではなくvectorで複数持てるようにする)
        left.at(r - 1).push_back(l - 1);
        //右端がrであるようなクエリの左端の値を配列に持たせる
    }
    BIT<int> rock;//Binary Indexed Tree(1-indexed)
    rock.init(N + 10);//BITの前処理
    vector<int> RP(N, -1);
    //i番目の色の右端はどこか,初期値-1は存在しないことを示す(左から順に更新)
    vector<int> answer(Q, 1);
    //i番目のクエリの答えを持つ
    for (int i = 0; i < N; i++) {
        int memo = RP.at(C.at(i) - 1);
        //i番目の石の色の右端の位置が更新する前どこだったか(あるいはまだ現れていないか)
        RP.at(C.at(i) - 1) = i;
        //i番目の石の色の右端の位置をiに更新
        if (memo == -1) {
            rock.add(i + 1, i + 1, 1);
            //初登場なのでi番目に1を足すだけ
        }
        else {
            rock.add(memo + 1, memo + 1, -1);
            rock.add(i + 1, i + 1, 1);
            //2回目以降の登場なのでi番目に1を足すとともに、旧右端の情報は-1して消しておく
        }
        for (int j = 0; j < (int) left.at(i).size(); j++) {
            //右端がiであるクエリそれぞれについてクエリの答えを以下求める
            int L = left.at(i).at(j);
            //各クエリの左端がL、右端がi
            for (int k = 0; k < (int) query[make_pair(L, i)].size(); k++) {
                int number = query[make_pair(L, i)].at(k);
                //左端と右端の情報からそのクエリが何番目かをnumberで受け取る
                answer.at(number) = (int) rock.sum(L + 1, i + 1);
                //number番目のクエリの答えは[L+1,i+1]の間の1の個数
                //つまり[L+1,i+1]の区間の和と一致
            }
        }
    }
    for (int i = 0; i < Q; i++) {
        printf("%d\n", answer.at(i));
    }
}

Measured memory_bytes: 89060
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map(String::toInt)
    if (x.groupId() == y.groupId()) {
        println("Yes")
    } else {
        println("No")
    }
}

fun Int.groupId() = when (this) {
    1, 3, 5, 7, 8, 10, 12 -> 1
    4, 6, 9, 11 -> 2
    2 -> 3
    else -> null
}


Measured memory_bytes: 36136
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<ll>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;

class d{
    ll n,k,l;
    #define maxN (ll)2e5+1
    

    int init(int n,int *par,int *hight){
        rep(i,n){
            par[i]=i;
            hight[i]=0;
        }
    }

    int root(int x,int *par,int *hight){
        return par[x]==x?x:par[x]=root(par[x],par,hight);
    }

    bool same(int x,int y,int *par,int *hight){
        return root(x,par,hight)==root(y,par,hight);
    }

    void unit(int x,int y,int *par,int *hight){
        x=root(x,par,hight);
        y=root(y,par,hight);
        if(x==y) return;

        if(hight[x]<hight[y]){
            par[x]=y;
        }else{
            par[y]=x;
            if(hight[x]==hight[y]) hight[x]++;
        }

    }

    public:
    d(){
        cin >> n >> k >> l;
        int trainv[maxN];
        int trainh[maxN];
        int carv[maxN];
        int carh[maxN];
        
        init(n,carv,carh);
        rep(i,k){
            ll p,q;
            cin >> p >> q;
            p--; q--;
            unit(p,q,carv,carh);
        }
        
        init(n,trainv,trainh);
        rep(i,l){
            ll r,s;
            cin >> r >> s;
            r--;s--;
            unit(r,s,trainv,trainh);
        }
        
        #define rootC(i) root(i,carv,carh)
        #define rootT(i) root(i,trainv,trainh)
        map<p<int,int>,int> m;
        rep(i,n) m[make_pair(rootC(i),rootT(i))]++;
        rep(i,n)
            cout << m[make_pair(rootC(i),rootT(i))] <<" "; 
        
    }


};


int main(){
    d();
    return 0;
}

Measured memory_bytes: 15104
#include <stdio.h>

int comp(const void *a,const void *b);

int main(){
	int n,k;
	int A[100001];
	int i;
	int wc;
	int len,lenmax,lensub;
	
	while(1){
		scanf("%d %d\n",&n,&k);
		if(n==0&&k==0)break;

		wc=0;
		for(i=0;i<k;i++){
			scanf("%d\n",&A[i]);
		}
		
		qsort(A,k,sizeof(int),comp);
		
		if(A[0]!=0){
			len=0;
			lenmax=0;
			for(i=0;i<k;i++){
				if(i==0)len=1;
				if(i>0){
					if(A[i-1]==A[i]-1)len++;
					if(A[i-1]!=A[i]-1)len=1;
					if(len>=lenmax)lenmax=len;
				}
			}
		}
		
		if(A[0]==0){
			len=0;
			lensub=0;
			lenmax=0;
			wc=0;
			for(i=1;i<k;i++){
				if(i==1){
					len=1;
					lensub=len;
					if(A[1]!=1){
						wc=A[1]-1;
						lensub++;
					}
					if(len>=lenmax)lenmax=len;
					if(lensub>=lenmax)lenmax=lensub;

				}
				if(i>1){
					if(A[i-1]==A[i]-1){
						len++;
						lensub++;
					}
					if(A[i-1]!=A[i]-1){
						len=1;
						if(A[i-1]==A[i]-2){
							if(wc==0){
								wc=A[i]-1;
								lensub+=2;
							}
							if(wc>0){
								lensub=A[i]-(wc+1)+1;
								wc=A[i]-1;
							}
						}
						if(A[i-1]!=A[i]-2){
							lensub=2;
							wc=A[i]-1;
						}
					}
					if(i==k-1 && wc==0 && A[i]!=n){
						wc=A[i]+1;
						lensub++;
					}
				}
				if(len>=lenmax)lenmax=len;
				if(lensub>=lenmax)lenmax=lensub;
			}
		}
		printf("%d\n",lenmax);

	}
	return 0;
}


int comp(const void *a,const void *b){
	int x= *(int *)a;
	int y= *(int *)b;
	return x-y;
}

Measured memory_bytes: 1132
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  int s,w;
  cin>>s>>w;
  if(s>w) cout << "safe" <<endl;
  else cout << "unsafe" <<endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long mpow(long long a, int b) {
	if (b == 0) return 1;
	if (b % 2 == 1) return mpow(a, b - 1) * a % mod;
	long long z = mpow(a, b / 2);
	return z * z % mod;
}
int main() {
	int X, Y;
	scanf("%d%d", &X, &Y);
	vector<long long> F(X + Y);
	F[0] = 1;
	for (int i = 1; i < (int) F.size(); ++i) F[i] = F[i - 1] * i % mod;
	long long r = 0;
	for (int j = 0; j <= X; ++j) {
		int xa = j;
		if ((X - xa) % 2 != 0) continue;
		int ya = (X - xa) / 2;
		if (xa + ya * 2 == X && xa * 2 + ya == Y) {
			r += F[xa + ya] * mpow(F[xa], mod - 2) % mod * mpow(F[ya], mod - 2);
			r %= mod;
		}
	}
	printf("%lld\n", r);
}


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

void solve_8(){
    string a, b;
    cin >> a >> b;
    string tmp =  a+b;
    int c = atoi(tmp.c_str());
    //cout << c << endl;
    int c_square = sqrt(c);
    cout << (c_square * c_square == c? "Yes": "No") << endl;
    
}

void solve_B(){
    
}

void solve_C(){
    
}

void solve_D(){
    
}

void solve_E(){
    
}

void solve_F(){
    
}

int main(){
    solve_8();
    //solve_B();
    //solve_C();
    //solve_D();
    //solve_E();
    //solve_F();
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] data = in.readLine().split(" ");
        int n = Integer.parseInt(data[0]);
        long d = Integer.parseInt(data[1]);
        long dd = d * d;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            data = in.readLine().split(" ");
            long x = Integer.parseInt(data[0]);
            long y = Integer.parseInt(data[1]);
            if (x*x + y*y <= dd) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 55244
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  if(a=="H"){
    if(b=="H"){
      cout<<"H"<<endl;
    }
    else{
      cout<<"D"<<endl;
    }
  }
  else{
    if(b=="H"){
      cout<<"D"<<endl;
    }
    else{
      cout<<"H"<<endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <set>
using namespace std;

const int W = 8;
const int H = 4;

int dat[4][8];

struct S {
  char dat[4][8];
  char pos[4];
  int cost;
  void show() const {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	cout << (int)dat[i][j] << " ";
      }
      cout << endl;
    }
  }

  void change(int sp, int a) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	if(dat[i][j] == a) {
	  swap(dat[i][j], dat[pos[sp]/W][pos[sp]%W]);
	  pos[sp] = (char)(i*W+j);
	  return;
	}
      }
    }
  }

  bool operator <(const S &s) const {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	if(dat[i][j] != s.dat[i][j]) return dat[i][j] < s.dat[i][j];
      }
    }
    return false;
  }
};

bool isCorrect(const S &s) {
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      if(j+1 == W) {
	if(s.dat[i][j]%10 != 8) return false;
      } else {
	if(s.dat[i][j] != (char)((i+1)*10+j+1)) return false;
      }
    }
  }
  return true;
}

int bfs(S s) {
  queue<S> que;
  set<S> vis;
  que.push(s);
  vis.insert(s);
  while(!que.empty()) {
    s = que.front(), que.pop();
    bool isChange = false;
    for(int i = 0; i < 4; ++i) {
      int x = s.pos[i]%W;
      int y = s.pos[i]/W;
      if(s.dat[y][x-1]%10 >= 7) continue;
      S t = s;
      ++t.cost;
      t.change(i, s.dat[y][x-1]+1);
      if(vis.find(t) != vis.end()) continue;
      isChange = true;
      vis.insert(t);
      que.push(t);
    }
    if(!isChange) {
      if(isCorrect(s)) return s.cost;
    }
  }
  return -1;
}

int main() {
  int T;
  cin >> T;
  while(T--) {
    S s;
    s.cost = 0;
    for(int i = 0; i < 4; ++i) {
      s.dat[i][0] = (char)((i+1)*10+8);
      s.pos[i] = (char)(i*W);
    }
    for(int i = 0; i < H; ++i) {
      for(int j = 1; j < W; ++j) {
	int in;
	cin >> in;
	s.dat[i][j] = in;
	if(in%10 == 1) {
	  char tmp = s.pos[in/10-1];
	  s.pos[in/10-1] = (char)(i*W+j);
	  swap(s.dat[i][j], s.dat[tmp/W][tmp%W]);
	}
      }
    }
    cout << bfs(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll h,n;
    cin >> h >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll total = 0;
    rep(i,n) total += a[i];
    if(h <= total){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#include <unordered_map>
#define lli long long int
#define fl(i, a, b) for(int i = a; i < b; ++i)
#define fl2(i, a, b) for(int i = a; i <= b; ++i)
#define rfl(i, a, b) for(int i = a; i > b; --i)
#define rfl2(i, a, b) for(int i = a; i >= b; ++i)
#define all(v) ((v).begin(), (v).end())
#define all2(v) ((a) + 0, (a) + n);
#define sz(s) (s).size()
#define OO (lli)1e18
#define MIN INT_MIN
#define f first
#define s second		
#define mp make_pair
#define pb puch_back
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
using namespace std;

lli power(lli x, lli y) {
	lli i, power = 1;
	if (y == 0)
		return 1;
	for (i = 1; i <= y; i++)
		power = power * x;
	return power;
}

int32_t main() {

	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	//freopen("overcode.in","r",stdin);
	//freopen("output.txt", "w", stdout);

	clock_t z = clock();

	int n, q;
	cin >> n >> q;
	int a[3];
	a[0] = n - q;
	a[1] = n + q;
	a[2] = n * q;
	cout << *max_element(a + 0, a + 3) << '\n';
	debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	while(1){
	int i,n,a[7]={},b;
	scanf("%d",&n);
	if(n==0)break;
	for(i=0;i<n;i++){
		scanf("%d",&b);
		if(0<=b&&b<10)a[0]++;
		if(10<=b&&b<20)a[1]++;
		if(20<=b&&b<30)a[2]++;
		if(30<=b&&b<40)a[3]++;
		if(40<=b&&b<50)a[4]++;
		if(50<=b&&b<60)a[5]++;
		if(60<=b)a[6]++;
		
			
	}
	for(i=0;i<7;i++)printf("%d\n",a[i]);
		
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
	 int R[MAX], n;
	 
	 
	 cin >> n;
	 for( int i = 0; i<n; i++) cin >> R[i];
	 
	 int maxv = -2000000000; //设置一个足够小的初始值
	 int minv = R[0];
	 
	 for ( int i = 1; i <n; i++ ) {		//如果每次都在这一阶段直接读取R[i]，那么数组可以省去 
	 	maxv = max(maxv, R[i] - minv);   //更新最大值 
	 	minv = min(minv, R[i]);		    //暂存现阶段最小值 
	 } 
	 cout  << maxv << endl;
	 
	 return 0;
	 
}


Measured memory_bytes: 3888
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
for i in range(N):
    ans += B[A[i]-1]
    if (i != 0):
        if (A[i] == A[i-1]+1):
            ans += C[A[i-1]-1]

print(ans)

Measured memory_bytes: 3064
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N, X, T = MI()
a = math.ceil(N / X)
print(a * T)

Measured memory_bytes: 68284
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int dp[5050][5050];

int main(){
	int N; cin >> N;
	string S; cin >> S;
	for(int i = N-1; i >= 0; i--){
		for(int j = N-1; j >= 0; j--){
			if(S[i] != S[j]) dp[i][j] = 0;
			else dp[i][j] = dp[i+1][j+1] + 1;
		}
	}
	int ans = 0;
	rep(i,N)rep(j,N){
		if(i >= j) continue;
		int now = min(dp[i][j],j-i);
		ans = max(ans,now);
	}
	cout << ans << endl;
}
   


Measured memory_bytes: 98944
#include<cstdio>

int n;
char s[20];

void wtf(int c, int n, char s[]) {
  if (c == n) {
    printf("%s\n", s);
    return;
  }
  char m = 'a';
  for (int i = 0; i < c; i++) {
    if (s[i] == m) {
      ++m;
    }
  }
  for (int i = 'a'; i <= m; i++) {
    s[c] = i;
    wtf(c + 1, n, s);
  }
}

int main() {
  scanf("%d", &n);
  wtf(0, n, s);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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; }
//-------------------
ll n;
const ll N = 100000 + 5;
ll a[N];
//ld c[N+1]; 
ll ans[N];

int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	for(int i=1;i<=n;i++){
		ans[1] += a[i]*(i%2==1? 1:-1);
	}
	for(int i=2;i<=n;i++){
		ans[i] = 2*a[i-1] - ans[i-1];
	}
	FOR(i,1,n){
		cout << ans[i] << ' ';
	}

	return 0;
}

Measured memory_bytes: 2816
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

x = inpl()
for i in range(5):
    if x[i] == 0:
        print(i+1)
        break

Measured memory_bytes: 10500
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
 
int gcd(int m, int n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}
 
vector<pair<int, int>> factorize(int n) {
  vector<pair<int, int>> res;
  for(int i = 2; i * i <= n; i++) {
    if(n%i) continue;
    res.emplace_back(i, 0);
    while(n%i==0) {
      n/=i;
      res.back().second++;
    }
  }
  if(n!=1) res.emplace_back(n, 1);
  return res;
}
 
signed main() {
  int a, b; cin >> a >> b;
  int g = gcd(a, b);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (size_t i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int dp[100000 + 1][100];

int solve(int n) {
  vector<int> coins(1, 1);
  for (auto i = 6; i <= n; i *= 6)
    coins.push_back(i);
  for (auto i = 9; i <= n; i *= 9)
    coins.push_back(i);
  sort(coins.begin(), coins.end());
  REP(i, coins.size())
    dp[0][i] = 0;
  FOR(i, 1, n + 1)
    dp[i][0] = i;
  FOR(i, 1, n + 1) {
    FOR(k, 1, coins.size()) {
      dp[i][k] = dp[i][k - 1];
      if (i >= coins[k]) {
        dp[i][k] = min(dp[i][k], 1 + dp[i - coins[k]][k]);
      }
    }
  }
  int cnt = n;
  REP(i, coins.size())
    cnt = min(cnt, dp[n][i]);
  return cnt;
}

int main() {
  int n;
  cin >> n;
  cout << solve(n) << endl;
}


Measured memory_bytes: 39296
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
int main()
{
  ll n,m,q[1100],r,x[1100],y[1100],z[1100],ans;
  cin >> n >> m;
  rep(i,n)cin >> x[i] >> y[i] >> z[i];
  rep(i,n)q[i]=x[i]+y[i]+z[i];
  sort(q,q+n);
  FOR(i,n-m,n)r+=q[i];
  if(ans<r)ans=r;
  //printf("%d\n",r);
  
  rep(i,n)z[i]=z[i]*(-1);
  r=0;
  rep(i,n)q[i]=x[i]+y[i]+z[i];
  sort(q,q+n);
  FOR(i,n-m,n)r+=q[i];
  if(ans<r)ans=r;
  //rep(i,n)printf("%d\n",q[i]);
  //printf("%d\n",r);
  
  rep(i,n)y[i]=y[i]*(-1);
  rep(i,n)z[i]=z[i]*(-1);
  r=0;
  rep(i,n)q[i]=x[i]+y[i]+z[i];
  sort(q,q+n);
  FOR(i,n-m,n)r+=q[i];
  if(ans<r)ans=r;
  //printf("%d\n",r);
  
  rep(i,n)z[i]=z[i]*(-1);
  r=0;
  rep(i,n)q[i]=x[i]+y[i]+z[i];
  sort(q,q+n);
  FOR(i,n-m,n)r+=q[i];
  if(ans<r)ans=r;
  //printf("%d\n",r);
  
  rep(i,n)x[i]=x[i]*(-1);
  rep(i,n)y[i]=y[i]*(-1);
  rep(i,n)z[i]=z[i]*(-1);
  r=0;
  rep(i,n)q[i]=x[i]+y[i]+z[i];
  sort(q,q+n);
  FOR(i,n-m,n)r+=q[i];
  if(ans<r)ans=r;
  //printf("%d\n",r);
  
  rep(i,n)z[i]=z[i]*(-1);
  r=0;
  rep(i,n)q[i]=x[i]+y[i]+z[i];
  sort(q,q+n);
  FOR(i,n-m,n)r+=q[i];
  if(ans<r)ans=r;
  //printf("%d\n",r);
  
  rep(i,n)y[i]=y[i]*(-1);
  rep(i,n)z[i]=z[i]*(-1);
  r=0;
  rep(i,n)q[i]=x[i]+y[i]+z[i];
  sort(q,q+n);
  FOR(i,n-m,n)r+=q[i];
  if(ans<r)ans=r;
  //printf("%d\n",r);
  
  rep(i,n)z[i]=z[i]*(-1);
  r=0;
  rep(i,n)q[i]=x[i]+y[i]+z[i];
  sort(q,q+n);
  FOR(i,n-m,n)r+=q[i];
  if(ans<r)ans=r;
  //printf("%d\n",r);
  
  printf("%lld",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */
//文字列中の一文字⇒数字の時は s[i]-'0'
int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

long long int nCr[3000][3000]={0};
 
long long int combination(long long int n, long long int r)
{
    if (r == 0 || r == n){
      nCr[n][r]=1;
        return (1);
    }
    else if (r == 1){
      nCr[n][r]=n;
        return (n);
    }
  if(nCr[n-1][r-1]==0&&nCr[n-1][r]==0){
    nCr[n-1][r-1]=combination(n - 1, r - 1)%1;
    nCr[n-1][r]=combination(n - 1, r)%1;
    return (nCr[n-1][r-1]+nCr[n-1][r]);
  }
  else if(nCr[n-1][r-1]!=0&&nCr[n-1][r]==0){
    nCr[n-1][r]=combination(n-1,r)%1;
    return(nCr[n-1][r-1]+ nCr[n - 1][r]);
  }
  else if(nCr[n-1][r-1]==0&&nCr[n-1][r]!=0){
    nCr[n-1][r-1]=combination(n-1,r-1)%1;
    return(nCr[n-1][r]+ nCr[n - 1][r-1]);
  }
  else{
    return nCr[n-1][r]+nCr[n-1][r-1];
  }
    
}


int main (void)
{
	long long int n,i,min,k,a[210000],max,j=1,count=0;
scanf("%lld",&n);
  n=n-1;
  for(i=1;i<=n;i++){
  count=count+n/i;
  }
  printf("%lld",count);
return 0;
}


Measured memory_bytes: 1736
n,x=int(input()),10**6+100
a,b,c=list(map(int,input().split())),[0]*(2*x),0
for i in a:
    b[i]+=1
for i in range(x):
    c+=1 if b[i]==1 else 0
    if b[i]==0:
        continue
    for j in range(1,x):
        if i*j>=x:
            break
        b[i*j]=0
print(c)

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

int main(void)
{
    int a, b ,c;
    while(scanf("%d%d%d", &a, &b, &c) == 3)
    {
        int maxa = -1;
        if(maxa < a)
            maxa = a;
        if(maxa < b)
            maxa = b;
            if(maxa < c)
            maxa = c;
        if(a == b && b == c)
        {
            cout << 0 << endl;
            continue;
        }
       for(int i = maxa; i <= 10000; ++i)
       {
           if((i-a+i-b+i-c)%2 == 0)
           {
               cout << (i-a+i-b+i-c)/2 << endl;
               break;
           }
       }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int n;
string d,y;
string a[10],b[10];
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i<n;i++)cin>>a[i]>>b[i];
		cin>>y>>d;
		queue<pair<string,int> >P;
		P.push(make_pair(y,0));
		bool flag=1;
		while(!P.empty())
		{
			string s=P.front().first;int c=P.front().second;
			P.pop();
			if(s==d)
			{
				cout<<c<<endl;
				flag=0;
				break;
			}
			for(int i=0;i<n;i++)
			{
				string t="";
				for(int j=0;j<s.size();)
				{
					if(j+a[i].size()<=s.size()&&s.substr(j,a[i].size())==a[i])
					{
						t+=b[i];
						j+=a[i].size();
					}
					else t+=s[j++];
				}
				if(t!=s&&t.size()<=d.size())P.push(make_pair(t,c+1));
			}
		}
		if(flag)cout<<-1<<endl;
	}
}



Measured memory_bytes: 3412