akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <(n); i++)
#define rep2(i,l,r) for (int i=(l); i<(r); i++)
#include <bits/stdc++.h>
//~ #include <atcoder/all>
using namespace std;
using ll = long long;
//~ using P = pair<int, int>;

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 A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
    //~ if (!bit) break;
//~ }
int next_combination(int sub){
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a){
    if(a==2) return true;
    if(a<=1 || a%2==0) return false;
  
    for(int i=3; i*i<=a; i+=2){
        if(a%i==0) return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> a;
// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (a[index] >= key) return true;
    else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

long long modpow(long long a, long long n, long long mod){
    long long res = 1;
    while(n>0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    
    int X[110];
    rep(i, N) {
        cin >> X[i];
    }
    
    int ans=1e9;
    for(int i=1; i<=100; i++) {
        int dist=0;
        rep(j ,N) {
            int x = abs(X[j]-i);
            dist += x*x;
        }
        chmin(ans, dist);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int main(){
    long long n,ans=1e17;
    cin>>n;
    for(long long i=1;i*i<=n+1;i++){
        if(n%i==0){
            ans=min(ans,i-1+n/i-1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N, K = input().split()
int_N = int(N)
arr = list(input().split())
max_num = pow(10,6)

for i in range(int_N, max_num):
    li = list(set(list(str(i))))
    for j in range(len(li)):
        if li[j] in arr:
            break
    else:
        print(i)
        exit()

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

int main() {
  ll n, m, d;
  cin >> n >> m >> d;

  double ans;
  if (d == 0) {
    ans = 1.0 / (double)n;
  }
  else {
    ans = (double)(2 * n - 2 * d) / (double)(n * n);
  }

  ans *= (double)(m - 1);
  cout << fixed << setprecision(15);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string a,b,c;
  cin >> a >> b >> c;

  cout << "A" << b[0] << "C" << '\n';
  return 0;
}


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

using namespace std;

typedef long long ll;
const int Max_N = 200000;
ll N;
std::vector<int> A(Max_N);
std::vector<int> B(Max_N);


int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
    B[i]=A[i];
  }
  sort(A.begin(),A.end(),std::greater<int>());
  for(int i=0;i<N;i++){
    if(B[i]==A[0]) cout << A[1] << endl;
    else cout << A[0] << endl;
  }
}


Measured memory_bytes: 3200
#include <iostream>

int sosujudge(int X);

using namespace std;

int main(){
	int X;
	int i;

	cin>>X;

	if(X==2){
		cout<<X<<endl;
		exit(0);
	}
	if( X%2 == 0 ) X++;

	while(!sosujudge(X)) X+=2;

	cout<<X<<endl;
	return 0;
}
	
int sosujudge(int X){
	int i=3;

	while( X%i != 0) i+=2;

	if(X==i){
		return 1;
	}
	return 0;
}




Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		a, b int
		op   string
	)
	for {
		fmt.Scan(&a, &op, &b)
		if op == "?" {
			break
		}
		switch op {
		case "+":
			fmt.Println(a + b)
		case "-":
			fmt.Println(a - b)
		case "*":
			fmt.Println(a * b)
		case "/":
			fmt.Println(a / b)
		}
	}
}



Measured memory_bytes: 1128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N;
  cin>>N;
  int cnt(0);
  for (int i(1);i<=N;i++){
    string s = to_string(i);
    if (s.size()%2==1) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define elif else if
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

// Debug
#define debug(x) cerr << #x << " = " << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

inline ll mod_pow(ll a, ll b) {
    if (b == 0) return 1LL;
    if (b & 1) return (a * mod_pow(a, b - 1)) % MOD;
    ll half = mod_pow(a, b / 2);
    return half * half % MOD;
}

def mod_comb(ll n, ll r) {
    r = min(r, n - r);
    ll sup = 1, sub = 1;
    rep(i, r) {
        sup *= n - i, sub *= i + 1;
        sup %= MOD, sub %= MOD;
    }
    return sup * mod_pow(sub, MOD - 2) % MOD;
}

signed main() {
    ll N, M, S = 2;
    double P;
    cin >> N >> M;
    P = sqrt(M);
    ll A[int(P) + 1];
    while (M != 1) {
        A[S] = 0;
        if (M % S == 0) {
            while (M % S == 0) {
                M /= S;
                A[S]++;
            }
        } else if (S > P) {
            A[S]++;
            S++;
            break;
        }
        S++;
    }
    ll ANS = 1;
    inc(i, 2, S - 1) if (A[i]) {
        ANS *= mod_comb(N + A[i] - 1, N - 1);
        ANS %= MOD;
    }
    cout << ANS << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


Measured memory_bytes: 512
import sys
# from math import sqrt
# try not to use sqrt because it carries some error
si = sys.stdin.readline


def main():
    [n, d] = [int(e) for e in si().split()]
    cnt = 0
    # coords = set()
    for _ in range(n):
        [x, y] = [int(e) for e in si().split()]
        if x*x+y*y <= d*d:
            # coords.add(tuple([x, y]))
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    string front, back, tmp;
    tmp = S;
    for(int i = 0; i < (S.size() - 1) / 2; i++) front += S[i];
    for(int i = (S.size() + 2) / 2; i < S.size(); i++) back += S[i];
    reverse(front.begin(), front.end());
    reverse(back.begin(), back.end());
    reverse(tmp.begin(), tmp.end());
    for(int i = 0; i < S.size(); i++)
        if(S[i] != tmp[i]) {
            cout << "No";
            return 0;
        }
    for(int i = 0; i < (S.size() - 1) / 2; i++)
        if(S[i] != front[i]) {
            cout << "No";
            return 0;
        }
    for(int i = (S.size() + 2) / 2; i < S.size(); i++)
        if(S[i] != front[i - (S.size() + 2) / 2]) {
            cout << "No";
            return 0;
        }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main(){
	string S;
	cin >> S;
	int N = S.size();
	deque<char> D;
	for(int i = 0; i < N; i++){
		if(S[i] == '0' || S[i] == '1'){
			D.push_back(S[i]);
		}else{
			if(D.empty()){
				continue;
			}else{
				D.pop_back();
			}
		}
	}
	while(!D.empty()){
		cout << D.front();
		D.pop_front();
	}
}

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




int main()
{	
	ll n,k=0,ans=0;
	cin>>n;
	
ll a[n];
for(ll i=0;i<n;i++)
{
	cin>>a[i];
	if(i)
	if(a[i]<=a[i-1])k++;
	else k=0;
	ans=max(ans,k);
}
	
	cout<<ans;

		
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
 string T;
 int A;
 cin>> T;
  A=T.size();
  if(A!=1){
  if(T.at(0)=='?'){
    if(T.at(1)=='?'||T.at(1)=='D')
           T.at(0)='P';
  }
  if(T.at(0)=='?'&&T.at(1)=='P')
     T.at(0)='D'; 
 for(int i=1;i<A-1;i++){
   if(T.at(i)=='?'&&T.at(i-1)=='P')
     T.at(i)='D';
   if(T.at(i)=='?'){
     if(T.at(i+1)=='D'||T.at(i+1)=='?')
     T.at(i)='P';
   }
    if(T.at(i)=='?'&&T.at(i+1)=='P')
     T.at(i)='D';
   }
   if(T.at(A-1)=='?')
     T.at(A-1)='D';
  }
  if(A==1)
    T.at(0)='D';
 cout << T << endl;
}

Measured memory_bytes: 3752
#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;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
// const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

const int MAX = 1000010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// int main() {
//     // 前処理
//     COMinit();

//     // 計算例
//     cout << COM(100000, 50000) << endl;
// }

int x[60];

map<int,ll> dp[60][2510];


int main () {

    int n,a;cin>>n>>a;

    rep(i,n) cin>>x[i];

    dp[0][0][0]=1;

    ll ans=0;

    rep(i,n) {
        rep(j,2501) {
            for (auto it = dp[i][j].begin();it!=dp[i][j].end();it++) {
                dp[i+1][j][it->first]+=it->second;
                dp[i+1][j+x[i]][it->first+1]+=it->second;
            }
        }
    }

    rep(i,2501) {
        for (auto it = dp[n][i].begin();it!=dp[n][i].end();it++) {
            if ((it->first)==0) continue;
            if (i%(it->first)==0&&i/(it->first)==a) ans+=(it->second);
        }
    }

    cout<<ans<<endl;

}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())

l=[]
for i in range(M):
  l.append(list(map(int,input().split()))[1:])

p=list(map(int,input().split()))

ans=0
for i in range(2**N):
  isOK=True
  for j in range(M):
    stat=0
    for k in l[j]:
      k-=1
      if i&(1<<k):
        stat=(stat+1)%2
    if stat!=p[j]:
      isOK=False
  if isOK:
    ans+=1
print(ans)

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

#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<string>
#include<math.h>
#include<vector>

using namespace std;

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

#define fst first 
#define snd second

const int maxn=1500005,maxm=2100;
const double pi=acos(-1.0);
const ll mod=1000000007;

int n,m,q;

int main()
{
	ios_base::sync_with_stdio(false);
	int i,j,k,l;
	cin>>n>>m;
	if(n<m) cout<<"0\n";
	else cout<<"10\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	ll x,ans=0;cin>>x;
	ans+=x/11*2;
	x-=ans/2*11;
	if(x>6)ans+=2;
	else if(x!=0)ans++;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[10];
int main(){
	scanf("%s",s);
	int len=strlen(s);
	for(int i=1;i<len;i++){
		if(s[i]=='C'&&s[i-1]=='A') {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

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

int main() {
    
    
    while(1){
    string s;
    cin >> s;
    string sp1, sp2, spaf;
    int N ;
    cin >> N; 
    int n;
    int sookisa;
    sookisa = s.size();
 
    if(s == "-")break;

    for(int i = 0 ; i < N; i++){
        
        cin >> n;
        sp1 = s.substr(0, n);
        sp2 = s.substr(n, sookisa - n );
        s = sp2 + sp1;
    }
    cout << s <<  endl;
    }
return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
	int n,t;
	cin >> n >> t;
	vector<vector<int>> dp(n+1,vector<int>(t+1));
	vector<P> ab(n);
	for(int i = 0;i<n;i++)
	{
		cin >> ab[i].first >> ab[i].second;
	}
	sort(ab.begin(),ab.end(),[&](auto a,auto b){return a.first  < b.first ;});

	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<=t;j++)
		{
			if(j-ab[i].first>=0)dp[i+1][j] = max(dp[i][j],dp[i][j-ab[i].first]+ab[i].second);
			else dp[i+1][j] = dp[i][j];
		}
	}
	vector<int> mx(n+1);
	for(int i = n-1;i>0;i--)
	{
		mx[i] = max(mx[i+1],ab[i].second);
	}

	int ans = dp[n][t];
	//cout << ab[0].first << ' ' << ab[0].second << endl;
	//cout << dp[1][10] << endl;
	//cout << mx[1] << endl;
	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<t;j++)ans = max(ans,dp[i][j]+mx[i]);
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 38872
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;


int32_t main()
{
   
   
    crap;
    
     int n,a,b;
     cin>>n>>a>>b;
     int p = (a+b);
     int q = n/p;
     int s = n%p;
     int ans = a*q;

     ans+= min(a, s);
     cout<<ans<<endl;
}

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

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

    if (n == 1) {
        cout << "Hello World" << endl;
        return 0;
    }

    cin >> a >> b;
    cout << a + b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define ufor(i,l,r) for (int i=l;i<=r;i++)
#define MAXN 1000500
int a[MAXN];
int main()
{
	int n,k;
	scanf("%d%d",&k,&n);
	int ans=0;
	ufor (i,1,n)
	{
		scanf("%d",&a[i]);
		ans=max(ans,a[i]-a[i-1]);
	}
	ans=max(ans,k-a[n]+a[1]);
	printf("%d",k-ans);		
	return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<queue>
#include<cstdlib>
#include<map>
#define fs first
#define sc second
using namespace std;

typedef pair<int,int> P;
typedef pair<P,P> P2;


bool v[300][300];
int d[300][300][6];
int dx[7] = {0, 1, 1, 0, -1, -1, 0}; 
int dy[2][7] = { {1, 0, -1, -1, -1, 0, 0},
		{1, 1, 0, -1, 0, 1, 0} };
const int G = 150;

int main(){
  int sx,sy,gx,gy;
  int n,lx,ly,x,y;

  cin >> sx >> sy >> gx >> gy >> n;
  for(int i=0;i<300;i++)
    for(int j=0;j<300;j++){
      v[i][j] = false;
      for(int k=0;k<6;k++)d[i][j][k] = 100000000;
    }

  for(int i=0;i<n;i++){
    cin >> x >> y;
    v[y+G][x+G] = true;
  }
  cin >> lx >> ly;

  priority_queue<P2,vector<P2>, greater<P2> > q;
  d[sy+G][sx+G][0] = 0;
  q.push(P2(P(0,0),P(sy,sx)));

  int ans = -1;
  while(q.size()){
    P2 p = q.top(); q.pop();
    int s = p.fs.fs, t = p.fs.sc;
    y = p.sc.fs; x = p.sc.sc;

    if(y==gy && x==gx){
      ans = s;
      break;
    }

    int dir = abs(x*y*t)%6, tt = (t+1)%6;
    for(int i=0;i<7;i++){
      int ty = y+dy[x&1][i], tx = x+dx[i];
      if(ty<-ly || tx<-lx || ly<ty || lx<tx)continue;
      if(v[ty+G][tx+G])continue;

      if(dir == i){
	if(s<d[ty+G][tx+G][tt]){
	  d[ty+G][tx+G][tt] = s;
	  q.push(P2(P(s,tt),P(ty,tx)));
	}
      }else{
	if(s+1<d[ty+G][tx+G][tt]){
	  d[ty+G][tx+G][tt] = s+1;
	  q.push(P2(P(s+1,tt),P(ty,tx)));
	}
      }
    }
  }
  cout << ans << endl;
}

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

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node *treeMinimum(Node *x)
{
    while (x->left != NIL) {
        x = x->left;
    }
    return x;
}

Node *treeSuccessor(Node *x)
{
    if( x->right != NIL )
        return treeMinimum(x->right);
    Node *y = x->parent;
    while( y != NIL && x == y->right){
        x=y;
        y=y->parent;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y;
    Node *x;

    if( z->left==NIL || z->right==NIL )
        y=z;
    else
        y = treeSuccessor(z);

    if( y->left != NIL ){
        x=y->left;
    }else {
        x = y->right;
    }

    if( x != NIL ){
        x->parent = y->parent;
    }

    if( y->parent == NIL){
        root = x;
    }else {
        if( y == y->parent->left){
            y->parent->left = x;
        }else {
            y->parent->right = x;
        }
    }
    if ( y!=z ){
        z->key = y->key;
    }
    free(y);
}

Node *find( Node *u, int k )
{
    while( u != NIL && k != u->key ){
        if( k< u->key )
            u = u->left;
        else
            u = u->right;
    }
    return u;
}

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));

    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while( x!=NIL ){
        y = x;
        if( z->key < x->key ){
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if ( y ==NIL ){
        root = z;
    } else {
        if( z->key < y->key ){
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder( Node *u )
{
    if( u==NIL )
        return;
    inorder(u->left);
    printf( " %d", u->key );
    inorder(u->right);
}

void preorder( Node *u )
{
    if( u==NIL )
        return;
    printf( " %d", u->key );
    preorder( u->left );
    preorder( u->right );
}

int main()
{
    int n, i, x;
    string com;

    scanf( "%d", &n );

    for( i=0; i<n; i++ ){
        cin >> com;

        if( com == "insert" ){
            scanf( "%d", &x );
            insert(x);
        } else if ( com == "print" ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if( com == "find" ){
            scanf("%d", &x);
            Node *t = find(root,x);
            if( t!=NIL )
                cout << "yes\n";
            else
                cout << "no\n";
        } else if (com == "delete"){
            scanf("%d", &x);
            treeDelete(find(root,x));
        }
    }
    return 0;
}



Measured memory_bytes: 22004
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	int n; cin >> n;
	while (n--) {
		int a[3]; cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		if (a[0] == 0 || a[1] == 0 || a[2] == 0) cout << "NO" << endl;
		else cout << (a[2] * a[2] - a[1] * a[1] - a[0] * a[0] == 0 ? "YES" : "NO") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;
int cnt[2];

int main() {
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'm')cnt[0]++;
		else if (s[i] == 'e') {
			cnt[1]++;
			if (cnt[1] > cnt[0])break;
		}
		else {
			cnt[0]--;
			cnt[1]--;
			if (cnt[1] == 0 && cnt[0] == 0) {
				if (i != s.size() - 1)break;
				else {
					cout << "Cat" << endl;
					return 0;
				}
			}
			else if (cnt[1] < 0 || cnt[0] < 0)break;
		}
	}
	cout << "Rabbit" << endl;
}


Measured memory_bytes: 3188
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


x, y = map(int, input().split())
if (x + y) % 3 == 0:
    n = (x + y) // 3
    k = x - n
    print(cmb(n, k, mod) % (10**9 + 7))
else:
    print(0)

Measured memory_bytes: 122048
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#define REP(i,N) for(auto i = 0; i<N; i++)


#include <cmath>
using namespace std;

int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

long long dp[51][2600];
long long ndp[51][2600];


int main() {
    
    int N = in();
    int A = in();
    
    vector<int> X;
    
    for(auto i = 0; i<N; i++){
        X.push_back(in());
    }

    sort(X.begin(),X.end());
    
    for(auto i = 0; i<=N; i++){
            for(auto k = 0; k<=N*A; k++){
                dp[i][k] = 0;
                ndp[i][k] = 0;
        }
    }
    
    dp[N][X[N-1]] = 1;
    
    for (auto i = N-1; i >0; i--){
        dp[i][X[i-1]] += 1;
        for(auto j = 0; j<= A*N; j++){
            dp[i][j] += dp[i+1][j];
        }
    }
    
    long long max = *max_element(X.begin(), X.end());
    long long min = *min_element(X.begin(), X.end());
    
    
    long long ans = 0;
    ans += dp[1][A];
    
    for(auto n = 2; n<=N; n++){ /// n枚使うときの組み合わせを、n-1枚のときから求める。
        
        for(auto a = min*n; a <= max*n; a++){
            
            for(auto i = 1; i <=N; i++){
                ndp[i][a] = 0;

                for(auto j = i; j <=N -n+1; j++){
                    if(a-X[j-1] <= 0) break; // ソートしてあるので、これ以上のjは無駄。
                    ndp[i][a] += dp[j+1][a-X[j-1]];
                }
            }
        }
        
        for(auto i = 1; i<=N; i++){
            for(auto k = 0; k<= A*N; k++){
                dp[i][k] = ndp[i][k];
            }
        }
        
        ans += dp[1][A*n];
    }
    
    cout << ans << endl;
    
    return 0;
    
}



Measured memory_bytes: 2304
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  int answer=0;
  for(int i=0;i<1000;i++){
    int x[3]={i/100,(i%100)/10,i%10};
    int judge=0;
    int j=0;
    while(j<N&&judge<3){
      if(s[j]-'0'==x[judge]) judge++;
      j++;
    }
    if(judge==3) answer++;
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0;
    for(int i = 1; i < N; i++){
        if(A[i] < A[i - 1]){
            ans += A[i - 1] - A[i];
            A[i] = A[i - 1];
        }
    }
    cout << ans << endl;
}


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

int main(){
  int A = 0, B = 0;
  char c;
  
  cin >> A >> c >> B;
  
  if(c == '+'){
    cout << A + B << endl;
  }
  if(c == '-'){
    cout << A - B << endl;
  }
  
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

using namespace std;

int main(){
  int a[]={0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y; cin >> x >> y;
  cout << (a[x]==a[y] ? "Yes": "No") << endl;
}

Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline())

minprice = 2000000000
maxdifference = -1000000000
for _ in range(n):
    price = int(stdin.readline())
    if price - minprice > maxdifference:
        maxdifference = price - minprice
    if price < minprice:
        minprice = price
print(maxdifference)


Measured memory_bytes: 5616
#include <cstdio>
#include <algorithm>

using namespace std;

int main(void) {
  int a, b, k;
  scanf("%d%d%d", &a, &b, &k);
  int c = (a < b ? a : b) + 1;
  while (k > 0) {
    --c;
    if (a%c == 0 && b%c == 0) --k;
  }
  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = (sc.nextInt()*100 + sc.nextInt()*10 + sc.nextInt());
		if(n % 4 == 0 ) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    rep(i,h) {
      rep(j,w) {
        if (i == 0 || i == h-1 || j == 0 || j == w-1) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


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

using ll = long long;
static const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int s;
  cin >> s;
  
  vector<ll> dp(s + 1);
  dp[0] = 1;
  for (int i = 3; i <= s; i++) dp[i] = (dp[i - 1] + dp[i - 3]) % MOD;
  
  cout << dp[s] << '\n';
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define re register
long long gcd(re long long a,re long long b){return b?gcd(b,a%b):a;}
long long lcm(re long long a,re long long b){return a/gcd(a,b)*b;}
long long a[510][510],pri[1010],cnt;
bool vis[100100];
int main()
{
	re int n;
	scanf("%d",&n);
	if(n==2){puts("4 7\n23 10");return 0;}
	for(re int i=2;cnt<=1000;i++)
	{
		if(!vis[i])pri[++cnt]=i;
		for(re int j=1;j<=cnt&&i*pri[j]<=100000;j++)
		{
			vis[i*pri[j]]=1;
			if(!(i%pri[j]))break;
		}
	}
	for(re int i=-n+1+(!(n&1)),i1=1;i<n;i+=2,i1++)
	{
		for(re int j=1;j<=n&&i+j<=n;j++)if(i+j>0)a[j][i+j]=pri[i1];
	}
	for(re int i=2,i1=n+1;i<=2*n;i+=2,i1++)
	{
		for(re int j=1;j<=n&&i-j>0;j++)a[j][i-j]*=pri[i1];
	}
	for(re int i=1;i<=n;i++)a[i][0]=a[0][i]=a[i][n+1]=a[n+1][i]=1;
	for(re int i=1;i<=n;i++,puts(""))for(re int j=1;j<=n;j++)
	{
		if(!a[i][j])a[i][j]=lcm(lcm(a[i+1][j],a[i-1][j]),lcm(a[i][j-1],a[i][j+1]))+1;
		printf("%lld ",a[i][j]);
	}
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
   ll N,A,B;cin>>N>>A>>B;
   ll info[N];
   rep(i,N)cin>>info[i];
   ll ans=0;
   rep(i,N-1){
       if(A*(info[i+1]-info[i])<B)ans+=A*(info[i+1]-info[i]);
       else ans+=B;
   }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int H,W,h,w;

int main(){
    cin >> H >> W >> h >> w;

    cout << H * W - (H * w + W * h - h * w) << endl;
}


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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

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

    int N;
    cin>>N;
    set<int> As;
    for (int n = 0; n < N; n++) {
        int A;
        cin>>A;
        if (As.count(A) == 0) As.insert(A);
        else As.erase(A);
    }
    cout<<As.size()<<endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
   public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      String[] input = sc.nextLine().split(" ");
      
      int n = Integer.parseInt(input[0]);
      int m = Integer.parseInt(input[1]);
      int l = Integer.parseInt(input[2]);
      
      //declare matrices
      long[][] matrix_1 = new long[n][m];
      long[][] matrix_2 = new long[m][l];
      long[][] answer = new long[n][l];
            
      //initialize matrix_1
      for(int i = 0; i < n; i ++) {
         input = sc.nextLine().split(" ");
         for(int j = 0; j < m; j ++) {
            matrix_1[i][j] = Integer.parseInt(input[j]);
         }
      }
      
      //initialize matrix_2
      for(int i = 0; i < m; i ++) {
         input = sc.nextLine().split(" ");
         for(int j = 0; j < l; j ++) {
            matrix_2[i][j] = Integer.parseInt(input[j]);
         }
      }
      //calculation
      for(int i = 0; i < n; i ++) {
         for(int j = 0; j < l; j ++) {
            long temp = 0;
            for(int k = 0; k < m; k ++) {
               temp += matrix_1[i][k] * matrix_2[k][j];
            }
            answer[i][j] = temp;
         }
      }
      
      //print out
      for(int i = 0; i < n; i ++) {
         String output = "";
         for(int j = 0; j < l; j ++) {
            output += answer[i][j] + " ";
         }
         System.out.println(output.trim());
      }
      
   }
}


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

#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdlib>

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


//4-side
//int xx[] = {0,0,-1,1};
//int yy[] = {-1,1,0,0};
//6-side hexagonal
//int xx[] = {2,-2,1,1,-1,-1};
//int yy[] = {0,0,1,-1,1,-1};

#define popc(a) (__builtin_popcount(a))
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

#define MX 100005
#define inf 100000000

const double pi = acos(-1.0);
const ll mod = 1000000007ll;

char str[100];

int input(int id)
{
    printf("%d\n", id);
    fflush(stdout);
    scanf("%s", str);
    if(str[0] == 'V')
        exit(0);
    if(str[0] == 'M')
        return 1;
    if(str[0] == 'F')
        return 2;
}

void func(int n)
{
    int st = input(0);
    int l = 0, r = n-1;
    while(l<=r)
    {
        int mid = (l+r)/2;
        int typ = input(mid);
        if(mid%2 == 0)
        {
            if(typ == st)
                l = mid+1;
            else
                r = mid-1;
        }
        else
        {
            if(typ != st)
                l = mid+1;
            else
                r = mid-1;
        }
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    scanf("%d", &n);
    func(n);
    return 0;
}



Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
int dp[1000100];
int joa(int money) {
  if (money <= 0)
    return 0;
  int ans = (int)1e5;
  if (dp[money] != -1)
    return dp[money];

  ans = min(ans, 1 + joa(money-1));
  for(int i = 6; i <= money; i *= 6)
    ans = min(ans, 1 + joa(money-i));
  for(int i = 9; i <= money; i *= 9)
    ans = min(ans, 1 + joa(money-i));
  dp[money] = ans;
  return ans;
}
int main() {
  int n;
  cin >> n;
  for(int i = 0; i <= 100010; i++)
    dp[i] = -1;
  int ans = 0;
  for(int i = 0; i <= n; ++i)
    ans = joa(i);
  cout << ans;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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,k;
    cin >> n >> k;
    vector<ll> t(n,0);
    rep(i,n){
        cin >> t[i];
        --t[i];
    }
    vector<ll> path;
    ll cnt = 0;
    unordered_set<ll> us;
    ll now = 0;
    while (us.count(now) == 0) {  // 探索済みの町に到達するまで
        path.push_back(now);
        us.insert(now);
        now = t[now];
    }
    ll s = find(path.begin(),path.end(),now) - path.begin();
    ll r = (ll)path.size() - s;
    if (k < s) {  // ループ部分に到達しない時
        cout << path[k] + 1 << endl;
        return 0;
    } else {  // ループ部分に到達する時
        cout << path[(k - s) % r + s] + 1 << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 14228
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
void solve() {}
vector<int> g[100005];
vector<int> bad[100005];
int vis[100005];
int gro[100005];
int dp[100005];
int s[100005];
void dfs(int u, int gr) {
  vis[u] = 1;
  gro[u] = gr;
  s[gr]++;
  for (int v : g[u]) {
    if (!vis[v])
      dfs(v, gr);
  }
}
int main() {
  IOS;
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].pb(v), g[v].pb(u);
  }
  for (int i = 0; i < k; i++) {
    int u, v;
    cin >> u >> v;
    bad[u].pb(v), bad[v].pb(u);
  }
  int cur = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i, cur);
      cur++;
    }
  }
  for (int i = 1; i <= n; i++) {
    int ans = s[gro[i]] - 1;
    for (int v : bad[i]) {
      if (gro[v] == gro[i])
        ans--;
    }
    for (int v : g[i]) {
      if (gro[v] == gro[i])
        ans--;
    }
    cout << ans << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 15964
# coding: utf-8
n,m=map(int,input().split())
l={}
p=2

while m>=p*p:
    if m%p==0:
        if not p in l.keys():
            l[p]=0
        l[p]+=1
        m//=p
    else:
        p+=1
if not m in l.keys():
    l[m]=0
l[m]+=1

ans=1
for p,q in l.items():
    if p==1:
        continue
    for i in range(q):
        ans*=n+i
    for i in range(q):
        ans//=i+1

print(ans%1000000007)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main() {
	int sum = 700;
	string S;
	cin >> S;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') {
			sum += 100;
		}
	}
	cout << sum;
	return 0;
}

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

int main()
{
  stack<int> S1;
  stack<pair<int ,int> > S2;
  char ch;
  int sum = 0;

  for(int i = 0;cin >> ch;i++)
  {
    if(ch == '\\') S1.push(i);
    else if(ch == '/' && S1.size() > 0)
    {
      int j = S1.top();S1.pop();
      sum += i - j;
      int a = i - j;
      while(S2.size() > 0 && S2.top().first > j)
      {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }

  vector<int> ans;
  while(S2.size() > 0)
  {
    ans.push_back(S2.top().second); S2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i = 0;i < ans.size();i++)
  {
    cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include<cstring>
#include <algorithm>
using namespace std;
int a[100001];
int main()
{
    int n;
    while(cin>>n)
    {
        int t;
        memset(a,0,sizeof(a));
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&t);
            a[t+1]++;
            a[t-1]++;
            a[t]++;
        }
        sort(a,a+100001);
        cout<<a[100000]<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
odd=list(input())
even=list(input())
ans=[]
for i in range(1,len(odd)+len(even)+1):
    if i%2!=0:
        ans.append(odd[i//2])
    else:
        ans.append(even[i//2-1])
for i in range(len(ans)):
    print(ans[i],end="")

Measured memory_bytes: 3060
#商をxとすると、(m+1)*x=N
#つまり、約数のうち、商よりも大きいもの−１の和を求める
n=int(input())
ans=0
for i in range(1, int(n**0.5)+1):
  if n%i==0:
    if n/i-1 > i:
      ans+=(n//i)-1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

struct RollingHash{
  typedef unsigned long long ull;
  string S;
  ull B;
  int len;
  vector<ull> hash,p;
  RollingHash(){}
  RollingHash(string S_,ull B_=1000000007LL):
    S(S_),B(B_),len(S.length()),hash(len+1),p(len+1){
    hash[0]=0;p[0]=1;
    for(int i=0;i<len;i++){
      hash[i+1]=hash[i]*B+S[i];
      p[i+1]=p[i]*B;
    }
  }
  //S[l,r)
  ull find(int l,int r){
    return hash[r]-hash[l]*p[r-l];
  }
};

int n,m,dp[5004][1<<12];
string s[12],x;

signed main(){
    while(cin>>n>>m,n){
        r(i,n)cin>>s[i];
        vector<RollingHash> re;
        r(i,n){
            RollingHash rer(s[i]);
            re.push_back(rer);
        }
        int sum=0;
        r(i,m){
            string t;
            cin>>t;
            x+=t;
        }
        r(o,1){
            //cin>>x;
            RollingHash R(x);
            memset(dp,0,sizeof(dp));
            for(int i=0;i<x.size();i++){
                dp[i][0]=1;
                for(int j=0;j<n;j++){
                    for(int k=0;k<(1<<n)-1;k++)if(!((1<<j)&k)){
                        if(i+s[j].size()>x.size())continue;
                        if(re[j].find(0,s[j].size())==R.find(i,i+s[j].size())){
                            dp[i+s[j].size()][k|(1<<j)]+=dp[i][k];
                            if(k==0)dp[i+s[j].size()][k|(1<<j)]++;
                            dp[i+s[j].size()][k|(1<<j)]%=1000000007;
                        }
                    }
                }
            }
            for(int i=0;i<x.size()+1;i++) sum+=(dp[i][(1<<n)-1]?1:0) , sum%=1000000007;
        }
        x="";
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 83260
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	AB, BC, _ := getInt(), getInt(), getInt()
	out(AB * BC / 2)
}


Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<string>
#define MAX 1060
using namespace std;
typedef struct{
	char s[MAX];
	int sum;
} gg;
char mstr[MAX],lstr[MAX],str[MAX],pre[MAX];
int lon=0,r,gs=0,mx=0;
gg sp[MAX];
void func(int x){
	int i;
	for(i=0;i<gs;i++){
		if(strncmp(sp[i].s,&str[x],r)==0){
			sp[i].sum++;
			break;
		}
	}
	if(i==gs){
		strncpy(sp[gs].s,&str[x],r);
		sp[gs].s[r]='\0';
		sp[gs++].sum=1;
	}
	if(sp[i].sum>mx){
		mx=sp[i].sum;
		strcpy(mstr,sp[i].s);
		mstr[strlen(sp[i].s)]='\0';
	}
}
int lo(int x){
	int i;
	for(i=x;isalpha(str[i]);i++)
		;
		return i-x;
}
void solve(){
	for(int i=0;str[i]!='\0';i++){
		if(isalpha(str[i])){
			r=lo(i);
			if(r>lon){
				lon=r;
				strncpy(lstr,&str[i],r);
				lstr[r]='\0';
			}
			func(i);
			i+=(r-1);
		}
	}
}
int main(){
	cin.getline(str,MAX);
		gs=0;mx=0;lon=0;
		solve();
		cout<<mstr<<' '<<lstr<<endl;
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  vector<int> num = {2, 5, 5, 4, 5, 6, 3, 7, 6};
  
  int n, m;
  cin >> n >> m;
  
  vector<int> a(m);
  for(int i = 0; i < m; i++) cin >> a.at(i);
  
  vector<int> dp(n + 10, -1);
  dp.at(0) = 0;
  for(int i = 0; i < m; i++){
    for(int j = num.at(a.at(i) - 1); j <= n; j++){
      if(dp.at(j - num.at(a.at(i) - 1)) != -1){
        dp.at(j) = max(dp.at(j - num.at(a.at(i) - 1)) + 1, dp.at(j));
      }
    }
  }
  
  sort(a.rbegin(), a.rend());
  
  int now = n;
  while(now != 0){
    for(int i = 0; i < m; i++){
      if(now - num.at(a.at(i) - 1) >= 0 && dp.at(now - num.at(a.at(i) - 1)) == dp.at(now) - 1){
        cout << a.at(i);
        now -= num.at(a.at(i) - 1);
        break;
      }
    }
  }
  
  cout << '\n';
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	max := 0.0
	vs := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&vs[i])
	}

	sort.Float64s(vs)
	cur := vs[0]
	for i := 1 ; i < n; i++ {
		cur = (cur +vs[i])/2.0
	}
	if cur > max {
		max = cur
	}
	fmt.Println(max)

}


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

int main()
{
  ll N; cin >> N;
  vector<ll> a(N);
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (i % 2) {
      sum -= a[i];
    } else {
      sum += a[i];
    }
  }

  vector<ll> m(N);
  m[0] = sum;
  cout << m[0] << " ";
  for (int i = 1; i < N; i++) {
    m[i] = 2 * a[i-1] - m[i-1];
    cout << m[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2944