akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T & a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T & a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T> & v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	makei(x);
	say(x * x * x);
}


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

int N;

int search2(int a[]){
int nex=0;
int ans =0;
for(int i=0;i<=N-1;i++){
nex=a[nex]-1;
ans++;
if (nex==1) return ans;
}
return -1;
}

int main(){
int a[100005];
cin>>N;
for(int i=0;i<=N-1;i++){
cin>>a[i];
}

cout << search2(a) <<endl;

return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long int ll;
vector<int> a[100005];
int vis[100005];

void dfs(int n,int v)  {
    vis[n]=v;
    for(int i=0; i<a[n].size(); i++)  
        if(vis[a[n][i]]!=v)  dfs(a[n][i],v);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    int n,m;
    cin>>n>>m;
    int c,d;
    for(int i=0; i<n; i++)  vis[i]=0;
    for(int i=0; i<m; i++)  {
        cin>>c>>d;
        c--; d--;
        a[c].push_back(d);
        a[d].push_back(c);
    }
    int v=0;
    set<int> b;
    //b.insert(1);
    for(int i=0; i<n; i++)  {
        if(!b.count(vis[i]))  {
            b.insert(++v);
            dfs(i,v);
            
        }
    }
    
    cout<<b.size()-1<<endl;
   return 0;
}

Measured memory_bytes: 11144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> P(M);
  rep(i, M)
  {
    cin >> P[i].first >> P[i].second;
  }
  // 全探査
  rep(x, 1000)
  {
    int nx = x / 10;
    vector<int> d(1, x % 10);
    // 分解
    while (nx)
    {
      d.push_back(nx % 10);
      nx /= 10;
    }
    reverse(d.begin(), d.end());
    if (d.size() != N)
    {
      continue;
    }
    bool is = true;
    rep(i, M)
    {
      if (d[P[i].first - 1] != P[i].second)
      {
        is = false;
      }
    }
    if (is)
    {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second 
using  namespace std;
using pii = pair<int, int>;
using ll = long long;
const int N = 2e5 + 10;
std::vector<int> gr[N];
stack<int> bip[2];
void dfs(int node,int from, int value){
	bip[value].push(node);
	for(auto it: gr[node]){
		if(it == from) continue;
		dfs(it, node, 1 - value);
	}
	return;

}
map<pii, int> mp;
int sz[2], ans[N];
bool comp(int &lhs, int &rhs){
	return sz[lhs] < sz[rhs];
}
int main(){
	int n,x,y;
	scanf("%d",&n);
	for(int i =1; i <= n-1;i++){
		scanf("%d%d",&x,&y);
		gr[x].push_back(y);
		gr[y].push_back(x);
	}
	dfs(1, 0, 0);

	sz[0] = (int)bip[0].size(), sz[1] = (int)bip[1].size();
	fprintf(stderr, "%d\n", sz[0] + sz[1]);
	int k  = sz[0] > sz[1] ? 0 : 1;
	for(int i = 1; i <= n; i+=3){
		ans[bip[k].top()] = i;
		bip[k].pop();
	}
	sz[0] = (int)bip[0].size(), sz[1] = (int)bip[1].size();
	k = sz[0] > sz[1] ? 0 : 1;
	for(int i = 2; i <= n; i+=3){
		ans[bip[k].top()] = i;
		bip[k].pop();
	}
	int st = 3;
	for(int i = 1;i <= n;i++){
		if(ans[i] == 0) ans[i] = st, st+=3;
		printf("%d ",ans[i]);
	}



}

Measured memory_bytes: 26200
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 998244353;

#include<iostream>

using namespace std;

int const MAX_N = 200010;


int main(){
    int n, k;
    cin >> n >> k;
    int l[n], r[n];
    rep(i, k) {
        cin >> l[i] >> r[i];
        l[i]--; r[i]--;
    }
    ll dp[n];
    ll dps[n+1];
    rep(i, n){
        dp[i] = 0;
        dps[i] = 0;
    }
    dp[0] = 1;
    dps[0] = 0;
    dps[1] = 1;
    rep(i, n - 1){
        rep(j, k){
            int ls = max(i - l[j], -1);
            int rs = max(i - r[j], 0);
            dp[i+1] += dps[ls+1] - dps[rs] + mod;
            dp[i+1] %= mod;
            dps[i+2] = dps[i+1] + dp[i+1];
            dps[i+2] %= mod;
        }
    }
    // rep(i, n){
    //     cout << dp[i] << endl;
    // }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 6756
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int main()
{
    long long Q, H, S, D, N;
    long long price = 0;
    cin >> Q >> H >> S >> D >> N;
    // replace H and S
    H = min(2 * Q, H);
    S = min(2 * H, S);
    if(N % 2 == 1){
        price = (D <= 2 * S) ? ((N / 2) * D + S) : (N * S);  
    }
    else {
        price = (D <= 2 * S) ? ((N / 2) * D) : (N * S);
    }
    cout << price << endl;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n;cin>>n;

	vector<int> b(n-1);
	for(int i=0; i<n-1; i++){
		cin>>b[i];
	}
	vector<int> a(n);
	a[0] = b[0];

	for(int i=1; i<=n-2; i++){
		a[i] = min(b[i],b[i-1]);
	}
	a[n-1] = b[n-2];

	ll ans =0;
	for(auto e: a){
		ans +=e;
	}
	writeln(ans);


}




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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 1000010
const int MOD = 1000000007;

int pw(int a, int b, int m = MOD) {
    if (b == 0)return 1;
    if (b & 1)return a * pw(a, b - 1) % m;
    return pw(a * a % m, b / 2);
}

int inverse(int a) {
    return pw(a, MOD - 2);
}

int fact[maxn], inv[maxn];

void preprocess(int lmt) {
    fact[0] = 1;
    for (int i = 1; i <= lmt; i++)fact[i] = (fact[i - 1] * i) % MOD;
    inv[lmt] = inverse(fact[lmt]);
    for (int i = lmt - 1; i >= 0; i--)inv[i] = (i + 1) * inv[i + 1] % MOD;
}


int C(int n, int r) {
    if (r > n)return 0;
    return fact[n] * inverse(fact[r] * fact[n - r] % MOD) % MOD;
}

void solve() {
    int n;
    cin >> n;

    int ans = pw(10, n) - pw(8, n);
    ans += MOD;
    ans %= MOD;
    for (int i = 1; i <= n; i++) {
        int val = 2 * pw(8, n - i) % MOD;
        (val *= C(n, i)) %=MOD;
        ans = ans - val;
        ans = (ans + MOD) % MOD;
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    preprocess(1000000);
    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 19268
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                if (n == 0) {
                    break;
                }
                int[] scores = new int[n];
                for (int i = 0; i < scores.length; i++) {
                    scores[i] = sc.nextInt();
                }
                double average = 0, variance = 0;
                //average
                for(int i=0;i<scores.length;i++){
                    average += scores[i];
                }
                average = average/n;

                for(int i=0;i<scores.length;i++){
                    variance += (scores[i]-average)*(scores[i]-average);
                }
                 variance = variance/n;

                System.out.println(Math.sqrt(variance));
            }
        }
    }
}



Measured memory_bytes: 31324
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  string s=to_string(N);
  if(s[0]=='7' || s[1]=='7' || s[2]=='7')
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3660
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		Arrays.sort(t);
		int count = 0;
		int i = 1;
		int ft = t[0];
		int pc = 1;
		while (i < n) {
			if (t[i] <= ft + k && pc < c) {
				pc++;
			} else {
				count++;
				ft = t[i];
				pc = 1;
			}
			i++;
		}
		count++;
		System.out.println(count);
 	}
}

Measured memory_bytes: 52072
def main():
    N = int(input())
    P = [float(i) for i in input().split()]
    dp = [[0]*(N+1) for _ in range(N+1)]
    dp[1][1] = P[0]
    dp[1][0] = 1 - P[0]
    for i in range(2, N+1):
        p = P[i-1]
        for j in range(i+1):
            p1 = dp[i-1][j-1] * p if j != 0 else 0
            p2 = dp[i-1][j] * (1 - p)
            dp[i][j] = p1 + p2
    ans = 0
    for j in range(0--N//2, N+1):
        ans += dp[N][j]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 204048
fun main(){
    val n = readLine()!!.split(" ")[0].toCharArray().map { it.toInt() }
    var total = 0
    for (i in 0 until n.size){
        total += n[i] - 48
    }
    if (total % 9 == 0){
        println("Yes")
    } else if (total == 0){
        println("Yes")
    } else {
        println("No")
    }

}

Measured memory_bytes: 42964
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////


int main() {
    ll n; cin >> n;
    Vl a(n), b(n, 0);
    rep(i, 0, n) cin >> a[i];

    sort(ALL(a));
    rep(i, 0, n-1){
        b[i] += a[i];
        b[i+1] += b[i];
    }
    ll ans = 1;
    bool f = true;
    repr(i, 0, n-1){
        if(f){
            if(b[i]*2 >= a[i+1]) ans++;
            else f = false;
        }
    }
    co(ans);

    return 0;
}




Measured memory_bytes: 4772
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

vector<int> eratosthenes(int n) {
  vector<int> v(n);
  for (int i=2; i<n; i++) v[i] = i;
  for (int i=2; i*i<n; i++)
    if (v[i])
      for (int j=i*i; j<n; j+=i)
        v[j] = 0;
//  v.erase(remove(ALL(v),0),v.end()); // ツつアツつアツづーツづつつッツづェツづ篠素ツ青板δ環スツト
  return v;
}

int main() {
  vector<int> prime =  eratosthenes(1000000);
  int n,x;
  while(cin >> n >> x, n||x) {
    int a[n];
    REP(i,n) {
      cin >> a[i];
    }
    bool dp[x+1];
    memset(dp,0,sizeof(dp));
    dp[0] = true;
    for (int i=1; i<=x; ++i) {
      REP(j,n) {
        if (i-a[j] >= 0 &&dp[i-a[j]]) {
          dp[i] = true;
          break;
        }
      }
    }
    int i;
    for (i = x; i>=0; --i) {
      if (prime[i] &&dp[i]) {
        cout << i << endl;
        break;
      }
    }
    if (i<0) {
      cout << "NA" << endl;
    }
  }
}

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

int main(){
  int k;
  string s;
  cin>>k>>s;
int n= s.size();
if(n<=k){
  cout<<s<<endl;
}
else{
  for(int i=0; i<k; i++){
    cout<<s.at(i);
  }
  cout<<"..."<<endl;
}

return 0;
}


Measured memory_bytes: 3628
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int n;

	cin >> n;

	string s = "";

	if(n == 0){
		cout << '0' << endl;
		return 0;
	}
	

	int i = 1;
	while(n != 0){
		if(n % 2 == 0){
			s += '0';
		} else {
			s += '1';
		}

		n -= abs(n % 2);

		n /= -2;
	}

	reverse(s.begin(), s.end());

	cout << s << endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll d[110][100010];
ll n,m;
ll w[100010],v[100010];
int res;
int main()
{
	cin >>n>>m;
	for (int i=1;i<=n;i++) cin >>w[i]>>v[i];
	for (int i=1;i<=100005;i++) d[0][i]=1e18;
	d[0][0]=0;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=100005;j++)
		{
			d[i][j]=d[i-1][j];
			if (v[i]<=j) d[i][j]=min(d[i][j],d[i-1][j-v[i]]+w[i]);
		}
	} 
	for (int i=0;i<=100005;i++) if (d[n][i]<=m) res=max(res,i);
	cout <<res;
	return 0;
}

Measured memory_bytes: 80640
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<string>
#define mod 1000000007
#define ll long long
using namespace std;
map<int,int> mp;
int main()
{
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
    int N;
    cin>>N;
    int temp,MIN=0x3f3f3f3f,MAX=-0x3f3f3f3f;
    for(int i=1;i<=N;i++)
    {
    	cin>>temp;
    	if(MIN>temp)
    	MIN=temp;
    	if(MAX<temp)
    	MAX=temp;
    	mp[temp]++;
	}
	int ans=0;
	for(int i=MIN-1;i<=MAX+1;i++)
	{
		if(mp[i]+mp[i-1]+mp[i+1]>ans)
		ans=mp[i]+mp[i-1]+mp[i+1];
	}
	mp.clear();
	cout<<ans<<endl;
}


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

int main(void){
  int N, K;
  cin >> N >> K;
  int h[N];
  for (int i = 0; i < N; i++){
	cin >> h[i];
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++){
	if (h[i] >= K) ans++;
  }
  cout << ans << endl;

  	
	return 0;
  
}

Measured memory_bytes: 640
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

ans = [[0] * W for _ in range(H)]
ctr = [0] * N
n = 0
for i in range(H):
    for j in range(W):
        if i % 2 == 1:
            j = W - 1 - j
        ans[i][j] = n + 1
        ctr[n] += 1
        if A[n] == ctr[n]:
            n += 1

for v in ans:
    print(*v)


Measured memory_bytes: 42352
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    a.sort()
    for i in range(n-1):
        if a[i]==a[i+1]:
            return 'NO'
    return 'YES'

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>K;
	for(i=100;i>=1;i--) {
		if(A%i==0 && B%i==0) {
			K--;
			if(K==0) {
				cout<<i<<endl;
				return;
			}
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 3
using namespace std;
typedef unsigned long long ull;
bool im[1010][1010],pa[110][110];
int w,h,p,ans;
vector<ull> used;

void ppp(){
 ull a=0;
 ull roll[1001][1001]={};
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)a=a*N+pa[i][j];
 for(int i=0;i<used.size();i++)
   if(used[i]==a)return;
 used.push_back(a); 
 for(int j=0;j<h;j++){
   ull b=0,g=1;
   for(int i=0;i<p;i++)b=b*N+im[j][i],g*=N;
   roll[j][p-1]=b;
   for(int i=p;i<w;i++){
     b=b*N+im[j][i]-im[j][i-p]*g;
     roll[j][i]=b;
   }
 }
 for(int j=p-1;j<w;j++){
   ull b=0,g=1,n=1;
   for(int i=0;i<p;i++)n*=N;
   for(int i=0;i<p;i++)b=b*n+roll[i][j],g*=n;
   if(b==a)ans++;
   for(int i=p;i<h;i++){
     b=b*n+roll[i][j]-roll[i-p][j]*g; 
     if(b==a)ans++;
   }
 }
}

void ch(){
 bool npa[110][110];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)npa[i][j]=pa[j][p-i-1];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)pa[i][j]=npa[i][j];
}

void ch1(){
 for(int i=0;i<p;i++)
   for(int j=0;j<p/2;j++)swap(pa[i][j],pa[i][p-j-1]);
}

int main(){
 int D[256];
 for(int i='A';i<='Z';i++)D[i]=i-'A';
 for(int i='a';i<='z';i++)D[i]=i-'a'+26;
 for(int i='0';i<='9';i++)D[i]=i-'0'+52;
 D['+']=62,D['/']=63;
 while(cin>>w>>h>>p,w){
   string s;
   memset(im,0,sizeof(im));
   memset(pa,0,sizeof(pa));
   used.clear();
   for(int i=0;i<h;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
	int t=D[s[j]];
	int a=5;
	while(t){
	  im[i][j*6+a]=t%2;
	  t/=2,a--;
	}
     }
   }
   for(int i=0;i<p;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
	int t=D[s[j]];
	int a=5;
	while(t){
	  pa[i][j*6+a]=t%2;
	  t/=2,a--;
	}
     }
   }
   ans=0;
    for(int i=0;i<4;i++){
     ppp();
     ch1();
     ppp();
     ch1();
     ch();
   }
   cout<<ans<<endl;
 }

 return 0;
}

Measured memory_bytes: 11848
#include <stdio.h>
int main(void){

  int q, r;

  int p;

  int tmp;

  scanf("%d%d",&p,&q);

   /* 自然数 a > b を確認・入替 */
  if(q<p){
    tmp =q;
    q = p;
    p = tmp;
  }

  /*ucrid*/
  r = p % q;
  while(r!=0){
    p = q;
    q = r;
    r = p % q;
  }
 
  /* 出wosim力 */
  printf("%d\n", q);
 
  return 0;
}



Measured memory_bytes: 2072
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int a[4],ans=0;
    for(int i=0;i<4;i++)scanf("%d",&a[i]);
    sort(a,a+4);
    for(int i=1;i<4;i++)ans+=a[i];
    for(int i=0;i<2;i++)scanf("%d",&a[i]);
    sort(a,a+2);
    ans+=a[1];
    printf("%d\n",ans);
}


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

vector<pair<int, int> > p[22];

int main()
{
    int n, t, ans = 0;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &t);
        p[i].resize(t);
        
        for (int j = 0; j < t; j++)
            scanf("%d %d", &p[i][j].first, &p[i][j].second);
    }

    for (int i = 0; i < (1 << n); i++)
    {
        vector<bool> honest(n, 0);
        int dap = 0;
        bool invalid = false;
        
        for (int j = 0; j < n; j++)
            if (i & (1 << j))
                honest[j] = true, dap++;
        
        for (int j = 0; j < n; j++)
            if (i & (1 << j))
                for (auto x : p[j])
                {
                    int per = x.first - 1, what = x.second;
                    if (honest[per] != what)
                        invalid = true;
                }
        
        if (invalid)
            continue;
        
        ans = max(ans, dap);
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
    #define debug(...) printf(__VA_ARGS__)
#else
    #define debug(...) (void)0
#endif
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define PII pair<long long, long long>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
const int inf = 0x7fffffff; //beware overflow
const LL INF = 0x7fffffffffffffff; //beware overflow
#define mem(x, y) memset(x, (y), sizeof(x) );
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
     return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
    s << "[ ";
    for (auto it : c) s << it << " ";
    s << "]";
    return s;
}
template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    o << "{";
    for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it;
    return o << "}";
}
template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se;
    }
    o << "}";
    return o;
}
int h, w;
LL cnt[10];
map< pii, bool > ma;
set<pii> se;
vector<pii> p;
int main() {
    scanf("%d %d", &h, &w);
    mem(cnt, 0);
    LL tot = 1LL*h*w-2*h-2*w+4;
    int n;cin>>n;
    while(n--) {
        int a, b; scanf("%d %d", &a, &b);
        p.pb( mp(a, b) );
        ma[ mp(a,b) ] = true;
    }

    for( auto pa : p) {
        for(int i = pa.fi-2; i <= pa.fi; i++) {
            for(int j = pa.se-2; j <= pa.se; j++) {
                if( se.count( mp(i, j) ) ) continue;

                if( i>=1 && j >= 1 && i+2<=h && j+2 <=w ) {
                    int old = 0;
                    for(int k = 0; k < 3; k++) for(int kk=0;kk<3;kk++)
                        old += ma.count( mp(i+k,j+kk) );
                    cnt[old]++;
                    se.insert( mp(i, j));
                }
            }
        }
    }
    LL sum = 0;
    for(int i = 1; i <= 9; i++) sum += cnt[i];
    cout<<tot-sum<<endl;
    for(int i = 1; i <= 9; i++)
        printf("%lld\n", cnt[i]);
}


Measured memory_bytes: 49524
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	int A;
	cin >> A;

	if (N % 500 <= A)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3620
n = int(input())
S = input()
cnt = 0
i,j = 0,n-1
while i<j:
    if S[i]=='R' and S[j]=='R':
        i+=1
    elif S[i]=='R' and S[j]=='W':
        i += 1
        j -=1
    elif S[i]=='W' and S[j]=='W':
        j-=1
    else:
        cnt += 1
        i+=1
        j-=1
print(cnt)


Measured memory_bytes: 67760
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,L;
    cin >> N >> L;
    vector<string>S(N);
    for(int i=0;i<N;i++){
        cin >> S.at(i);
    }
    sort(S.begin(),S.end());
    for(int i=0;i<N;i++){
        cout << S.at(i);
    }
}

Measured memory_bytes: 256
N = int(input())

dp = [float('inf') for _ in range(N + 1)]
dp[N] = 0

for i in range(N, -1, -1) :
    if i - 1 >= 0 :
        dp[i - 1] = min(dp[i - 1], dp[i] + 1)
    dis = 6
    while i - dis >= 0 :
        dp[i - dis] = min(dp[i - dis], dp[i] + 1)
        dis *= 6
    dis = 9
    while i - dis >= 0 :
        dp[i - dis] = min(dp[i - dis], dp[i] + 1)
        dis *= 9

print(dp[0])

Measured memory_bytes: 6296
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;
	
	int dp[100010][13] = { 0 };
	int N = S.size();
	
	dp[0][0] = 1;
	int tmp;
	REP(i, N) {
		tmp = 0;
		if (S[i] == '?')tmp = -1;
		else tmp = S[i] - '0';
		REP(j, 10) {
			if (tmp != -1 && tmp != j)continue;

			REP(l, 13) {
				dp[i + 1][(l * 10 + j) % 13] += dp[i][l];
			}
			REP(l, 13)dp[i + 1][l] = (dp[i + 1][l] + mod) % mod;
		}
	}

	cout << dp[N][5] << endl;
	return 0;
}



Measured memory_bytes: 10704
#include <iostream>
#include <algorithm>

int main() {
  int64_t a, b, c, d;
  std::cin >> a >> b >> c >> d;

  int64_t ans = a * c;
  ans = std::max(ans, a * d);
  ans = std::max(ans, b * c);
  ans = std::max(ans, b * d);
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c,r,cal,value,i,j,k;
    while(scanf("%d%d",&c,&r)!=EOF)
    {
        if(c==0 && r==0)
        {
            break;
        }
        else
        {
            for(i=0; i<c; i++)
            {
                for(j=0; j<r; j++)
                {

                    cout<<"#";
                }
                cout<<endl;
            }
            cout<<endl;
        }

    }
}



Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
	int N,i;
	bool flag = false;
	char buf;
	cin >> N;
	for(i=0;i<N;i++){
		cin >> buf;
		if(buf == 'Y'){
			flag = true;
			break;
		}
	}
	if(flag) cout << "Four" << endl;
	else cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,i;
	char moji[10000]={0};
	while(scanf("%s",moji)!=EOF){
	a=0,b=0,i=0;
		while(moji[i+1]!='\0'){
			if(moji[i]=='J' && moji[i+1]=='O' && moji[i+2]=='I')a++;
			else if(moji[i]=='I' && moji[i+1]=='O' && moji[i+2]=='I')b++;
			i++;
		}
		printf("%d\n%d\n",a,b);
	}
	return 0;
}


Measured memory_bytes: 2080
// think twice code once
// Start:
// End  :
#include <bits/stdc++.h>
using namespace std;

#define rep(i, x, y) for(int i = (x), _ = (y); i <= _; ++ i)
#define per(i, x, y) for(int i = (x), _ = (y); i >= _; -- i)
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
#define disp(x) cout << #x << " = " << x << "; "

typedef long long LL;

template <class T> bool chkmin(T& a, T b) { return a > b ? a = b, true : false; }
template <class T> bool chkmax(T& a, T b) { return a < b ? a = b, true : false; }

template <class T> void read(T& a) {
	char c = getchar(); T f = 1; a = 0;
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) a = a * 10 + c - '0';
	a *= f;
}

template <class T> void write(T a) {
	static int stk[60]; 
	int tp = 0;
	if(a < 0) putchar('-'), a = -a;
	do {
		stk[++ tp] = a % 10;
		a /= 10;
	}while(a);
	
	while(tp) putchar(stk[tp--] + '0');
}

const int maxN = 1e5 + 5;

char s[maxN];
string lala[4];
bool f[maxN];
int N;

bool check(int pos, string haha) {
	rep(i, 0, haha.size() - 1) if(s[i + pos] != haha[i]) return 0;
	return 1;
} 

int main() {
#ifdef Leeson
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
#endif

	lala[0] = "dream";
	lala[1] = "dreamer";
	lala[2] = "erase";
	lala[3] = "eraser";

	scanf("%s", s + 1);
	N = strlen(s + 1);

	f[0] = 1;
	rep(i, 1, N) {
		if(i - 5 >= 0 && f[i - 5]) {
			if(check(i - 4, lala[0]) || check(i - 4, lala[2]))
				f[i] = 1;
		} 
		if(i - 6 >= 0 && f[i - 6]) {
			if(check(i - 5, lala[3]))
				f[i] = 1;
		}
		if(i - 7 >= 0 && f[i - 7]) {
			if(check(i - 6, lala[1]))
				f[i] = 1;
		}
	}

	if(f[N]) puts("YES");
	else puts("NO");

	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String ans = "APPROVED";

		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			if(A[i] % 2 == 0) {
				if(A[i] % 3 != 0 && A[i] % 5 != 0)
					ans = "DENIED";
			}
		}

		System.out.println(ans);
	}

}



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

#define   ld             long double
#define   ll             long long
#define   boost_         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define   pb             push_back
#define   ppb            pop_back
#define   ull            unsigned long long
#define   over           return 0
#define   scan(i,n,a)    for(i=0;i<n;i++) cin>>a[i]

using namespace std;

                        //**************************GCD**************************//

int gcd(int x,int y){

    if(x==0) return y;
    else return gcd(y%x,x);

}


                        //**************************MAIN**************************//

int main(){

   int n,k,sum=0,i;
   cin>>n>>k;
   int a[n];
   scan(i,n,a);
   sort(a,a+n);
   for(i=0;i<k;i++) sum+=a[i];
   cout<<sum<<endl;


}












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

long long s;
long long solve(long long, long long);

int main()
{
	scanf("%lld", &s);
	printf("%lld\n", solve(1, 0));

	return 0;
}

long long solve(long long digit, long long set)
{
	if (digit * 10 > s)
	{
		int pre{1};
		long long sum{}, ten_pow{};
		for (ten_pow = 10; ten_pow <= s; ten_pow *= 10)
		{
			if (set & 1)
			{
				sum += s % ten_pow / pre;
				pre = ten_pow;
			}
			set >>= 1;
		}
		sum += s % ten_pow / pre;
		return sum;
	}
	return solve(digit * 10, set << 1) + solve(digit * 10, (set << 1) + 1);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
main(){
	string s;
	cin>>s;
	int f=1,i;
	for(;f;){
		for(f=0,i=1;i<s.size()-3;i++)
			if(s.substr(i,3)=="mew")s.replace(i,3,""),f=1;
	}
	cout<<(s=="mew"?"Cat":"Rabbit")<<endl;
}

Measured memory_bytes: 1216
import math

n = int(input())

soinsu = []

c = n
if (c % 2 == 0):
    while True:
        soinsu.append(2)
        c = c // 2
        if ( c % 2 != 0):
            break

len = int(math.sqrt(c)) + 1
for i  in range (3,len,2):
    while True:
        if ( c % i != 0):
            break
        soinsu.append(i)
        c = c // i
    if ( c == 1):
        break
if ( c != 1):
    soinsu.append(c)

print (n,":",sep="",end="")
for i in soinsu:
    print (' {}'.format(i),sep="",end="")
print("")





Measured memory_bytes: 5664
from collections import deque

H, W = map(int, input().split())
sy = 0
sx = 0
gy = H-1
gx = W-1
c = []
d = [[-1 for i in range(W)] for j in range(H)]
d[sy][sx] = 0
cnt=0
for i in range(H):
	c.append(input())
for j in range(H):
  cnt=cnt+c[j].count(".")

dirr = [[1, 0], [0, 1], [-1, 0], [0, -1]]
q = deque()
q.append([sy, sx, 0])
while len(q) != 0:
	y, x, w = q[0]
	if y == gy and x == gx:
		break

	for i in range(4):
		ny, nx = y + dirr[i][0], x + dirr[i][1]
		if ny>=0 and nx>=0 and ny<H and nx<W and d[ny][nx] == -1 and c[ny][nx] != "#":
			q.append([ny, nx, w + 1])
			d[ny][nx] = w + 1

	q.popleft()

if d[gy][gx]==-1:
  print(-1)
else:
  print(cnt-w-1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{

    long long int k,n,i,s=0;

    cin>>k>>n;
    long long int a[n],b[n];
    cin>>a[0];
    for(i=1;i<n;i++)
    {
     cin>>a[i];
     b[i-1]=a[i]-a[i-1];
     s=s+b[i-1];

    }
    b[n-1]=a[0]+k-a[n-1];
    s=s+b[n-1];
    sort(b,b+n);
    s=s-b[n-1];
    cout<<s<<endl;


}



Measured memory_bytes: 3328
N = int(input())
a = list(map(int, input().split()))

for i in range(N):
    key = a[i]
    j = i - 1
    while j >= 0 and a[j] > key:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = key
    print(" ".join([str(x) for x in a]))



Measured memory_bytes: 5608
#include<stdio.h>
#define N 100000
int partition(int *, int, int);
int main(){
  int i,j,n,A[N];
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

    j = partition(A ,0,n-1);
    for(i = 0;i<j; i++){
      printf("%d",A[i]);
      printf(" ");
    }
    printf("[%d] ", A[j]);
    for(i = j+1; i < n; i++){
      printf("%d", A[i]);
      if(i < n-1)printf(" ");
    }
    printf("\n");
  return 0;
}

int partition(int *A,int p,int r){
  int x,i,j;
  int copy;
  x = A[r];
  i = p-1;
  for(j = p; j <= r-1; j++){
    if(A[j] <= x){
      i = i+1;
      copy = A[i];
      A[i] = A[j];
      A[j] = copy;
    }
  }
  copy = A[i+1];
  A[i+1] = A[r];
  A[r] = copy;
  
  return i+1;
}
 
  

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<n; ++i)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define F first
#define S second
#define PB push_back
#define MP make_pair 
using namespace std;
typedef unsigned long ul;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int, int> pi;
const int INF = 100100100;
const unsigned int MOD = 1000000007;

bool is_prime(int n) { for (int i = 2; i*i <= n; ++i) { if (n % i == 0) return false; } return true; }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }

ll dp[50];
int N;

int main() {
    cin >> N;
    REP(i, 50) dp[i] = 0;
    dp[0] = 1; dp[1] = 1;
    
    for(int i = 2; i < 50; ++i) {
        dp[i] = dp[i - 1] + dp[i - 2];    
    }
    
    cout << dp[N] << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
int main() {
    while (cin >> N) {
        double res = 0.0;
        for (int i = 0; i < N; ++i) {
            double x;
            string s;
            cin >> x >> s;
            if (s == "JPY") res += x;
            else res += x * 380000;
        }
        cout << fixed << setprecision(10) << res << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
// #define DEBUG
#define fi first
#define se second
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long LL;
typedef unsigned int UINT;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector< Vi > VVi;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(P *a){scanf("%d",&a->fi);scanf("%d",&a->se);} 
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999;
 
const int DX4[4]= {-1,0,1,0};
const int DY4[4]= {0,-1,0,1};
 
//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
long double pascalTri(int n,int r){
	long double tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]+tri[i-1][j]);}
		}
	}
	return tri[n][r];
}
 
LL GCD(LL a,LL b){
	LL t;
	if(a<b){t=a;a=b;b=t;}
	if(b==0){return a;}
	LL r;
	while(a%b!=0){
		r=a%b;
		a=b;
		b=r;
	}
	return b;
}
 
LL LCM(LL a,LL b){
	LL ab=(a*b)%MOD;
	return ab/GCD(a%b,b);
}
 
double area(P a,P b,P c){
	return ((b.fi-a.fi)*(c.se-a.se)-(b.se-a.se)*(c.fi-a.fi))/2.;
}
 
int checkCross(P v1,P v2,P a,P b){
	// cout<<area(v1)<<" "<<area(v2)<<endl;
	if(area(a,b,v1)*area(a,b,v2)>=0){return 0;}
	if(area(v1,v2,a)*area(v1,v2,b)>=0){return 0;}
	return 1;
}
 
 
 
int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int n,k;
	// int a,b,c,d;
	int sum;
	char s[3];
	int i,j,l;

	SCAN(&n);SCAN(&k);
	
	
	#ifdef DEBUG
		auto start=chrono::system_clock::now();
	#endif

	if((n+k)%2==1){
		cout<<(int)(n+k)/2+1<<endl;
	}else{
		cout<<(int)(n+k)/2<<endl;
	}
		
 
	#ifdef DEBUG
		auto end=chrono::system_clock::now();
		cout<<"Elapsed time : "<<chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms."<<endl;
	#endif
	return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}

class TreeDP{//c++11
	public:
	struct edge{
		int to,cost;
	};
	int n;
	vi dist,siz,out;
	vector<vector<edge> >G;
	TreeDP(int size){
		n=size;
		dist=out=siz=vi(n);
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	int dfs1(int a,int par){
		int w=1;
		siz[a]=0;
		rep(i,G[a].size()){
			edge e=G[a][i];
			if(e.to==par)continue;
			int t=dfs1(e.to,a);
			(w*=t*nCr(siz[a]+siz[e.to],siz[e.to])%MOD)%=MOD;
			siz[a]+=siz[e.to];
		}
		siz[a]++;
		return w;
	}
	void dfs2(int a,int par){
		rep(i,G[a].size()){
			edge e=G[a][i];
			if(e.to==par)continue;
			int t=out[a];
			(t*=powmod(nCr(n-1,siz[e.to]),MOD-2))%=MOD;
			(t*=nCr(n-1,siz[e.to]-1))%=MOD;
			out[e.to]=t;
			dfs2(e.to,a);
		}
	}
	void dp(){
//		rep(i,n)cout<<dfs1(i,-1)<<endl;
		out[0]=dfs1(0,-1);
		dfs2(0,-1);
		rep(i,out.size())cout<<out[i]<<endl;
	}
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	TreeDP tr(n);
	rep(i,n-1){
		int a,b;cin>>a>>b;
		a--;b--;
		tr.add_edge(a,b,1);
	}
	tr.dp();
}












Measured memory_bytes: 30208
n = int(input())
a = [-1] + list(map(int, input().split()))

b = [0] * (n+1)
for i in reversed(range(1, n+1)):
    bi = 0
    for j in range(2, n//i + 1):
        bi += b[i*j]
    bi %= 2

    if bi != a[i]:
        b[i] = 1
    else:
        b[i] = 0

b_idx = [str(i) for i in range(1, n+1) if b[i] == 1]
m = len(b_idx)
print(m)
if m > 0:
    print(' '.join(b_idx))


Measured memory_bytes: 17204
/**
 * C - Many Medians
 * https://atcoder.jp/contests/abc094/tasks/arc095_a
 * 
 * 解法
 * 
 **/
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    vector<int> CP(N);
    for(int i=0; i<N; ++i) {
        cin >> X[i];
        CP[i] = X[i];
    }
    sort(CP.begin(), CP.end(), std::greater<int>());
    for(int i=0; i<N; i++) {
        if(CP[N/2-1]<=X[i]) {
            cout << CP[N/2] << endl;
        } else {
            cout << CP[N/2-1] << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3712
#include <vector>
#include <cstdio>
#include <climits>

using namespace std;

int V, E;

enum {
  WHITE,
  GREY,
  BLACK
};

vector<int> color;
vector<int> ord;
vector<int> low;

int k = 0;

void dfs(const vector<vector<int>> &g, int s, int from) {
  color[s] = GREY;
  ord[s] = low[s] = k++;
  for (auto t : g[s]) {
    if (color[t] == WHITE) {
      dfs(g, t, s);
    }
    if (t != from) {
      low[s] = min(low[s], low[t]);
    }
  }
  color[s] = BLACK;
}

int main() {
  scanf("%d", &V);
  scanf("%d", &E);

  color = vector<int>(V, WHITE);
  ord = vector<int>(V, INT_MAX);
  low = vector<int>(V, 0);

  vector<vector<int>> g(V);
  for (int i = 0; i < E; ++i) {
    int s, t;
    scanf("%d", &s);
    scanf("%d", &t);
    --s;
    --t;
    g[s].push_back(t);
    g[t].push_back(s);
  }

  dfs(g, 0, 0);
  int b = 0;
  for (int s = 0; s < V; ++s) {
    for (auto t : g[s]) {
      if (ord[s] < low[t]) ++b;
    }
  }
  printf("%d\n", b);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <optional>
#include <limits>

using namespace std;
using u = uint_fast32_t;
using U = uint64_t;

optional<U> checked_mul(const optional<U> &a, const U b) {
  if(!a) return nullopt;
  const auto a_ = a.value();
  U ans = a_ * b;
  return (a_ == 0 || b == ans / a_) ? make_optional(ans) : nullopt;
}

int main() {
  u n;
  cin >> n;
  optional<U> ans = 1;
  for(u i = 0; i < n; ++i) {
    U a;
    cin >> a;
    if(a == U(0)) {
      cout << "0\n";
      return 0;
    }
    ans = checked_mul(ans, a);
    if(ans && ans.value() > U(1000'000'000'000'000'000)) {
      ans = nullopt;
    }
  }
  if(!ans) {
    cout << "-1\n";
  } else {
  	cout << ans.value() << '\n';
  }
  return 0;
}

Measured memory_bytes: 3632