akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
	public void run() throws Exception {
		FastScanner file = new FastScanner();
		int N = file.nextInt();
		int[][] dp = new int[3][N+1];
		int[] a = new int[N+1], b = new int[N+1], c = new int[N+1];
		for(int i = 1; i <= N; i++) {
			a[i] = file.nextInt();
			b[i] = file.nextInt();
			c[i] = file.nextInt();
		}
		dp[0][1] = a[1];
		dp[1][1] = b[1];
		dp[2][1] = c[1];
		for(int i = 2; i <= N; i++) {
			dp[0][i] = Math.max(dp[1][i-1], dp[2][i-1]) + a[i];
			dp[1][i] = Math.max(dp[0][i-1], dp[2][i-1]) + b[i];
			dp[2][i] = Math.max(dp[1][i-1], dp[0][i-1]) + c[i];
		}
		System.out.println(Math.max(dp[0][N], Math.max(dp[1][N], dp[2][N])));
	}
	class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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

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

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

	}
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
}


Measured memory_bytes: 44156
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple

int main(){
  ll n; cin >> n;
  ll t_2 = 0, t_4 = 0;
  rep(i,n){
    ll t; cin >> t;
    if(t%4 == 0) t_4++;
    else if(t%2 == 0) t_2++;
  }
  if(t_2) n = n - t_2 + 1;
  if(t_4 + 1 >= n - t_4) cout <<"Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<ll> list(3 * N);
  for (int i = 0; i < 3 * N; i++) {
    cin >> list[i];
  }

  // 左から
  vector<ll> S(2 * N + 1, 0);
  priority_queue<ll, vector<ll>, greater<ll> > que1;
  for (int i = 0; i < N; i++) {
    S[i + 1] = S[i] + list[i];
    que1.push(list[i]);
  }
  for (int i = N; i < 2 * N; i++) {
    ll mi = que1.top();
    if (list[i] > mi) {
      S[i + 1] = S[i] + list[i] - mi;
      que1.pop();
      que1.push(list[i]);
    } else {
      S[i + 1] = S[i];
    }
  }

  // 右から
  vector<ll> T(2 * N + 1, 0);
  priority_queue<ll> que2;
  for (int i = 0; i < N; i++) {
    T[i + 1] = T[i] + list[3 * N - 1 - i];
    que2.push(list[3 * N - 1 - i]);
  }
  for (int i = N; i < N * 2; i++) {
    ll ma = que2.top();
    if (ma > list[3 * N - 1 - i]) {
      T[i + 1] = T[i] + list[3 * N - 1 - i] - ma;
      que2.pop();
      que2.push(list[3 * N - 1 - i]);
    } else {
      T[i + 1] = T[i];
    }
  }

  // 集計
  ll res = -(1LL << 60);
  for (int i = N; i <= 2 * N; i++) {
    res = max(res, S[i] - T[3 * N - i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 8052
import sys

input=sys.stdin.readline
sys.setrecursionlimit(10**7)

N=int(input())
c=list(map(int,input().split()))
for i in range(N):
    c[i]-=1
edge=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

subtree=[1]*N
def size(v,pv):
    for nv in edge[v]:
        if nv!=pv:
            size(nv,v)
            subtree[v]+=subtree[nv]

size(0,-1)

data=[[] for i in range(N)]
Parent=[[0] for i in range(N)]
parent=[0]*N
def dfs(v,pv,nop):
    pp=parent[nop]
    parent[nop]=v
    Parent[nop].append(v)
    data[c[v]].append((parent[c[v]],v))
    for nv in edge[v]:
        if nv!=pv:
            dfs(nv,v,c[v])
    parent[nop]=pp

dfs(0,-1,0)

for i in range(N):
    dic={v:subtree[v] for v in Parent[i]}
    for p,ch in data[i]:
        dic[p]-=subtree[ch]

    res=N*(N+1)//2
    for p in dic:
        res-=dic[p]*(dic[p]+1)//2
    print(res)

Measured memory_bytes: 339280
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int ans=0,si=s.size();
  bool fg=false;
  rep(i,si){
    for(int j=si-1;j>=i;j--){
      fg=true;
      REP(k,i,j+1){
        if(s[k]!='A' && s[k]!='C' && s[k]!='G' && s[k]!='T'){
          fg=false;
        }
      }
      if(fg){
        int tmp=j-i+1;
        chmax(ans,tmp);
      }
    }
  }
  cout<<ans<<'\n';
  return(0);
}


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

using namespace std;

int main(){
    vector<int> antenna(5);
    for(int i=0; i<5; i++)
	{
    	cin >> antenna[i];
    }
    int k;
    cin >> k;

	sort(antenna.begin(), antenna.end());
	if(antenna[4] - antenna[0] > k){
			cout << ":(" << endl;
	}else{
			cout << "Yay!" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;

const int N=3005;
int n;
ll mod,f[N][N],c[N][N],ans; 
inline int read() {
	int x=0,flag=0;char ch=getchar();
	while(ch<'0'||ch>'9'){flag|=(ch=='-');ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return flag?-x:x;
}
inline int mx(int x,int y) {return x>y?x:y;}
inline int mn(int x,int y) {return x<y?x:y;}

inline int ksm(ll a,int b,int m=mod) {
	int ans=1;
	while(b) {
		if(b&1) ans=1ll*ans*a%m;
		a=1ll*a*a%m;
		b>>=1;
	}
	return ans;
}
int main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();mod=read();
	c[0][0]=f[0][0]=1;
	for(int i=1;i<=n+1;++i) {
		c[i][0]=1;
		for(int j=1;j<=i;++j)
			f[i][j]=(f[i-1][j-1]+1ll*j*f[i-1][j]%mod)%mod,
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	for(int i=0;i<=n;++i) {
		ll mul=(i&1?mod-1:1),res=0,i2=ksm(2,n-i),j2=1;
		mul=1ll*mul*c[n][i]%mod*1ll*ksm(2,ksm(2,n-i,mod-1))%mod;
		for(int j=0;j<=i;++j)
			res=(res+1ll*j2*f[i+1][j+1]%mod)%mod,
			j2=1ll*j2*i2%mod;
		ans=(ans+1ll*mul*res%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

int main(){
int N,K; cin >> N >> K;
  string S; cin >> S;
  vector<int> vec;
  //0,2,4,,番目に連続する1の個数を、1,3,5,,,番目に連続する0の個数をpush_backする
  if( S[0] == '0'){
    vec.push_back(0);} //最初の連続する1の個数は０
  int head = 0;
  while(head < N){
    //headは0(または１）の連続する個数を数えるためのスタート位置
    int tail = head; int cnt = 0;
    while(tail < N && S[tail] == S[head]){ tail++; cnt++;}
    head = tail; vec.push_back(cnt);}

  if( S.back() == '0'){ vec.push_back(0);} //最初と最後は1の個数で終わりたい　
  //このときのvecの長さは必ず奇数
  
  vector<long long > sum((int) vec.size() + 1, 0);
  
  for(int i = 0; i <vec.size(); i++){
    sum[i + 1] = sum[i] + vec[i];}

long long ans = 0;

 for(int start = 0; start < (int)vec.size(); start++){
   long long res = 0; int j = start;
   if( j % 2 == 0){ //vec[start]は１の個数
    int goal = min( (int) vec.size() - 1 , j + 2 * K);
    res = sum[goal + 1] - sum[j];}
   
   else{
     // vec[start]は0の個数
     int goal = min((int) vec.size() - 1 , j + 2 * K - 1);
     res = sum[goal + 1] - sum[j - 1]; }
   
   ans = max( ans , res);
 }
  
  cout << ans << endl; return 0;}

Measured memory_bytes: 1656
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

const int MOD = 1000000007;

vector<long long> fact_inv, inv, Com;

/*  init_nCk :二項係数のための前処理
    計算量:O(n)
*/
void init_nCk(int n, int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
    Com.resize(SIZE + 5);
    Com[0] = 1;
    for (int i = 1; i < SIZE + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int k) {
    assert(!(k < 0));
    return Com[k];
}

long long modPow(int i, int p) {
    if(p == 0) {
        return 1;
    }
    long long ret;
    if(p % 2 == 1) {
        ret = i * modPow(i, p-1);
    } else {
        long long mp = modPow(i, p/2); 
        ret = mp * mp;
    } 
    return ret % MOD;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    auto total = modPow(2, n);

    init_nCk(n, max(a, b));
    auto c1 = nCk(a);
    auto c2 = nCk(b);

    if(total <= c1) {
        total += MOD;
    }
    total -= c1;

    if(total <= c2) {
        total += MOD;
    }
    total -= c2;
    cout << total - 1<< endl;

    return 0;
}



Measured memory_bytes: 7580
package main
import "fmt"
import "unicode/utf8"
import "strconv"
func main(){
    // Your code here!
    var n, m int
    fmt.Scan(&n, &m)
    t := make([][]int, m)
    var t1, t2 int
    for i := 0; i < m; i++ {
         fmt.Scan(&t1, &t2)
         t[i] = []int{t1, t2}
    }
    // fmt.Println(n)
    // fmt.Println(t)
    
    var ss string
    for i := 0; i <= 999; i++{
        ss = strconv.Itoa(i)
        //fmt.Println(utf8.RuneCountInString(ss))
        if utf8.RuneCountInString(ss) != n{
            continue
        }
        //println(string(ss[0]))
        var f bool
        f = true
        for k := 0; k < len(t); k++{
            //println(string(ss[t[k][0]-1]), t[k][1])
            if string(ss[t[k][0]-1]) != strconv.Itoa(t[k][1]){
                f = false
            }
        }
        if f == true{
            fmt.Println(ss)
            return
        }
    }
    fmt.Println("-1")
}


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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }



int main() {
    int N, M = 10;
    cin >> N;
    vector<vector<int>> F(N,vector<int>(10,0));
    REP(i,N) REP(j,10) cin >> F[i][j];
    vector<vector<int>> P(N,vector<int>(11,0));
    REP(i,N) REP(j,11) cin >> P[i][j];
    
    ll ans = -1e+16;
    vector<int> S;
    for ( int bit = 1; bit < (1<<M); ++bit){
        S.clear();
        for ( int i = 0; i < M; ++i) if ( bit & (1<<i) ) S.push_back(i);
        
        ll ans_sub = 0;
        for ( int i = 0; i < N; ++i){
            int num = 0;
            for ( auto a: S){
                num = num + F[i][a];
            }
            /*for ( int j = 0; j < S.size(); ++j){
                num = num + F[i][S[j]];
            }*/
            ans_sub = ans_sub + P[i][num];
        }
        if ( ans_sub > ans ) ans = ans_sub;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

constexpr int64_t mod = 1000000007;

int64_t power(int64_t n, int64_t k) {
  if (k == 0) return 1;
  int64_t res = power(n * n % mod, k / 2);
  if (k % 2) {
    res = res * n % mod;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  map<pair<int64_t, int64_t>, int64_t> m;
  for (int i = 0; i < n; i++) {
    int64_t a, b, d;
    cin >> a >> b;
    if (a == 0 and b == 0) {
      m[make_pair(0, 0)]++;
      continue;
    }
    d = gcd(abs(a), abs(b));
    a /= d;
    b /= d;
    if (a < 0 or (a == 0 and b < 0)) {
      a = -a;
      b = -b;
    }
    m[make_pair(a, b)]++;
    auto x = make_pair(b, -a);
    if (x.first < 0 or (x.first == 0 and x.second < 0)) {
      x.first = -x.first;
      x.second = -x.second;
    }
    m[x] += 0;
  }
  int64_t ans = 1;
  for (auto x : m) {
    auto y = make_pair(x.first.second, -x.first.first);
    if (y.first < 0 or (y.first == 0 and y.second < 0)) {
      y.first = -y.first;
      y.second = -y.second;
    }
    if (x.first >= y) continue;
    ans *= (power(2, m[x.first]) + power(2, m[y]) + mod - 1) % mod;
    ans %= mod;
  }
  cout << (ans + mod - 1 + m[make_pair(0, 0)]) % mod << endl;
}


Measured memory_bytes: 28468
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

void warshall_floyd(int V, vector< vector<long long> > &d) {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {

    int H, W;
    vector< vector<long long> > c(10, vector<long long>(10, 0));
    cin >> H >> W;
    int A[H][W];
    rep(i,10) rep(j,10) cin >> c[i][j];
    rep(i,H) rep(j,W) cin >> A[i][j];

    warshall_floyd(10, c);
    long long ans = 0;
    rep(i,H) rep(j,W) {
        if (A[i][j] >= 0) ans += c[A[i][j]][1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

long long n, m, ta = 0, mu = 0;
long long a[100000], b[100000];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ta += a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		mu += b[i];
	}
	cout << ta * mu << endl;
}


Measured memory_bytes: 4652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#define N 1000005
#define LL long long
#define mod 19260817
using namespace std;
inline int read(){
	int rtn=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))rtn=(rtn<<1)+(rtn<<3)+ch-'0',ch=getchar();
	return rtn*f;
}
int a[100010],b[100010],c[100010];
LL g[100010],f[100010],h[100010];
int main(){
	int n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)b[i]=read();
	for(int i=1;i<=n;i++)c[i]=read();
	sort(a+1,a+1+n);sort(b+1,b+1+n);sort(c+1,c+1+n);
	for(int i=1;i<=n;i++)g[i]=i;
	for(int i=1;i<=n;i++){int p=lower_bound(a+1,a+1+n,b[i])-a;f[i]=g[p-1];}
	for(int i=1;i<=n;i++)f[i]+=f[i-1];
	for(int i=1;i<=n;i++){int p=lower_bound(b+1,b+1+n,c[i])-b;h[i]=f[p-1];}
	for(int i=1;i<=n;i++)h[i]+=h[i-1];
	printf("%lld",h[n]);
	return 0;
}

Measured memory_bytes: 3712
//B - Harshad Number: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string n;
    int num, soma = 0;
    cin >> n;
    for(auto x : n) soma += x - '0';
    num = stoi(n);
    if(num % soma == 0) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
import math
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
b = [0]*(N+1)
a = [0] + a
for i in range(N, 0, -1):
  tmp = 0
  for j in range(1, N//i+1):
    tmp += b[i*j]
  tmp %= 2
  if a[i] == tmp:
    continue
  elif a[i] == 1 and tmp == 0:
    b[i] += 1
  elif a[i] == 0 and tmp == 1:
    b[i] += 1
  
M = 0
for i in range(1, N+1):
  if b[i] == 1:
    M += 1
print(M)
for i in range(1, N+1):
  if b[i] == 1:
    print(i, end=" ")

Measured memory_bytes: 67048
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 A, B;

int msb(i64 v)
{
	for (int i = 60; i >= 0; --i) {
		if ((v >> i) & 1) return i;
	}
	return -1;
}

i64 solve(i64 A, i64 B)
{
	if (A > B) return 0;
	if (A == B) return 1;

	for (int i = 60; i >= 0; --i) {
		if (((A >> i) & 1) != ((B >> i) & 1)) {
			i64 ans = 0;

			i64 Alo = A ^ ((A >> i) << i);
			i64 Blo = B ^ ((B >> i) << i);
			i64 tmp = (1LL << i) - Alo;
			int m = msb(Blo);
			if (m >= 0) tmp += 1LL << (m + 1);
			else tmp += 1;

			tmp = min(tmp, 1LL << i);

			tmp += solve(Alo, (1LL << i) - 1);
			return tmp;
		}
	}

	return 0;
}

int main()
{
	scanf("%lld%lld", &A, &B);
	printf("%lld\n", solve(A, B));

	return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int k, a, b; scanf("%d%d%d", &k, &a, &b);
  if (a <= b/k*k) puts("OK");
  else puts("NG");
  
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3708
//int64_t a;
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  int num=c;
  rep(i,10){
    num = a* num-b;
    cout<<num<<endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
long long a, b, c, d;
int n;
int main(){
    scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    a = b-a;
    n--;
    int i;
    for(i=0;i<=n;i++){
        long long t1 = (-d) * i + c * (n-i), t2 = (-c) * i + d * (n-i);
        if(t1 <= a && a <= t2){
            printf("YES\n");
            return 0;
        }
        if(t2 <= a && a <= t1){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
}

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

using namespace std;

#define pb push_back

const int N = 2e5 + 5;
int n, m, deg[N][2];
string s;
vector<int> gr[N], vec;
bool in[N];

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> s; s = '*' + s;
    for (int i = 1; i <= m; ++i) {
        int u, v; cin >> u >> v;
        gr[u].pb(v); gr[v].pb(u);
        deg[u][ s[v] - 'A' ] ++;
        deg[v][ s[u] - 'A' ] ++;
    }

    for (int u = 1; u <= n; ++u) if (!deg[u][0] || !deg[u][1]) in[u] = 1, vec.pb(u);

    for (int i = 0; i < vec.size(); ++i) {
        int u = vec[i];
        for (int v : gr[u]) {
            deg[v][ s[u] - 'A' ] --;
            if ( (!deg[v][0] || !deg[v][1]) && !in[v]) in[v] = 1, vec.pb(v);
        }
    }

    if (vec.size() == n) cout << "No";
    else cout << "Yes";

    return 0;
}


Measured memory_bytes: 13456
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

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

	int32_t res = 0;
	for (int32_t i = 0; i < N; i++) {
		res += 800;
	}
	res -= (N / 15) * 200;
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
//0011 Drawing Lots
//¢íÉ­¶ðø±¤I
//cüÌ{wA¡{Ì{hª^¦çêA
//ã©çÉhÂÌ¡üÌêª^¦çê½Æ«A±Ì¡üðÊßµ½Æ«ÌcüÌÔð¦æ
//È¨¡üÌîñÍA¡üªcüÌÊua,bÆÂÈªÁÄ¢éÆ·éÆA"a,b"Å\³êé
//w <= 30, h <= 30ª½³êéÆ·é

#include<iostream>
#include<algorithm>
using namespace std;

int main(void)
{
	const int N = 30;
	int w, h;
	int i;
	int a, b;

	int amida[N+1];	//âèÍ1©çnßÄ¢é©ç í¹é©@0ÈñÄÈ©Á½

	cin >> w >> h;

	//¡üªÈ¢Æ«Ìóµ
	for(i = 1; i <= w; i++)
		amida[i] = i;

	for(i = 0; i < h; i++)
	{
		//','ª´êÄ¢éÌÅòÎµÜµå¤
		char dummy;
		cin >> a >> dummy >> b;
		//¡üª éÆA½ÎÉÈèÜ·
		swap(amida[a], amida[b]);
	}
	
	for(i = 1; i <= w; i++)
	{
		cout << amida[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int gcd(int x,int y){
    if (x < y) {
        int tmp = x;
        x = y;
        y = tmp;
    }
    while (y > 0) {
        int tmp = x;
        x = y;
        y = tmp % y;
    }
    return x;
}

long lcm(int a,int b){
    return (long) a * b / gcd(a,b);
}

int main(void){
    int A,B;
    scanf("%d %d",&A,&B);

    long ans = lcm(A,B);
    printf("%ld\n",ans);

    return 0;
}


Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0]*(10**6+1)
    for a in A:
        B[a] += 1

    for i in range(1, 10**6):
        if not B[i]:
            continue
        j = 2*i
        while j <= 10**6:
            B[j] += 1
            j += i
    ans = 0
    for a in A:
        if B[a] <= 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95712
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int k = in.nextInt();
		k-=1;
		int [] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		int max = Integer.MAX_VALUE;
		for (int i = 0; i < n-k; i++) {
			max = Math.min(max, a[i+k] - a[i]);
		}
		out.println(max);
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}

Measured memory_bytes: 36272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()	
{
	int n;
	string s;
	set<string>S;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		S.insert(s);
	}
	if(S.size()==3)cout<<"Three"<<endl;
	else cout<<"Four"<<endl;
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

long long int a[90];
int n;
int main(){
	cin >> n;
	a[0]=2;
	a[1]=1;
	for(int i=2;i<=n;i++){
		a[i]=a[i-1]+a[i-2];
	}
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int card[4][13];
  int i,j,n,k,c,a;
  char b;
  
 for(i=0;i<4;i++){
          for(j=0;j<13;j++){
                   card[i][j]=0;
                            }
                  }
  
 scanf("%d",&n);

 for(k=0;k<=n;k++){ 
               scanf("%d",&a);
               scanf("%c %d",&b,&c);
               if(b=='S')i=0;
               if(b=='H')i=1;
               if(b=='C')i=2;
               if(b=='D')i=3;
               
               card[i][c-1]=1;
                  }

 for(i=0;i<4;i++){
                  for(j=0;j<13;j++){
                                    if(card[i][j]==0){
                                                      if(i==0)printf("S %d\n",j+1);
                                                      if(i==1)printf("H %d\n",j+1);
                                                      if(i==2)printf("C %d\n",j+1);
                                                      if(i==3)printf("D %d\n",j+1);
                                                      } 
                                    }
                 }

return 0;
}





Measured memory_bytes: 2040
import java.io.*;
import java.util.*;

public class Main {
	public static void main (String args[]){
		Scanner sc=new Scanner(new InputStreamReader(System.in));
		int i=0,x;
		while(true){
			i++;
			x=sc.nextInt();
			if(x==0) break;
			System.out.println("Case "+i+": "+x);
		}
	sc.close();
	}
}

Measured memory_bytes: 41272
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	k := nextInt()

	l := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	i, n := 0, 0
	for len(l) > 0 && i < k {
		n, l = l[0], l[1:]
		d := n % 10
		switch d {
		case 0:
			l = append(l, n*10+d, n*10+d+1)
		case 9:
			l = append(l, n*10+d-1, n*10+d)
		default:
			l = append(l, n*10+d-1, n*10+d, n*10+d+1)
		}
		i++
	}
	fmt.Fprintln(out, n)
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func min(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] < ret {
			ret = a[i]
		}
	}
	return ret
}
func max(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] > ret {
			ret = a[i]
		}
	}
	return ret
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 8560
#include <stdio.h>

int cnt;

void insertionSort(int A[], int n, int g);
void shellSort(int A[], int n);

int n;
int A[1000000];

int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%d", A+i);
  shellSort(A, n);
  printf("%d\n", cnt);
  for(i = 0; i < n; ++i) printf("%d\n", A[i]);
  return 0;
}

void insertionSort(int A[], int n, int g) {
  int tmp;
  int i, j;
  for(i = g; i < n; ++i) {
    tmp = A[i];
    j = i-g;
    while(j >= 0 && A[j] > tmp) {
      A[j+g] = A[j];
      j -= g;
      ++cnt;
    }
    A[j+g] = tmp;
  }
}

void shellSort(int A[], int n) {
  int m = 0;
  int G[100];
  int i;
  G[0] = 1;
  for(m = 1; 3*G[m-1]+1 <= n; ++m) G[m] = 3*G[m-1]+1;
  printf("%d\n", m);
  cnt = 0;
  for(i = m-1; i >= 0; --i) {
    printf("%d%c", G[i], " \n"[i==0]);
    insertionSort(A, n, G[i]);
  }
}




Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}

struct Node{
	int innum;
	int year;
	int pref;
	ll number;
};

int main() {
	int N,M; cin>>N>>M;
	Node City[M];
	for(int i=0; i<M; i++) {
		int P,Y; cin>>P>>Y;
		City[i].innum=i;
		City[i].year=Y;
		City[i].pref=P;
		City[i].number=(ll)P*1000000;
	}
	sort(City,City+M,[](Node a, Node b){return a.year<b.year;});

	int num[N+1]; for(int i=0; i<N+1; i++) num[i]=0;
	for(int i=0; i<M; i++) {
		num[City[i].pref]++;
		City[i].number+=num[City[i].pref];
	}
	sort(City,City+M, [](Node a, Node b){return a.innum<b.innum;});

	for(int i=0; i<M; i++) printf("%012lld\n",City[i].number);
}


Measured memory_bytes: 4224
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer player = 0;
		List<List<String>> s = new ArrayList<>();
		s.add(Arrays.asList(sc.next().split("")));
		s.add(Arrays.asList(sc.next().split("")));
		s.add(Arrays.asList(sc.next().split("")));
		Integer[] currentPos = { 0, 0, 0 };
		
		while (true) {
			if (currentPos[player].equals(s.get(player).size())) {
				if (player == 0) {
					System.out.println("A");
				} else if (player == 1) {
					System.out.println("B");
				} else if (player == 2) {
					System.out.println("C");
				}
				return;
			}
			String next = s.get(player).get(currentPos[player]);
			currentPos[player]++;
			if (next.equals("a")) {
				player = 0;
			} else if (next.equals("b")) {
				player = 1;
			} else if (next.equals("c")) {
				player = 2;
			}
		}
	}
}


Measured memory_bytes: 9940
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        Console.ReadLine();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int min = int.MaxValue;
        
        for (int i = -100; i <= 100; i++)
        {
            int sum = 0;
            foreach (int n in a)
            {
                sum += (i - n) * (i - n);
            }
            min = Math.Min(min, sum);
        }
        Console.WriteLine(min);
    }
}

Measured memory_bytes: 13268
#include <iostream>
//#include <string>
#include <vector>
//#include <math.h>
#include <algorithm>
#include <numeric>

int iabs(int x)
{
	x = (x >= 0) ? x : -x;
	return x;
}

int main()
{
	int N = 0;
	std::cin >> N;

	std::vector<int> W(N);


	for (int i = 0l; i < N; i++){
		std::cin >> W[i];
	}

	int total = std::accumulate(W.begin(), W.end(), 0);
	int sum = W[0];
	int ans = -total;
	for (int t = 0; t < N; t++){
		sum += W[t];
		int chk = ans + 2 * W[t];

		if (iabs(ans) < iabs(chk)) break;
		ans += 2 * W[t];
	}
	std::cout << iabs(ans) << std::endl;

	return 0;
}

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

int main() {
    ll N; cin >> N;
    if(N%2 == 1){
        cout << 0 << endl;
        return 0;
    }
    string s = to_string(N);
    int ss = s.size();
    
    ll ans = 0;
    ll now5 = 10;
    while(now5 <= N){
        ll x = N / now5;
        ans += x;
        now5 *= 5;
    }

    cout << ans << endl;

    return 0;
}

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

#define ll long long
#define uint unsigned int
#define vi vector<int>
#define pii pair<int,int>

#define for0(i,n) for(int i=0; i<(n); i++)
#define for1(i,n) for(int i=1; i<=(n); i++)
#define from(i,a,b) for(int i=(a); i<=(b); i++)
#define forr(i,a,b) for(int i=(a); i>=(b); i--)

#define PB push_back
#define MP make_pair
#define FI first
#define SE second

#define all(x) (x).begin(),(x).end()
#define len(x) (int)(x).size()

#define safe_map unordered_map<long long, int, custom_hash>

#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main

void amax(int& x, int y){if(x<y)x=y;}
void amin(int& x, int y){if(x>y)x=y;}
int gcd(int a, int b){if(b){return gcd(b,a%b);}return a;}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {  // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};








void solve(){
int n; cin>>n;
    if(n<600)
        n=8;
    else if(n<800)
        n=7;
    else if(n<1000)
        n=6;
    else if(n<1200)
        n=5;
    else if(n<1400)
        n=4;
    else if(n<1600)
        n=3;
    else if(n<1800)
        n=2;
    else
        n=1;
    cout << n << '\n';
}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1; //cin >> t;
    while(t--) solve();
}



Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		int a = 0;
		String operator = "";
		int b = 0;

		// テキスト入力
		Scanner sc = new Scanner(System.in);
		String out = "";

		// 演算子の変数に入っている中身で場合わけ
		while (true) {

			//
			while (sc.hasNext()) {
				a = sc.nextInt();
				operator = sc.next();
				b = sc.nextInt();
				break;
			}

			if (operator.equals("?")) {
				break;

			} else if (operator.equals("/")) {
				out = out + a / b + "\n";

			} else if (operator.equals("*")) {
				out = out + a * b + "\n";

			} else if (operator.equals("+")) {
				out = out + (a + b) + "\n";

			} else if (operator.equals("-")) {
				out = out + (a - b) + "\n";
			}
		}
		// 出力
		System.out.print(out);
	}
}

Measured memory_bytes: 18100
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cstdio>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;

class DisjointSet {
    VI parent;
    VI groupSize;
public:
    DisjointSet(int treeSize) {
        parent = move(VI(treeSize, -1));
        groupSize = move(VI(treeSize, 1));
    }

    int groupSizeOfN(int n) {
        return groupSize[findParent(n)];
    }

    int findParent(int n) {
        if (parent[n] == -1) {
            return n;
        }

        return parent[n] = findParent(parent[n]);
    }

    void unionGroup(int a, int b) {
        a = findParent(a);
        b = findParent(b);

        if (a != b) {
            if (groupSize[a] < groupSize[b]) {
                swap(a, b);
            }

            groupSize[a] += groupSize[b];
            parent[b] = a;
        }
    }
};

int main() {
    int N;
    int M;
    int K;
    scanf("%d %d %d", &N, &M, &K);

    DisjointSet ds(N);
    vector<vector <int>> blkCand(N); // check if block count is in the group
    vector <int> friCnt(N);

    for (int i = 0; i < M; ++i) {
        int a;
        int b;
        scanf("%d %d", &a, &b);
        --a;
        --b;
        ds.unionGroup(a, b);
        ++friCnt[a];
        ++friCnt[b];
    }

    for (int i = 0; i < K; ++i) {
        int a;
        int b;
        scanf("%d %d", &a, &b);
        --a;
        --b;
        blkCand[a].push_back(b);
        blkCand[b].push_back(a);
    }

    string str;
    for (int i = 0; i < N; ++i) {
        int groupCount = ds.groupSizeOfN(i) - friCnt[i] - 1;
        int groupParent = ds.findParent(i);

        for (int j = 0; j < blkCand[i].size(); ++j) {
            int cand = blkCand[i][j];
            if (ds.findParent(cand) == groupParent) {
                --groupCount;
            }
        }

        printf("%s%d", str.c_str(), groupCount);
        str = " ";
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 7168
#include <stdio.h>
int main(void){
int i;
char a[4] = {};
for (i = 0;i < 4;i++)
{
  scanf("%s",&a[i]);
}
if (a[1] == a[2])
{
  if (a[0] == a[1] || a[2] == a[3])
  {
    printf("Yes");
  }else{printf("No");}
}else
{printf("No");}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> V;
const long long MOD=1000000007LL;
const long long INFL=1LL << 60;
const int INF=1<<29;


int main() {
    int N;
    cin >>N;
    V d(N);
    for(int i=0;i<N;i++){
        cin >>d.at(i);
    }
    sort(d.begin(),d.end());
    ll ans=d.at(N/2)-d.at(N/2-1);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17
int score[MAX2];
void dfs(Graph &tree,ll v,int p,int s){
    score[v]+=s;
    for(auto node:tree[v]){
        if(node==p)continue;
        dfs(tree,node,v,score[v]);
    }
}
int main(){
    memset(score,0,sizeof(score));
    int n,q;
    cin>>n>>q;
    Graph tree(n);
    rep(i,n-1){
        int a,b;cin>>a>>b;
        a--;b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    rep(i,q){
        int p,x;cin>>p>>x;
        p--;
        score[p]+=x;
    }
    dfs(tree,0,0,0);
    rep(i,n){
        cout<<score[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 27404
#include "bits/stdc++.h"
using namespace std;
const int N = 5e5 + 5;
const int C = 27;
const int LN = 19;
int n;
char str[N];
int dp[N][C];
int nxt[N][C];
int q;
int l , r;
int arr[N];
int bin[LN][N];
int main(){
    scanf("%s" , str + 1);
    n = strlen(str + 1);
    memset(dp , -1 , sizeof(dp));
    memset(nxt , -1 , sizeof(nxt));
    for(int i = n ; i >= 1 ; --i){
        int c = str[i] - 'a';
        dp[i][c] = i;
        for(int j = c + 1 ; j <= 26 ; ++j){
            dp[i][j] = nxt[dp[i][j - 1] + 1][j - 1];
        }
        for(int j = 0 ; j < C ; ++j){
            if(dp[i][j] == -1){
                nxt[i][j] = nxt[dp[i][26] + 1][j];
            }
            else{
                nxt[i][j] = dp[i][j];
            }
        }
    }
    for(int i = 0 ; i <= n + 2 ; ++i){
        if(dp[i][26] == -1){
            arr[i] = n + 2;
        }
        else{
            arr[i] = dp[i][26] + 1;
        }
    }
    for(int i = 0 ; i <= n + 2 ; ++i){
        bin[0][i] = arr[i];
    }
    for(int i = 1 ; i < LN ; ++i){
        for(int j = 0 ; j <= n + 2 ; ++j){
            bin[i][j] = bin[i - 1][bin[i - 1][j]];
        }
    }
    scanf("%d" , &q);
    while(q--){
        scanf("%d %d" , &l , &r);
        for(int i = LN - 1 ; i >= 0 ; --i){
            if(bin[i][l] <= r){
                l = bin[i][l];
            }
        }
        puts((arr[l] == r + 1) ? "Yes" : "No");
    }
}

Measured memory_bytes: 145664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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()
{
  ll N; cin>>N;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  //まずは合計
  ll sum=0; rep(i,N) sum+=A[i]; sum/=2;
  
  
  //x0求める
  ll ssum=0; for(int i=0;i<N;i+=2) ssum+=A[i];
  ll x0=ssum-sum;
  
  //x求める
  vector<ll> x(N); x[0]=x0;
  for(int i=1;i<N;i++) x[i]=A[i-1]-x[i-1];
  
  rep(i,N){
    if(i!=0) cout<<" ";
    cout<<x[i]*2;
  }
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 4832
#include<stdio.h>
int main(){
  int a,s;
  char z[15],x[15],c[15];
  scanf("%s",z);
  scanf("%s",x);
  scanf("%d%d",&a,&s);
  scanf("%s",c);
  if(!strcmp(z,c)){
    printf("%d %d",a-1,s);
  }
  else{
    printf("%d %d",a,s-1);
  }
}
  

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    int mid = d.size() / 2;
    cout << d[mid] - d[mid - 1] << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void chmax(int&a,int b)
{
	a=max(a,b);
}
main()
{
	int n;
	while(cin>>n,n)
	{
		vector<vector<int> >dp(n+2,vector<int>(5e2+1,-1));
		dp[0][0]=0;
		for(int count=0;count<n;count++)
		{
			int p;cin>>p;
			int oturi=p%1000?1000-p%1000:0;
			for(int k=n;k>=0;k--)
			{
				for(int j=5e2;j>=0;j--)
				{
					if(dp[k][j]<0)continue;
					chmax(dp[k+(dp[k][j]+oturi>=500)][j+(p+999)/1000],
							dp[k][j]+oturi-(dp[k][j]+oturi>=500?500:0));
				}
			}
		}
		int f=0;
		for(int k=n;!f&&k>=0;k--)
		{
			for(int i=0;!f&&i<=5e2;i++)
			{
				if(dp[k][i]>=0)
				{
					cout<<k<<" "<<i*1000-dp[k][i]-k*500<<endl;
					f=1;
				}
			}
		}
	}
}



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

const long long inf = 0x3f3f3f3f;
int main(){
	
	int n,m,x;
	cin>>n>>m>>x;
	int ans=inf;
	int dat[n+1][m+1+1];
	for(int i=0;i<n;i++){
		cin>>dat[i][0];
		for(int j=1;j<=m;j++) cin>>dat[i][j];
	}
	for(int i=0;i<=(1<<n)-1;i++){
		int e[m+1+1]={0};
		int foo=0;
		for(int j=0;j<n;j++){
			if(i>>j&1){
				for(int k=1;k<=m;k++){
					e[k]+=dat[j][k];
				}
				foo+=dat[j][0];
			}
		}
		bool ok=true;
		for(int i=1;i<=m;i++) if(e[i]<x) ok=false;
		if(ok) ans=min(ans,foo);
	}
	cout<<(ans==inf?-1:ans)<<endl;
	return 0;
}

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

int main(){
  int N,M,X;
  cin>>N>>M>>X;
  int hon[N][M+1];
  rep(i,N){
    rep(j,M+1)
      cin>>hon[i][j];
  }
  int ans=1e9;
  
  rep(s,1<<N){
    int cost=0;
    //int vec[M];
    vector<int> vec(M);
    rep(i,N){
      if(s>>i & 1){
        cost+=hon[i][0];
        rep(j,M)  vec[j]+=hon[i][j+1];
      }
    }
    bool ok=true;
    rep(j,M){
      if(vec[j]<X) ok=false;
    }
    
    if(ok) ans=min(ans, cost);
  }
  if(ans==1e9) cout<<-1;
  else cout<<ans;
    
          
        
        
  
  
}

Measured memory_bytes: 3636
#include<iostream>
    #include<vector>
    #include<iterator>
    #include <algorithm>

    using namespace std;

    int main(){
        int a, b, k; cin >> a >> b >> k;
        for (int i = 100; i >= 1; i--){
            if (a%i == 0 && b%i == 0){
                k--;
                if (k == 0){
                    cout << i << endl;
                    break;
                }
            }
        }

        
        return 0;
    }

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        UnionFindTree uft = new UnionFindTree(n);
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            sc.nextInt();
            uft.unite(a, b);
        }
        System.out.println(uft.getCouunt());
    }
    
    static class UnionFindTree {
        int[] parents;
        
        public UnionFindTree(int n) {
            parents = new int[n];
            for (int i = 0; i < n; i++) {
                parents[i] = i;
            }
        }
        
        public int find(int x) {
            if (parents[x] == x) {
                return x;
            } else {
                return parents[x] = find(parents[x]);
            }
        }
        
        public void unite(int x, int y) {
            int xx = find(x);
            int yy = find(y);
            parents[xx] = yy;
        }
        
        public int getCouunt() {
            HashSet<Integer> set = new HashSet<>();
            for (int i = 0; i < parents.length; i++) {
                set.add(find(i));
            }
            return set.size();
        }
    }
}

Measured memory_bytes: 91340