akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}



ll cvf(ll s){
	if(s%4 == 0) return s;
	if(s%4 == 1) return 1;
	if(s%4 == 2) return s+1;
	return 0;
}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll a, b;
	cin >>a >>b;
	
	//dbg("", cvf(a-1), cvf(b));
	if(a==0) cout << cvf(b) <<"\n";
	else cout <<( cvf(a-1) ^ cvf(b)) <<"\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

int main(){
    ll h, w, n, count=1;
    bool flag = false;
    cin >> h >> w >> n;
    ll a[n];
    RAP(i, n){
        cin >> a[i];
    }
    ll c[h][w];
    RAP(i, h){
        if(i%2){
            RAP(j, w){
                RAP(k, a[count-1]){
                    c[i][j]=count;
                    j++;
                    if(j==w ){
                        if(k<a[count-1]-1){
                            a[count-1] -= k+1;
                            flag = true;
                        }
                        break;
                    }
                }
                j--;
                if(!flag){
                    count++;
                }else{
                 	flag = false; 
                }
            }
        }else{
            for(ll j=w-1;j>=0;j--){
                RAP(k, a[count-1]){
                    c[i][j]=count;
                    j--;
                    if(j==-1 ){
                        if(k<a[count-1]-1){
                            a[count-1] -= k+1;
                            flag = true;
                        }
                        break;
                    }
                }
                j++;
                if(!flag){
                    count++;
                }else{
                 	flag = false; 
                }
            }
        }
        
    }
    RAP(i, h){
        RAP(j, w){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    ll s[10000];
    rep(i,n){
        cin>>s[i];
    }
    int q;
    cin>>q;
    ll t[500];
    rep(i,q){
        cin>>t[i];
    }
    int count=0;
    rep(i,q){
        rep(j,n){
            if(t[i]==s[j]){
                count++;
                break;
            }
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;int n,p[1363];int main(){scanf("%d",&n);for(int i=2;n;++i){if(p[i]<1){if(i%10==1||i<3){printf("%d ",i);--n;}for(int j=i*i;j<=1362;j+=i)p[j]=1;}}}

Measured memory_bytes: 256
def getPostorder(preorder, inorder):
    if not preorder:
        return []
    postorder = []
    root = preorder[0]
    rootIndex = inorder.index(root)

    postorder.extend(getPostorder(preorder[1:rootIndex + 1], inorder[:rootIndex]))
    postorder.extend(getPostorder(preorder[rootIndex + 1:], inorder[rootIndex + 1:]))
    postorder.append(root)

    return postorder 

if __name__ == '__main__':
    n = int(input())
    preorder = list(map(int, input().split()))
    inorder = list(map(int, input().split()))
    print(*getPostorder(preorder, inorder))

Measured memory_bytes: 7780
s = input()
t = input()
n = len(t)
ans = float('inf')
for i in range(len(s)-n+1):
    tmp = 0
    for j in range(n):
        if t[j]!=s[i+j]:
            tmp += 1
    ans = min(ans,tmp)
print(ans if ans != float('inf') else 0)

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

int main() {
  unsigned long int n;
  cin >> n;
  n = n%10;
  if(n==2 || n==4 || n==5 || n==7 || n==9){
    cout << "hon";
  }else if(n==0 || n==1 || n==6 || n==8){
    cout << "pon";
  }else{
    cout << "bon";
  }
  return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <algorithm>
#include <vector>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<intmax_t> a(N);
  intmax_t sum = 0;
  for (auto& ai: a) {
    scanf("%jd", &ai);
    sum += ai;
  }

  intmax_t x = a[0];
  intmax_t res = std::abs(x-(sum-x));
  for (size_t i = 1; i+1 < N; ++i) {
    x += a[i];
    intmax_t y = sum-x;
    res = std::min(res, std::abs(x-y));
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,b,ans=0;
int a[105],f[105][105];
int x[2][105],cnt[2],c;
int p[10000005],prime[3000005],tot=0;
int vis[105],link[105];

int dfs(int x){
	for(int i=1;i<=cnt[1];i++){
		if(vis[i]==0&&f[x][i]==1){
			vis[i]=1;
			if(link[i]==0||dfs(link[i])){
				link[i]=x;
				return 1;
			}
		}
	}
	return 0;
}

int main(){
	scanf("%d",&n);
	a[0]=-1;
	for(int i=2;i<=10000000;i++){
		if(p[i]==0) prime[++tot]=i;
		for(int j=1;j<=tot&&i*prime[j]<=10000000;j++){
			p[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
	p[1]=p[2]=1;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		if(a[i]==a[i-1]+1) continue;
		if(a[i-1]!=-1) x[c=(a[i-1]+1)&1][++cnt[c]]=a[i-1]+1;
		x[c=a[i]&1][++cnt[c]]=a[i];
	}
	x[c=(a[n]+1)&1][++cnt[c]]=a[n]+1;
	for(int i=1;i<=cnt[0];i++){
		for(int j=1;j<=cnt[1];j++){
			if(p[abs(x[0][i]-x[1][j])]==0) f[i][j]=1;
		}
	}
	for(int i=1;i<=cnt[0];i++){
		memset(vis,0,sizeof(vis));
		if(dfs(i)) ans++;
	}
	cnt[1]-=ans,cnt[0]-=ans;
	ans+=2*(cnt[1]/2+cnt[0]/2);
	if(cnt[1]&1) ans+=3;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 44928
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define en cout << endl
#define sp cout << " "
#define precision(x) cout << fixed << setprecision(x);
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);

ll T, TT = 1, mod = (ll)(1e9 + 7), a[N]={0}, b[N], c[N], fq[N] = {0}, ali = LLONG_MAX;
ll dp[201][201][201];
void file()
{
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
#endif
}
ll power(ll x, ll y, ll p = ali)
{
    x = x % p;
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
        {
            res = (res * x) % p;
        }
        x = (x * x) % p;
        y = y >> 1;
    }
    return res;
}

bool mycpm(ll x, ll y)
{
    if (x > y)
    {
        return 1;
    }
    return 0;
}
void dfs(vector<ll> *v, ll k, vector<ll> &wt)
{
    for (auto x : v[k])
    {
        if (wt[x] == 0)
        {
            wt[x] = 1;
            dfs(v, x, wt);
            wt[k] += wt[x];
        }
    }
}
void solve_testcase()
{
    int n;
    cin >> n;
    for(int i=3;i<=n;i++){
        a[i]=1;
        for(int j=3;j<=i-3;j++){
            a[i]=(a[i]+a[j])%mod;
        }
    }
    cout<<a[n];
}

int main()
{
    fio;
    file();
    //cin >> TT; //testcase
    for (T = 1; T <= TT; T++)
    {
        //cout<<"Case #"<<T<<": ";
        solve_testcase();
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int a,b,m;
  cin>>a>>b>>m;
  vecint A(a);
  for(auto&& e:A)cin>>e;
  vecint B(b);
  for(auto&& e:B)cin>>e;
  int ans = *boost::min_element(A) + *boost::min_element(B);
  for(auto&& i:irange(0,m)) {
    int x,y,c;
    cin>>x>>y>>c;
    --x;--y;
    ans = min(ans, A[x]+B[y]-c);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int n,k;
  string s;
  cin>>n>>k>>s;
  s.at(k-1)=(char)tolower(s.at(k-1));
  cout<<s<<endl;
}

Measured memory_bytes: 256
/**
		Author : Avi J Patel
		University : DA-IICT
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll r1=(b/c)-((a-1)/c);
	ll r2=(b/d)-((a-1)/d);
	ll LCM=(c*d)/__gcd(c,d);
	//cout<<LCM<<endl;
	ll r3=(b/LCM)-((a-1)/LCM);
	cout<<(b-a+1-(r1+r2-r3));
	return 0;
}








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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  long long res = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] < a[i - 1]) {
      res += a[i - 1] - a[i];
      a[i] = a[i - 1];
    }
  }   
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << '=' << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << ' '
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;


int main(){
    int N;
    cin >> N;
    vector<int> a(N),b(N,0);
    loop(i,N){
        cin >> a[i];
    }

    for(int i = N ; i >= 1; i--){
        int sum = 0;
        for(int j = i; j <= N; j += i){
            sum ^= b[j-1];
        }
        b[i-1] = sum^a[i-1];
    }

    vector<int> result;
    loop(i,N){
        if(b[i] == 1)result.push_back(i+1);
    }
    cout << result.size() << endl;
    loop(i,result.size()){
        cout << result[i] << " " << endl;
    }

}

Measured memory_bytes: 3192
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

void a();void b();void c();void d();void e();void f();

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

	// a();
	// b();
	// c();
	d();
	// e();
	// f();
	return 0;
}

void a(){
	string s;
	cin >> s;
	if(s == "ABC")puts("ARC");
	else puts("ABC");
}

void b(){
	int n, k;
	cin >> n >> k;
	vi adj[1500];
	forn(i, k){
		int d;
		cin >> d;
		forn(j, d){
			int x;
			cin >> x;
			adj[x].pb(i);
		}
	}
	int c = 0;
	for1(i, n){
		if(adj[i].size() == 0)c++;
	}
	cout << c;
}

void c(){
	vi adj[100050];
	int n, m;
	cin >> n >> m;
	vi ht(n + 1);
	for1(i, n)cin >> ht[i];
	forn(i, m){
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	int c = 0;
	for1(i, n){
		bool ok = true;
		for(auto j:adj[i]){
			if(ht[i] <= ht[j])ok = false;
		}
		if(ok)c++;
	}
	cout << c;
}

void d(){
	lint x;
	cin >> x;
	bool ok = true;
	for(lint i = -1e3;i <= 1e3; i++){
		lint b = i * i * i * i * i - x;
		for(lint j = -1e3; j <= 1e3; j++){
			if(j * j * j * j * j == b){
				ok = true;
				cout << i << ' ' << j;
				return;
			}
		}
	}
	assert(ok == true);
}

void e(){

}

void f(){

}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int key, u, w;
} data;
 
typedef struct {
	data obj[100001];
	int size;
} min_heap;
 
void push(data x, min_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key < h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

typedef struct {
	int *par, *size, *height;
} UF_forest;

void UF_initialize(UF_forest *F, int n)
{
	int i;
	F->par = (int*)malloc(sizeof(int) * (n + 1));
	F->size = (int*)malloc(sizeof(int) * (n + 1));
	F->height = (int*)malloc(sizeof(int) * (n + 1));
	for (i = 1; i <= n; i++) {
		F->par[i] = i;
		F->size[i] = 1;
		F->height[i] = 1;
	}
}

int UF_merge(UF_forest *F, int u, int v)
{
	for (; F->par[u] != u; u = F->par[u]);
	for (; F->par[v] != v; v = F->par[v]);
	if (u == v) return u;
	else if (F->height[u] > F->height[v]) {
		F->par[v] = u;
		F->size[u] += F->size[v];
		return u;
	} else {
		F->par[u] = v;
		F->size[v] += F->size[u];
		if (F->height[u] == F->height[v]) F->height[v]++;
		return v;
	}
}

int UF_root(UF_forest *F, int v)
{
	for (; F->par[v] != v; v = F->par[v]);
	return v;
}

int main()
{
	int i, N, M, X[100001];
	data d;
	min_heap h;
	h.size = 0;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%d", &(X[i]));
	for (i = 1; i <= M; i++) {
		scanf("%d %d %d", &(d.u), &(d.w), &(d.key));
		push(d, &h);
	}
	
	int ans = 0, r[3], vio[100001] = {};
	long long sum[100001];
	UF_forest F;
	UF_initialize(&F, N);
	for (i = 1; i <= N; i++) sum[i] = X[i];
	while (h.size > 0) {
		d = pop(&h);
		r[0] = UF_root(&F, d.u);
		r[1] = UF_root(&F, d.w);
		if (r[0] == r[1]) {
			if ((long long)d.key > sum[r[0]]) {
				vio[r[0]]++;
				ans++;
			}
		} else {
			r[2] = UF_merge(&F, r[0], r[1]);
			sum[r[2]] = sum[r[0]] + sum[r[1]];
			if ((long long)d.key > sum[r[2]]) {
				vio[r[2]] = vio[r[0]] + vio[r[1]] + 1;
				ans++;
			} else {
				ans -= vio[r[0]] + vio[r[1]];
				vio[r[2]] = 0;
			}
		}
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    string s, t;
    cin >> s >> t;
    if ( s == t.substr(0, (int)t.length()-1) ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
// inputに入力データ全体が入る
    // fizzBuzz
    function Main(inputString) {
        // 1行目がinput[0], 2行目がinput[1], …に入る
        let inputNumber = parseInt(inputString.trim());
        let arrNotFizzBuzzNumber = [];
        for(let i = 0; i <= inputNumber; i++ ){
            if( !((i % 3 == 0) || (i % 5 == 0))){
                arrNotFizzBuzzNumber.push(i);
            }
        }

            let sum = 0;
            arrNotFizzBuzzNumber.forEach(function(tmpNumber){
                sum += tmpNumber;
            });

    	//出力
    	console.log(sum);
    }
    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
    //Main('115')

Measured memory_bytes: 51612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

const int MAX_V = 105; //頂点の数の最大

// to　行先　cap 容量　rev　逆辺のindex
struct edge{ int to,cap,rev;};

vector<edge> G[MAX_V]; //グラフ
int level[MAX_V] = {-1}; // sからの距離 -1に初期化
int iter[MAX_V] = {0}; // どこまで調べ終わったか

//容量capの辺をfromからtoにはる。最初は逆辺の要領はゼロ
void add_edge(int from,int to,int cap){
    G[from].push_back(edge{to,cap,(int)(G[to].size())});
    G[to].push_back(edge{from,0,(int)(G[from].size()-1)});
}

void bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> q;
    level[s] = 0;
    q.push(s);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int i=0;i<G[v].size();i++){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                q.push(e.to);
            }
        }
    }
}

int dfs(int v,int t,int f){
    if(v == t) return f;
    for(int &i=iter[v];i<G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to,t,min(f,e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s,int t){
    int flow = 0;
    for(;;){
        bfs(s);
        if(level[t] < 0) return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f = dfs(s,t,INF)) > 0){
            flow += f;
        }
    }
}

int main(){
    int v,e;
    cin >> v >> e;
    rep(i,e){
        int a,b,c;
        cin >> a >> b >> c;
        add_edge(a,b,c);
    }
    cout << max_flow(0,v-1) << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back
#define eb emplace_back


int main()
{
    ll N, K;
    cin >> N >> K;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ASC(A);

    ll cnt = 0, m = 1;
    bool f = true;
    if(K % 2 == 1) {
        m = A[N-1];
        A.pop_back();
        ++cnt;
        if(m < 0) {
            m = (m + MOD) % MOD;
            f = false;
        }
    }
    ll left = 0, right = SZ(A) - 1;
    while(cnt < K) {
        if(f) {
            if(A[left]*A[left+1] > A[right]*A[right-1]) {
                m = (((m * A[left]) % MOD) * A[left+1])  % MOD;
                left += 2;
                cnt += 2;
            }
            else {
                m = (((m * A[right]) % MOD) * A[right-1]) % MOD;
                right -= 2;
                cnt += 2;
            }
        }
        else {
            REP(i,1,K) {
                m = (m * A[N-i-1]) % MOD;
            }
            break;
        }
    }

    m = (m < 0) ? (m + MOD) % MOD : m;
    PR(m);



    return 0;
}

/*



*/

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

double distance(double x,double y){
	return pow((pow(x,2) + pow(y,2)),0.5);
}
int main(){
	double n,d,dist,count=0;
  	cin >> n >> d;
  	while(n--){
    	int x1,y1;
        cin >> x1 >> y1;
        dist = distance(x1,y1);
      	if(dist <= d){
        	count++;
        }
     }
     cout << count;
}

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

int main()
{
    ll Q,H,S,D,N;
    cin >>Q >>H >>S >>D >>N;

    ll ans = 0;

    // 2L以下になるまで一番安い方法で買う
    ll num = N/2;
    ll p = min({D,S*2,H*4,Q*8});

    ans += p*num;
    N -= 2*num;

    // 2L以下の買い方を全探索
    ll t = LLONG_MAX;
    rep(i,9)rep(j,9)rep(k,9)rep(l,9)
    {
        ll ml = 250*i + 500*j + 1000*k + 2000*l;
        if(ml == 1000*N) t = min(t, i*Q+j*H+k*S+l*D);
    }
    ans += t;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (a : b : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . maximum $ [a + b, a - b, a * b]

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    vector<int> dp(N + 1, 0);
    int k = 0;
    rep(i, N) {
        int p = P[i];
        dp[p] = dp[p - 1] + 1;
        chmax(k, dp[p]);
    }

    int ans = N - k;
    cout << ans << endl;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

N,M,X,Y = map(int, input().split())
Xs = list(map(int, input().split()))
Ys = list(map(int, input().split()))

ch = 0
for z in range(X+1,Y+1):
    if max(Xs)<z and min(Ys)>=z:
        ch = 1
if ch == 0:
    print('War')
else:
    print('No War')


Measured memory_bytes: 5780
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<set<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace(b);
    G[b].emplace(a);
  }
  vector<Int> cs(n);
  for(Int i=0;i<n;i++) cin>>cs[i];
  sort(cs.begin(),cs.end());
  Int ans=0;
  for(Int i=0;i+1<n;i++) ans+=cs[i];
  
  vector<Int> vs(n);
  queue<Int> que;
  for(Int v=0;v<n;v++)
    if(G[v].size()==1u)
      que.emplace(v);  

  Int idx=0;
  while(!que.empty()){
    Int v=que.front();que.pop();  
    vs[v]=cs[idx++];
    for(Int u:G[v]){
      G[u].erase(v);
      if(G[u].size()==1u)
        que.emplace(u);        
    }
  }  
  
  cout<<ans<<endl;
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<vs[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder176
{
    class Program
    {
        static void Main(string[] args)
        {
            QB();
        }

        static void QA()
        {
            string line = Console.ReadLine();
            string[] splited = line.Split(' ');
            int N = int.Parse(splited[0]);
            int X = int.Parse(splited[1]);
            int T = int.Parse(splited[2]);

            Console.WriteLine(Math.Ceiling((double)N / X) * T);
        }

        static void QB()
        {
            string line = Console.ReadLine();
            long l = 0;
            foreach(char c in line)
            {
                l += short.Parse(c.ToString());
            }
            Console.WriteLine((l % 9 == 0) ? "Yes" : "No");
        }
    }
}


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){
    long long A,B,V,W,T;
    long long dist_0,dist_A,dist_B,tmp;

    cin>>A>>V>>B>>W>>T;

    dist_0=llabs(A-B);
    dist_A=V*T;
    dist_B=W*T;

    tmp=dist_A-dist_B;;

    if(tmp >= dist_0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }




    return 0;
}



Measured memory_bytes: 3636
n, m = map(int, input().split())
li = list()
for i in range(m):
    li.append(tuple(input().split()))
 
ac_cnt = 0
wa_cnt = 0
 
s_ac = set()
d_wa = dict()
for l in li:
    if l[1] == 'AC':
        if l[0] not in s_ac:
            s_ac.add(l[0])
            ac_cnt += 1
            wa_cnt += d_wa.get(l[0], 0)
        else:
            pass
    elif l[1] == 'WA':
        d_wa[l[0]] = d_wa.get(l[0], 0) + 1
 
print(ac_cnt, wa_cnt)

Measured memory_bytes: 27508
import itertools
n=int(input())
int_list=[int(input()) for i in range(n)]

# max min

int_list.sort()

if n%2 == 0:
    big = int_list[int(n)//2+1:]
    mid = int_list[int(n)//2-1:int(n)//2+1]
    min = int_list[:int(n)//2-1]
    result = 0
    a = mid[1]
    b = mid[0]

    for i, (plus, minus) in enumerate(zip(big, min)):
        if i%2 == 0:
            result += abs(b-plus)
            result += abs(a-minus)
            a = minus
            b = plus
        else:
            result += abs(b-minus)
            result += abs(a-plus)
            a = plus
            b = minus

    result += abs(a-b)
    print(result)
else:
    result_1 = 0
    result_2 = 0
    big = int_list[int(n)//2+2:]
    mid = int_list[int(n)//2:int(n)//2+2]
    min = int_list[:int(n)//2]
    left = mid[1]
    right = mid[0]

    for plus, minus in itertools.zip_longest(big, min):
        result_1 += abs(left - minus)
        if plus != None:
            result_1 += abs(minus - plus)
            left = plus
        else:
            left = minus

    result_1 += abs(left - right)

    big = int_list[int(n)//2+1:]
    mid = int_list[int(n)//2-1:int(n)//2+1]
    min = int_list[:int(n)//2-1]
    left = mid[0]
    right = mid[1]
    for plus, minus in itertools.zip_longest(big, min):
        result_2 += abs(left - plus)
        if minus != None:
            result_2 += abs(minus - plus)
            left = minus
        else:
            left = plus

    result_2 += abs(left - right)

    print(max(result_1, result_2))

Measured memory_bytes: 8284
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<long long> B(N + 1, 0); //累積和テーブル
	int mod = 1000000007;
 
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		B[i + 1] = B[i] + A[i];
	}
 
	long ans = 0;
 
	//i について全探索する
	for (int i = 0; i < N; i++)
	{
		//累積和を使ってA[i+1] + ... + A[N] を求める
		long long sum = (B[N] - B[i + 1]) % mod;
 
		ans += A[i] * sum;
		ans %= mod;
	}
 
	cout << ans << endl;
}

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<ll>
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)

using namespace std;
void OJ();

#define ld long double
void solve(){
    int a , b , c;
    cin >> a >> b >> c;

    if ( a <= c && a+b >= c )
        cout << "YES";
    else
        cout << "NO";
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //OJ();

    int t = 1;
    //cin >> t;
    while ( t-- ){
        solve();
    }
    return  0;
}

void OJ(){
#ifndef ONLINE_JUDGE
    freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\in.txt" , "r" , stdin  );
   // freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\out.txt", "w" , stdout );
#endif // ONLINE_JUDGE
}



Measured memory_bytes: 384
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
zo(x)=x==0?-1:1

function bitp(x::Array{Int,1})
	k = length(x)
	for i in 1:k-1
		if x[k-i+1] > 1
			x[k-i+1] = 0
			x[k-i] += 1
		end
	end
	if x[1] > 1
		0
	else
		x
	end
end

function main()
	n,m = readline() |> split |> parseMap
	a = Array{Int}(4,n)
	for i in 1:n
		a[1:3,i] = readline() |> split |> parseMap
	end
	maxim = 0
	bt = [0,0,0]
	for i in 1:8
		for j in 1:n
			a[4,j] = zo(bt[1])*a[1,j]+zo(bt[2])*a[2,j]+zo(bt[3])*a[3,j]
		end
		a = sortcols(a,by=x->x[4],rev=true)
		maxim = max(maxim,abs(sum(a[1,1:m]))+abs(sum(a[2,1:m]))+abs(sum(a[3,1:m])))
		bt[3] += 1
		bt = bitp(bt)
	end
	println(maxim)
end

main()


Measured memory_bytes: 131752
import java.awt.geom.*;
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			HashSet<String> set = new HashSet<String>();
			for(int i = 0 ; i < n; i++){
				set.add(sc.next());
			}
			int m = sc.nextInt();
			StringBuilder sb = new StringBuilder();
			boolean isclose = true;
			for(int i = 0 ; i < m; i++){
				String s = sc.next();
				if(set.contains(s)){
					if(isclose){
						isclose = false;
						sb.append("Opened by " + s + "\n");
					}
					else{
						isclose = true;
						sb.append("Closed by " + s + "\n");
					}
				}
				else{
					sb.append("Unknown " + s + "\n");
				}
			}
			System.out.print(sb.toString());
		}
	}

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

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    int ans = A+B;

    if (ans % 2 == 0)
    {
        cout << (A+B) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }
int n;
int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  cin >> n;
  int m = 1; while (m * (m + 1) / 2 < n) m++;
  for (int i = 1; i < m + 1; i++) {
    if (i == m * (m + 1) / 2 - n) continue;
    cout << i << '\n';
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
int cmp(const void *a, const void *b){return (*(ll*)a > *(ll*)b)?-1:1;}

int p[]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}, n, a[30]={}, b=0, c=0, d=0, e=0, f=0;

int main(){
    scanf("%d", &n);
    for(int i=0; i<25; i++){
        int m = n;
        while(m){
            m /= p[i];
            a[i] += m;
        }
        if(a[i] >= 2)b++;
        if(a[i] >= 4)c++;
        if(a[i] >= 14)d++;
        if(a[i] >= 24)e++;
        if(a[i] >= 74)f++;
    }
    printf("%d\n", (b-2)*c*(c-1)/2 + (c-1)*d + (b-1)*e + f);
}

Measured memory_bytes: 128
def sort(a, n):
	print(" ".join(map(str, a)))
	for i in range(1, N):
		v = a[i]
		j = i - 1
		while 0 <= j and v < a[j]:
			a[j + 1] = a[j]
			j -= 1
		a[j + 1] = v
		print(" ".join(map(str, a)))

N = int(input())
A = list(map(int, input().split()))

sort(A, N)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
//#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    int ans = 1e9;
    for (int i = -100; i <= 100; i++) {
        int cur = 0;
        for (auto &j : a) {
            cur += sqr(j - i);
        }
        ans = min(ans, cur);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

int main(){
    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    string res;
    int cnt_B = 0;
    for (int i = 0; i < s.size(); i++){
	if (s[i] == 'B'){
	    cnt_B++;
	} else if (cnt_B > 0){
	    cnt_B--;
	} else {
	    res += s[i];
	}
    }

    reverse(res.begin(), res.end());
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=list(input())
ans=0

for i in range(1,n):
    left=set([])
    right=set([])
    for j in range (0,i):
        left.add(s[j])

    for j in range (i,n):
        right.add(s[j])
    
    both=right&left
    ans=max(ans,len(both))
    

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 5e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
string s;
int ans = 0;
void Zfunction(string s){
	int n = s.length();
	vector<int> z(n,0);
	int x = 0, y = 0;
	for(int i=1; i<n; i++){
		// z[i] = max(0, min(z[i-x], y-i+1));
		if (i <= y) z[i] = min(z[i-x], y-i+1);

		while(i+z[i] < n && s[i+z[i]] == s[z[i]]){
			z[i]++;
		}
		if (i+z[i]-1 > y) {
			x = i; y = i+z[i]-1;
		}
		ans = max(ans, min(z[i],i));
	}
}
int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n >> s;
	string tmp = "";
	for(int i=n-1; i>=0; i--){
		tmp = s[i] + tmp;
		Zfunction(tmp);
	}
	cout << ans << endl;

	return 0;
}


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

int main()
{
    long long n,m;
    cin >> n >> m;
    if(n==1&&m==1)
    {
        cout << 1 << endl;
        return 0;
    }
    if(n==1)
    {
        cout << m-2 << endl;
        return 0;
    }
    if(m==1)
    {
        cout << n-2 << endl;
        return 0;
    }
    long long ans=n*m-n*2-m*2+4;
    cout << ans << endl;
    return 0;
}


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

#define BR "\n"
#define SP " "

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

  vector<vector<vector<ll>>> P(5, vector<vector<ll>>(4, vector<ll>(11, 0)));
  for (int i = 0; i < N; i++) {
    ll b, f, r, v;
    cin >> b >> f >> r >> v;
    P[b][f][r] += v;
  }

  for (int i = 1; i < 5; i++) {
    for (int j = 1; j < 4; j++) {
      for (int k = 1; k < 11; k++) {
        cout << SP << P[i][j][k];
      }
      cout << BR;
    }
    if (i < 4) cout << "####################" << BR;
  }

  return 0;
}


Measured memory_bytes: 3160
n = int(input())
dp = [n+1 for i in range(n+1)]
dp[0] = 0
for i in range(n):
    dp[i+1] = min(dp[i]+1, dp[i+1])
    j = 1
    while i + 6 ** j <= n:
        dp[i+6**j] = min(dp[i]+1, dp[i+6**j])
        j += 1
    j = 1
    while i + 9 ** j <= n:
        dp[i+9**j] = min(dp[i]+1, dp[i+9**j])
        j += 1
print(dp[n])

Measured memory_bytes: 45040
n, k = list(map(int, input().split()))

a = [int(input()) for _ in range(n)]
a.sort()
b = 0
ans = []

for i in range(n - k + 1):
    b = a[i + k - 1] - a[i]
    ans.append(b)
ans.sort()
print(ans[0])

Measured memory_bytes: 11288
#include <iostream>

using namespace std;

int main()
{
    int L, R, d;    
    cin >> L >> R >> d;
    //cout << 

    int count = 0;
    for(int i = L; i <= R; ++i)
    {
        if(i % d == 0)
        {
            count++;    
        }
    }
    cout << count << endl;

    return 0;    
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	map< int, int > d;
	M = N;
	for (int i = 2; i * i <= M; i++) {
		while (M % i == 0) {
			d[i]++;
			M /= i;
		}
	}
	if (M > 1)
		d[M]++;
	int ans = 0;
	for (auto p : d) {
		int c = 1;
		while (p.second >= c) {
			ans++;
			p.second -= c;
			c++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
int a[64] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin >> k;
cout << a[k-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set <int> a;
int main(){
    int i,n;
    cin>>n;
    int x;
    for(i=1;i<=n;i++){
    	cin>>x;
    	a.insert(x);
	}
	cout<<a.size()<<endl;
	return 0;
}


Measured memory_bytes: 256
tmp = [int(i) for i in input().split()]
N,Q = tmp[0],tmp[1]
S = [str(i) for i in input().split()][0]

cnt=0
num=[0]
for i in range(len(S)):
  if S[i-1]=='A':
    if S[i]=='C':
      cnt+=1
  num.append(cnt)

for i in range(Q):
  L = [int(i) for i in input().split()]
  print(num[L[1]]-num[L[0]])

Measured memory_bytes: 6200
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){

	int n[15]={};

	int x;
	cin>>x;
	int max=0;
	for(int i=0;i<x;i++)
	{
		
		cin>>n[i];
		if(max<n[i])max=n[i];
	}

	int k=1;
	for(int i=2;i<=max;i++){bool f=false;
		for(int j=0;j<x;j++)
			{
				if(n[j]%i==0){
					f=true;n[j]/=i;
				}
		}
		if(f==true){k*=i;i=1;}
	}
	for(int i=0;i<x;i++)
		k*=n[i];

	cout<<k<<endl;
	return  0;

}

	

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
int main() {
	char F;
	int fC = 0;
	while( (F=getchar()) != EOF ){
		if( F == 'C' ) fC++;
		if( fC && F == 'F' ) {printf( "Yes\n"); exit(0);}
	}

	printf( "No\n" );
	exit(0);
}



Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] l = new int[n];
    int ans = 0;
    for (int cnt = 0; cnt < n; cnt++) {
      l[cnt] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < i; j++) {
        for (int k = 0; k < j; k++) {
          int[] tmpl = { l[i], l[j], l[k] };
          if( tmpl[0] == tmpl[1]) continue;
          if( tmpl[1] == tmpl[2]) continue;
          if( tmpl[2] == tmpl[0]) continue;
          Arrays.sort(tmpl);
          if (tmpl[2] < tmpl[0] + tmpl[1]) {
            ans++;
          }
        }
      }
    }
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 41696
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> S;
  cout << S[0]<< S.length()-2 << S[S.length()-1];

}


Measured memory_bytes: 256
from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9+7
dp = [[0 for i in range(k+1)] for j in range(n+1)]
dp[0][0] = 1
asum = 0
for i in range(1,n+1):
  acc = list(accumulate(dp[i-1]))
  ai = a[i-1]
  asum += ai
  for j in range(min(k,asum)+1):
    dp[i][j] = acc[j]
    if j > ai:
      dp[i][j] -= acc[j-ai-1]
    dp[i][j] %= mod
print(dp[n][k])

Measured memory_bytes: 186504
import java.util.*;
public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		
		for(int i=0; i<N+1; i++) {
			 A[i] = keyboard.nextInt();
		}
		for(int j=0; j<N; j++) {
			 B[j] = keyboard.nextInt();
		}
		
		long count = 0;
		for(int k = N; k>=1; k--) {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		}
		System.out.println(count);
		keyboard.close();	
	}
}


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

int rightSide(int top, int face){
	int result;
	if(top == 0){
		if(face == 1){ result = 2; }
		else if(face == 2){ result = 4;}
		else if(face == 4){ result = 3;}
		else if(face == 3){ result = 1;}
	}else if(top == 1){
		if(face == 0){ result = 3; }
		else if(face == 3){ result = 5;}
		else if(face == 5){ result = 2;}
		else if(face == 2){ result = 0;}		
	}else if(top == 2){
		if(face == 4){ result = 0; }
		else if(face == 0){ result = 1;}
		else if(face == 1){ result = 5;}
		else if(face == 5){ result = 4;}		
	}else if(top == 3){
		if(face == 5){ result = 1; }
		else if(face == 1){ result = 0;}
		else if(face == 0){ result = 4;}
		else if(face == 4){ result = 5;}		
	}else if(top == 4){
		if(face == 2){ result = 5; }
		else if(face == 5){ result = 3;}
		else if(face == 3){ result = 0;}
		else if(face == 0){ result = 2;}		
	}else if(top == 5){
		if(face == 4){ result = 2; }
		else if(face == 2){ result = 1;}
		else if(face == 1){ result = 3;}
		else if(face == 3){ result = 4;}		
	}

	return result;
}

int main(){
	int dice[6];
	int n;
	int top, face;

	for(int i = 0; i < 6; i++){
		cin >> dice[i];
	}

	cin >> n;
	int indexOfTop, indexOfFace;

	for(int i = 0; i < n; i++){
		cin >> top >> face;

		for(int j = 0; j < 6; j++){
			if(dice[j] == top){
				indexOfTop = j;
			}
			if(dice[j] == face){
				indexOfFace = j;
			}
		}

		cout << dice[rightSide(indexOfTop, indexOfFace)] << endl;
	}


	return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

class UnionFind {
  std::vector<intmax_t> tree;

public:
  UnionFind(size_t n): tree(n, -1) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    return (tree[v] = find(tree[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-tree[u] >= -tree[v])
      std::swap(u, v);

    tree[v] += tree[u];
    tree[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<size_t> p(N);
  for (size_t i=0; i<N; ++i)
    scanf("%zu", &p[i]);

  UnionFind uf(N+1);
  for (size_t i=0; i<M; ++i) {
    size_t x, y;
    scanf("%zu %zu", &x, &y);
    --x;
    --y;

    uf.unite(p[x], p[y]);
  }

  int res=0;
  for (size_t i=N; i>0; --i)
    if (uf.connected(i, p[i-1]))
      ++res;

  printf("%d\n", res);
}


Measured memory_bytes: 1792