akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,V;
	cin >> N >> V;
	vector<ll> a(N),b(N),c(N),d(N);
	FOR(i,0,N)cin>>a[i];
	FOR(i,0,N)cin>>b[i];
	FOR(i,0,N)cin>>c[i];
	FOR(i,0,N)cin>>d[i];
	vector<ll> A,B;
	FOR(i,0,N)FOR(j,0,N)A.push_back(a[i]+b[j]);
	FOR(i,0,N)FOR(j,0,N)B.push_back(c[i]+d[j]);
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	ll ans = 0;
	FOR(i,0,A.size()){
		ll x = A[i];
		ll xnum = NUM(A,x);
		i+=xnum;i--;
		ll y = V-x;
		ll ynum = NUM(B,y);
		ans += xnum * ynum;
	}
	cout << ans << endl;
}


Measured memory_bytes: 23140
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n,k;
    R(n,k);
    VI a(n+1);
    FOR(i,1,n)R(a[i]);
    FOR(i,2,n)a[i]+=a[i-1];
    int ma=0;
    FOR(i,k,n){
        ma=max(ma,a[i]-a[i-k]);
    }
    W((ma+k)*0.5);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(void){
    int i,len;
    char s[4096],p[4096],s2[4096];
    scanf("%s",s);
    scanf("%s",p);
    sprintf(s2,"%s%s",s,s);
    puts(strstr(s2,p)==NULL?"No":"Yes");
    return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin >> x;
    for(ll a = -1000;a<=1000;a++){
        for(ll b = -1000;b<=1000;b++){
            if(a*a*a*a*a - b*b*b*b*b == x){
                cout << a << " " << b <<endl;
                return 0;
            }
        }
    }
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define minit(a,b) memset(a, b, sizeof(a))

int N, M, memoM1[111][111], memoM2[111][3][3];
const int MOD = (int)1e6;

void modAdd(int& a, int add) { a = (a + add) % MOD; }

int recM1(int y, int cnt) {
	if (y == N + 1) {
		if (cnt % 2) return 1;
		return 0;
	}
	
	int& res = memoM1[y][cnt];
	if (res != -1) return res;
	res = 0;
	
	modAdd(res, recM1(y + 1, cnt));
	modAdd(res, recM1(y + 1, cnt + 1));
	
	return res;
}

int recM2(int y, int x, int s) {
	if (y == N + 1) {
		if (s == 0 && x == 2) return 1;
		return 0;
	}
	
	int& res = memoM2[y][x][s];
	if (res != -1) return res;
	res = 0;
	
	modAdd(res, recM2(y + 1, x, s));
	
	if (x == 0) {
		assert(s != 1);
		
		if (s == 0) {
			modAdd(res, recM2(y + 1, 0, 2));
			modAdd(res, recM2(y + 1, 1, 0));
			modAdd(res, recM2(y + 1, 2, 0));
		} else {
			modAdd(res, recM2(y + 1, 2, 0));
		}
	}
	
	if (x == 1) {
		assert(s == 0);
		modAdd(res, recM2(y + 1, 0, 0));
		modAdd(res, recM2(y + 1, 2, 0));
	}
	
	if (x == 2) {
		assert(s != 2);
		
		if (s == 0) {
			modAdd(res, recM2(y + 1, 2, 1));
			modAdd(res, recM2(y + 1, 1, 0));
			modAdd(res, recM2(y + 1, 0, 0));
		} else {
			modAdd(res, recM2(y + 1, 0, 0));
		}
	}
	
	return res;
}

int main() {
	cin >> N >> M;
	
	if (M == 1) {
		minit(memoM1, -1);
		cout << recM1(0, 0) << endl;
	} else {
		minit(memoM2, -1);
		cout << recM2(0, 0, 0) << endl;
	}
}

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

int main(void){
  int a,b;
  cin >> a >> b;
  if (a>b)
  {
    cout << "a > b" << endl;
  }else if (a<b)
  {
    cout << "a < b" << endl;
  }else
  {
    cout << "a == b" << endl;
  }
  return 0;
}


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

int main(void){
    
    int H,N,A;
    cin >> H >> N;
    
    for(int i=0;i<N;i++){
        cin >> A;
        H -= A;
        if(H <= 0){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    
    cout << "No" <<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
long long n,h[100010],dp[100010];

int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&h[i]);
	}
	for(int i=2;i<=n;i++)
	{
	//	printf("%d %d %d %d\n",dp[i-1],dp[i-2],h[i-1]-h[i],h[i-2]-h[i]);
		if(i-1>=0) dp[i] = dp[i-1]+abs(h[i-1]-h[i]);
		if(i>2)
		{
			
			dp[i] = min(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
		}
	//	printf("%d. %d\n",i,dp[i]);
	}
	printf("%lld\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<iomanip>
#include<string>
#include<string.h>
#include<cctype>
using namespace std;
int main()
{

    int x[5];

    for(int i=0;i<5;i++)
    {
         cin>>x[i];



    }
    for(int i=0;i<5;i++)
    {
         if(x[i]==0)
            cout<<i+1<<endl;
    }












    return 0;
}



Measured memory_bytes: 3632
#include<stdio.h>

int main(){

	int i,j,n;
	int item[5000],sum,Max;

	while(scanf("%d",&n)!=EOF){
		if(n==0) break;
		Max=-9999999;
		i=0;
		while(i<n) scanf("%d",&item[i++]);

		for(i=0;i<n;i++){
			sum=0;
			for(j=i;j<n;j++){
				sum+=item[j];
				if(Max<sum) Max=sum;
				
			}
					
		}
		printf("%d\n",Max);


	}



	return 0;
}

Measured memory_bytes: 620
package main

import (
	"fmt"
)

func main() {
	var r int
	fmt.Scan(&r)
	fmt.Println(r * r)
}

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

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

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


Measured memory_bytes: 1772
#include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    const int md = 1e9+7;
     
    int n, a[22][22];
    int dp[22][1<<22];
     
    int fun(int i, int m){
        if(i == n) return 1;
     
        int &ans = dp[i][m];
        if(ans != -1) return ans;
     
        ans = 0;
        for(int j=0; j<n; j++)
        if(a[i][j] && !(m & (1<<j)))
            ans += fun(i+1, m|(1<<j)), ans%=md;
        return ans;
    }
     
    int main(){
     
        cin.tie( nullptr );
        ios_base::sync_with_stdio(0);
     
        cin >> n;
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                cin >> a[i][j];
     
        memset(dp, -1, sizeof dp);
        cout << fun(0, 0) << "\n";
     
        return 0;
    }

Measured memory_bytes: 364032
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

int a[20];

inline ll dp(int l, int r, int L, int R) {
	if(l == r - 1) return 0;
	ll res = 1LL << 60;
	for(int i = l + 1; i <= r - 1; i++)
		chkmin(res, dp(l, i, L, L + R) + dp(i, r, L + R, R) + 1LL * (L + R) * a[i]);
	return res;
}

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri;
	for(int i = 1; i <= n; i++) a[i] = ri;
	cout << a[1] + a[n] + dp(1, n, 1, 1) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

const int max_n = 202020;
int n;
vector<int> g[max_n];
vector<int> v0, v1, v2;
vector<int> ans;
vector<bool> used;

int tcnt = 0, fcnt = 0;

bool tog, first;

void dfs1(int u, bool flg){
	used[u] = true;
	if(flg) tcnt++;
	else fcnt++;
	for(int v : g[u]){
		if(used[v]) continue;
		dfs1(v, !flg);
	}
}

void dfs2(int u, bool flg){
	int l0 = v0.size();
	int l1 = v1.size();
	int l2 = v2.size();
	if(flg){
		if(l1 > 0){
			ans[u] = v1[l1 - 1];
			v1.pop_back();
		}else{
			ans[u] = v0[l0 - 1];
			v0.pop_back();
		}
	}else{
		if(l2 > 0){
			ans[u] = v2[l2 - 1];
			v2.pop_back();
		}else{
			ans[u] = v0[l0 - 1];
			v0.pop_back();
		}
	}

	for(int v : g[u]){
		if(ans[v] > 0) continue;
		dfs2(v, !flg);
	}
}

void dfs3(int u, int p, bool flg){
	int l0 = v0.size();
	int l1 = v1.size();
	int l2 = v2.size();
	if(!first && flg != tog){
		if(l1 > 0){
			ans[u] = v1[l1 - 1];
			v1.pop_back();
		}else if(l2 > 0){
			ans[u] = v2[l2 - 1];
			v2.pop_back();
		}else{
			ans[u] = v0[l0 - 1];
			v0.pop_back();
		}
	}else if(first && flg == tog){
		ans[u] = v0[l0 - 1];
		v0.pop_back();
	}

	for(int v : g[u]){
		if(v == p) continue;
		dfs3(v, u, !flg);
	}
}

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

	cin >> n;
	ans.resize(n, 0);
	used.resize(n, false);

	rep(i, n - 1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);		
	}

	rep(i, n){
		if((i+1) % 3 == 0) v0.push_back(i+1);
		if((i+1) % 3 == 1) v1.push_back(i+1);
		if((i+1) % 3 == 2) v2.push_back(i+1);
	}



	dfs1(0, true);
	if(tcnt > n/3 && fcnt > n / 3) dfs2(0, true);
	else if(fcnt <= n / 3) {
		tog = false;
		first = true;
		dfs3(0, -1, true);
		first = false;
		dfs3(0, -1, true);
	}else{
		tog = true;
		first = true;
		dfs3(0, -1, true);
		first = false;
		dfs3(0, -1, true);
	}

	rep(i, n) cout << ans[i] << (i == n - 1 ? "\n" : " ");
}


Measured memory_bytes: 19320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> ans(n);
    rep(i, n) ans[a[i] - 1] = i + 1;
    rep(i, n) cout << ans[i] << ' ';
}


Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  cin>>n;
  int out=1;
  rep(i,n){
    int in;cin>>in;
    out=out*in/__gcd(out,in);
  }
  cout<<out<<endl;
}

Measured memory_bytes: 1164
from collections import deque
s = deque(list(input()))
editor = deque()
while s:
  x = s.popleft()
  if x == "0":
    editor.append("0")
  elif x == "1":
    editor.append("1")
  elif x == "B" and len(editor) != 0:
    editor.pop()
print("".join(editor))

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AtoZString(param);

	}

	static void AtoZString(String[] param) { //2行、Iで1追加し、Dで1減らす、処理後の最大値を出力[1]
		int K = Integer.parseInt(param[0]);
		int S = Integer.parseInt(param[1]);
		
		int count = 0;
		
		for(int i = 0; i <= K; i++){
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		}
		System.out.println(count);
	}
}

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

int main() {
  vector<int> Di(5);
  vector<int> Dis(5);
  for (int i = 0; i < 5; i++) {
    cin >> Di.at(i);
  }
  
  for (int i = 0; i < 5; i++) {
    Dis.at(i) = (Di.at(i) - 1) % 10;
  }
  
  int min, sum;
  sum = 0;
  sort(Dis.begin(), Dis.end());
  
  for (int i = 0; i < 5; i++) {
    if ((Di.at(i) - 1) % 10 == Dis.at(0)) {
      min = i;
      break;
    }
  }
  
  for (int i = 0; i < 5; i++) {
    sum += ((Di.at(i) - 1) / 10 + 1) * 10;
  }
  
  sum -= ((Di.at(min) - 1) / 10 + 1) * 10;
  sum += Di.at(min);
  cout << sum << endl;
}

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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  long long N,K;
  cin >> N >> K;
  
  Vi P(N);
  Vi C(N);
  rep(i,N){
    cin >> P[i];
    P[i]--;
  }
  rep(i,N){
    cin >> C[i];
  }
  
  
  ll ans = -1000000000000000000;
  
  rep(i,N){
  
    int circnt = 0;
    ll cirsum = 0;
    
    int v = i;
    
    while(true){
    	circnt++;
        cirsum += C[P[v]];       
        v = P[v];        
        if(v==i) break;
    }
    
    
    
    
    v = i;
    int counter = 0;
    
    ll cirsum2 = 0;
    
    while(true){
      counter++;
      cirsum2 += C[P[v]];
      v = P[v];   
      
      
      if(counter>K) break;
      
      ll num = (K-counter)/circnt;
      
      ll sum = cirsum2 + max(0LL, num*cirsum);
      ans = max(ans, sum);
      
        
      if(v==i) break;
    }
  }
  cout << ans << endl;
}

      
      
       




Measured memory_bytes: 3684
#include <iostream>
#include <climits>
#include <vector>
using namespace  std;

void fnInput(vector<string>& rvsStrX, vector<string>& rvsStrY)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvsStrX.resize(nMaxSiz);
  rvsStrY.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; ++i)
  {
    cin >> rvsStrX[i] >> rvsStrY[i];
    rvsStrX[i] = ' ' + rvsStrX[i];
    rvsStrY[i] = ' ' + rvsStrY[i];
  }
}

int fnLngCmnSubseq(const vector<string>& cnrvsStrX, const vector<string>& cnrvsStrY)
{
  for (int i = 0; i < cnrvsStrX.size(); ++i)
  {
    const int nMAXNX = cnrvsStrX[i].size();
    const int nMAXNY = cnrvsStrY[i].size();
    vector<vector<int>> vvnLcsDP(nMAXNX, vector<int>(nMAXNY, 0));

    for (int nx = 1; nx < nMAXNX; ++nx)
      for (int ny = 1; ny < nMAXNY; ++ny)
        if (cnrvsStrX[i][nx] == cnrvsStrY[i][ny])
          vvnLcsDP[nx][ny] = vvnLcsDP[nx - 1][ny - 1] + 1;
        else
          vvnLcsDP[nx][ny] = max(vvnLcsDP[nx - 1][ny], vvnLcsDP[nx][ny - 1]);

    cout << vvnLcsDP[nMAXNX - 1][nMAXNY - 1] << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> vsStrX, vsStrY;

  fnInput(vsStrX, vsStrY);
  fnLngCmnSubseq(vsStrX, vsStrY);
  return 0;
}

Measured memory_bytes: 6880
#include <iostream>
#define _for(i,a,b) for(int i = (a); i < b; ++i)
#define _rep(i,a,b) for(int i = (a); i <= b; ++i)
using namespace std;
int a[10+2];
bool flag = 0;
void dfs(int i, int l, int r){
    if(flag) return;
    if(i == 10) {
        flag = 1;
        return;
    }
    if(a[i] > l) dfs(i+1, a[i], r);
    if(a[i] > r) dfs(i+1, l, a[i]);
}
int main(){
    int n;
    cin>>n;
    while(n--){
        flag = 0;
        _for(i,0,10) cin>>a[i];
        dfs(0,0,0);
        if(flag) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3080
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr ll mod = 1000000007LL;

ll modpow(ll a, ll b) {
	if (b == 0) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b % 2 == 0)
		return tmp * tmp % mod;
	return tmp * tmp % mod * a % mod;
}

int main(void) {
	int N; cin >> N;
	map<int, int> A_cnt;
	for (int i = 0; i < N; ++i) {
		int Ai; cin >> Ai;
		++A_cnt[Ai];
	}
	bool check = true;
	for (int i = N - 1; i >= 0; i -= 2) {
		if (i == 0) check &= A_cnt[i] == 1;
		else check &= A_cnt[i] == 2;
	}
	if (!check) cout << 0 << endl;
	else cout << modpow(2, (N / 2)) << endl;
	return 0;
}

Measured memory_bytes: 7348
#include <bits/stdc++.h>
using namespace std;
bool u[11];
int a[10],x,y;
bool ck() {
  if(a[0]&&a[1]&&a[2]&&(a[0]+a[1]+a[2])%x!=y) return 0;
  if(a[3]&&a[4]&&a[5]&&(a[3]+a[4]+a[5])%x!=y) return 0;
  if(a[6]&&a[7]&&a[8]&&(a[6]+a[7]+a[8])%x!=y) return 0;
  if(a[0]&&a[3]&&a[6]&&(a[0]+a[3]+a[6])%x!=y) return 0;
  if(a[1]&&a[4]&&a[7]&&(a[1]+a[4]+a[7])%x!=y) return 0;
  if(a[2]&&a[5]&&a[8]&&(a[2]+a[5]+a[8])%x!=y) return 0;
  if(a[0]&&a[4]&&a[8]&&(a[0]+a[4]+a[8])%x!=y) return 0;
  if(a[2]&&a[4]&&a[6]&&(a[2]+a[4]+a[6])%x!=y) return 0;
  return 1;
}

int dfs(int k) {
  if(!ck()) return 0;
  if(k==9) return 1;
  int ans=0;
  if(a[k]) ans+=dfs(k+1);
  else {
    for(int i=1; i<=10; i++) {
      if(u[i]) continue;
      a[k]=i;
      u[i]=1;
      ans+=dfs(k+1);
      a[k]=0;
      u[i]=0;
    }
  }
  return ans;
}

int main() {
  while(1) {
    memset(u,0,sizeof(u));
    for(int i=0; i<10; i++) {
      cin >> a[i];
      u[a[i]]=1;
    }
    if(a[0]==-1) break;
    x=a[9];
    int ans=0;
    if(!x) {
      for(int i=1; i<11; i++) {
        if(u[i]) continue;
        x=i;
        u[i]=1;
        for(int j=0; j<x; j++) {
          y=j;
          ans+=dfs(0);
        }
        u[i]=0;
      }
    } else {
      for(int j=0; j<x; j++) {
        y=j;
        ans+=dfs(0);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
struct Node
{
	int key;
	Node* parent;
	Node* left;
	Node* right;
};
Node* root;
void insert(int val)
{
	Node* x = new Node();
	x->key = val;
	x->left = nullptr;
	x->right = nullptr;
	Node *q = nullptr;
	Node *p = root;
	while (p != nullptr)
	{
		q = p;
		if (x->key < p->key)
			p = p->left;
		else
			p = p->right;
	}
	x->parent = q;
	if (q == nullptr)
		root = x;
	else if (x->key < q->key)
		q->left = x;
	else
		q->right = x;
}
void inorder(Node* root)
{
	if (root == nullptr)
		return;
	inorder(root->left);
	printf(" %d", root->key);
	inorder(root->right);
}
void preorder(Node* root)
{
	if (root == nullptr)
		return;
	printf(" %d", root->key);
	preorder(root->left);
	preorder(root->right);
}
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		int t;
		cin >> s;
		if (s[0] == 'i')
		{
			cin >> t;
			insert(t);
		}
		else if (s[0] == 'p')
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}
}


Measured memory_bytes: 26768
class Node:
    def __init__(self,v):
        self.v = v
        self.c = []

def dfs(n,f,d,t,visited):
    visited.add(n.v)
    f[n.v] = t
    t2 = t
    for c in sorted(n.c,key=lambda x:x.v):
        if not c.v in visited:
            t2 = dfs(c,f,d,t2+1,visited)
    d[n.v] = t2+1
    return t2+1

n = int(raw_input())
nodes = {}
for _ in range(n):
    entry = map(int,raw_input().split(' '))
    nid = entry[0]
    if not nid in nodes: nodes[nid] = Node(nid)
    k = entry[1]
    if k > 0:
        children = entry[2:]
        for c in children:
            if not c in nodes: nodes[c] = Node(c)
            nodes[nid].c.append(nodes[c])

f = {}
d = {}
visited = set()
t = dfs(nodes[1],f,d,1,visited)
while len(visited) < len(nodes):
    for nid in nodes:
        if not nid in visited:
            t = dfs(nodes[nid],f,d,t+1,visited)

for k in f:
    print k,f[k],d[k]

Measured memory_bytes: 6504
x1, x2, x3, x4, x5 = map(int, input().split())
if x1 == 0:
    print("1")
elif x2 == 0:
    print("2")
elif x3 == 0:
    print("3")
elif x4 == 0:
    print("4")
elif x5 == 0:
    print("5")

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

typedef struct{
    char suit;
    int value;
    bool check;
}CARD;

bool checkStable(int n, CARD c[], CARD a[])
{
    for (int i = 0;i < n;i++)
    {
        for (int j = 0;j < n;j++)
        {
            if (a[i].value == c[j].value)
            {
                if (a[i].suit != c[j].suit)
                {
                    if (!c[j].check) return false;
                }
                else
                {
                    c[j].check = true;
                    break;
                }
            }
        }
    }
    for (int i = 0;i < n;i++)
    {
        c[i].check = false;
    }
    return true;
}

void bubbleSort(int n, CARD a[])
{
    for (int i = 0;i < n;i++)
    {
        for (int j = n-1;j >= i+1;j--)
        {
            if (a[j].value < a[j-1].value)
            {
                CARD temp = a[j];
                a[j] = a[j-1];
                a[j-1] = temp;
            }
        }
    }
}

void selectionSort(int n, CARD a[])
{
    for (int i = 0;i < n;i++)
    {
        int mini = i;
        for (int j = i;j < n;j++)
        {
            if (a[j].value < a[mini].value)
            {
                mini = j;
            }
        }
        if (mini != i)
        {
            CARD temp = a[i];
            a[i] = a[mini];
            a[mini] = temp;
        }
    }
}

int main ()
{
    int n;
    cin >> n;
    CARD card[n], bs[n], ss[n];
    for (int i = 0;i < n;i++)
    {
        cin >> card[i].suit >> card[i].value;
        card[i].check = false;
        bs[i] = card[i];
        ss[i] = card[i];
    }
    
    bubbleSort(n, bs);
    selectionSort(n, ss);
    
    bool BS = checkStable(n, card, bs);
    bool SS = checkStable(n, card, ss);
    
    for (int i = 0;i < n;i++)
    {
        cout << bs[i].suit << bs[i].value;
        if (i < n-1) cout << " ";
    }
    cout << endl;
    if (BS) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    
    for (int i = 0;i < n;i++)
    {
        cout << ss[i].suit << ss[i].value;
        if (i < n-1) cout << " ";
    }
    cout << endl;
    if (SS) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    
    return 0;
}



Measured memory_bytes: 3116
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;
 
int main() {
    int a,b,c,ans;
    cin >> a >> b >> c;
    
    if((b/a) > c){
        cout << c << endl;
    }else{
        cout << b / a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << endl
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
const int N=100000;
ull a[N],n,m,i,k;
int main()
{
	cin >> n>> m;
	k=n+m;
	if(n%m==0)
	{
		cout <<-1;
		return 0;
	}
	else
	{
		cout << n;
	}
	return 0;
}


Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n=0,m=0,d=0) Array.new(n){Array.new(m,d)}end
def na3(n=0,m=0,l=0,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
@n,k = inp
@lis = na2(@n+1,0)
@rev = na2(@n+1,0)
k.times do
  a,b,c = inp
  @rev[b].push(a)
  @lis[a].push([b,c])
end
@h = {}
@ans = -1e20
@memo = na(@n+1,-1e20)
@able = na(@n+1,false)
def sable(x)
  return if(@able[x])
  @able[x] = true
  @rev[x].each do |i|
    sable(i)
  end
end
sable(@n)
def zent(x,s,d)
  return unless(@able[x])
  if(d > 1500)
    puts  "inf"
    exit
  end
  if(x == @n)
    @ans = [@ans,s].max
  end
  return if(@memo[x] >= s)
  @memo[x] = s
  @lis[x].each do |aa|
    zent(aa[0],s+aa[1],d+1)
  end
end
zent(1,0,0)
p @ans
=begin
=end


Measured memory_bytes: 6780
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	int n;
	cin >> n;
	set<ll> same;

	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		if (same.count(a) > 0) {
			cout << "NO" << endl;
			return 0;
		}
		same.insert(a);
	}
	cout << "YES" << endl;

	
	return 0;
}

Measured memory_bytes: 9600
N = gets.to_i

max_i = 1
max_n = 0
1.upto(N) do |i|
  next if i.odd?
  v = i
  c = 0
  while v.even?
    v = v / 2
    c += 1
  end

  if c > max_n
    max_n = c
    max_i = i
  end
end

p max_i

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
#include <iomanip>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N, a; cin >> N;
VI B(N); 
rep(i, 0, N) {
    cin >> a;
    B[a-1] = i + 1;
}

rep(i, 0, N){
    cout << B[i] << ' ';
}

cout << "\n";


}

// 境界，出力文字列 チェック



Measured memory_bytes: 1280
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a[100],b,c,d,x,flag=0;
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<(a[0]*a[1])/2<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),k=in();
    if(k>(n-1)*(n-2)/2){
        cout<<-1<<endl;
        return 0;
    }
        int m=n*(n-1)/2-k;
        cout<<m<<endl;
        rep(i,n-1){
            cout<<1<<" "<<i+2<<endl;
        }
        int cnt=n-1;
        bool flag = true;
        for(int i=2;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if(cnt==m){
                    flag = false;
                    break;
                }
                cout<<i<<" "<<j<<endl;
                cnt++;
            }
            if(!flag)break;
        }
}

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

#define ll unsigned long long
#define INF 1234567890
#define N (int)(2e5 + 5)
#define pi acos(-1)

void solve()
{
    int x;
    cin >> x;
    int win = (x / 500) * 1000;
    x %= 500;
    cout << win + (x / 5) * 5;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

struct BIT{
    int n;
    vector<vector<int>> bit;

    BIT(int n_){
        bit.resize(26,vector<int>(n_,0));
        n = n_;
    } // 初期化

    int sum(int a, int i){
        int s = 0;
        while(i>0){
            s += bit[a][i];
            i -= i & -i; // 上のnodeへの遷移
        }
      	return s;
    } // i番目(1-index)までの和

    void add(int a, int i, int x){
        while(i<=n){
            bit[a][i] += x;
            i += i & -i; // 上のnodeへの遷移
        }
    } // i番目(1-index)にxを加える
};

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

    BIT data(n+2);
    rep(i,n) data.add(s[i]-'a', i+1, 1);

    int q; cin >> q;
    rep(i,q){
        int aa; cin >> aa;
        if(aa == 1){
            int bb; char cc; cin >> bb >> cc;
            data.add(s[bb-1]-'a', bb, -1);
            data.add(cc-'a', bb, 1);
            s[bb-1] = cc;
        }
        else{
            int bb, cc; cin >> bb >> cc;
            int ans = 0;
            rep(i,26) if(data.sum(i,cc)-data.sum(i,bb-1) > 0) ans++;
            cout << ans << endl;
        }
    }
  	return 0;
}

Measured memory_bytes: 56824
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <set>

using namespace std;

const int dy[]={-1,-1,-1,0,0,1,1,1};
const int dx[]={-1,0,1,-1,1,-1,0,1};
typedef pair<int,int> pii;
typedef pair<int,pii> sit;

int n;
char field[6][6];
pii sp;


int bfs(){
	int res=0;
	queue<sit> q[2];
	set<sit> used;
	int cur=0;
	int nxt=1;
	int ss=0;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(field[i][j]=='#')ss|=(1<<(i*n+j));
	q[cur].push(sit(ss,sp));
	while(q[cur].size()){
		while(q[cur].size()){
			sit csit=q[cur].front();q[cur].pop();
			if(csit.first==0)return res;
			const int fsit=csit.first;
			const pii &pp=csit.second;
			for(int l=0;l<8;l++){
				if(l==5){
					//cout<<endl;
				}
				int ny=pp.first+dy[l];
				int nx=pp.second+dx[l];
				if(ny>=0&&nx>=0&&ny<n&&nx<n&&!((fsit>>(ny*n+nx))&1)){
					int nfield=0;
					for(int i=0;i<n;i++){
						for(int j=0;j<n;j++){
							if(ny==i&&nx==j)continue;
							int cnt=0;
							for(int k=0;k<8;k++){
								int adx=j+dx[k];
								int ady=i+dy[k];
								if(ady>=0&&adx>=0&&ady<n&&adx<n)
									if(((fsit>>(ady*n+adx))&1)||(ny==ady&&nx==adx))cnt++;
							}
							if((fsit>>(i*n+j))&1){
								if(cnt==2||cnt==3)nfield|=(1<<(i*n+j));
							}
							else{
								if(cnt==3)nfield|=(1<<(i*n+j));
							}
						}
					}
					sit nsit=make_pair(nfield,make_pair(ny,nx));
					if(used.find(nsit)!=used.end())continue;
					used.insert(nsit);
					q[nxt].push(nsit);
				}
			}
		}
		swap(cur,nxt);
		res++;
	}
	return -1;
}

int main(){

	while(cin>>n&&n){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>field[i][j];
				if(field[i][j]=='@')sp.first=i,sp.second=j,field[i][j]='.';
			}
		}
		int res=bfs();
		cout<<res<<endl;
	}

	return 0;
}

Measured memory_bytes: 1628
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int a[] = new int[n];
    for(int i = 0; i < a.length; i++){
      a[i] = 0;
    }
    for(int i = 0; i < n-1; i++){
      a[s.nextInt()-1]++;
    }
    for(int i:a){
      System.out.println(i);
    }
  }
}

Measured memory_bytes: 62244
countsall={}
[*"a".."z"].each do |alp|
  countsall[alp]=0
end
n=gets.to_i
n.times do |i|
  sn=gets.chomp.split("").sort
  prevalp=sn[0]
  num=0
  ssize=sn.size
  counts1={}
  [*"a".."z"].each do |alp|
    counts1[alp]=0
  end
  ssize.times do |j|
    if prevalp==sn[j]
      num+=1
    else
      if i==0
        countsall[prevalp]=num
      else
        counts1[prevalp]=num
      end
      prevalp=sn[j]
      num=1
    end
  end
  if i==0
    countsall[prevalp]=num
  else
    counts1[prevalp]=num
    [*"a".."z"].each do |alp|
      countsall[alp]=[countsall[alp],counts1[alp]].min
    end
  end
end
puts countsall.to_a.inject(""){|ans,c| ans+c[0]*c[1]}


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

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T, size_t N, size_t I = N>
auto make_vector(const std::array<int, N> &a, T value = T()){
  static_assert(I >= 1);
  static_assert(N >= 1);
  if constexpr (I == 1){
    return std::vector<T>(a[N - I], value);
  }else{
    return std::vector(a[N - I], make_vector<T, N, I - 1>(a, value));
  }
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}


namespace haar_lib {}

namespace solver {
  using namespace haar_lib;

  constexpr int m1000000007 = 1000000007;
  constexpr int m998244353 = 998244353;

  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }

  void solve(){
    int N; std::cin >> N;
    std::vector<int64_t> x(N), y(N);
    for(int i = 0; i < N; ++i){
      int64_t X, Y; std::cin >> X >> Y;

      x[i] = X + Y;
      y[i] = X - Y;
    }

    std::sort(x.begin(), x.end());
    std::sort(y.begin(), y.end());

    int64_t ans = std::max(x.back() - x.front(), y.back() - y.front());
    std::cout << ans << "\n";
  }
}

int main(){
  solver::init();
  while(true){
    try{
      solver::solve();
    }catch(const std::istream::failure &e){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 6364
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main( int argc, char** argv ){
	int N;
	cin >> N;

  if(N == 25){
    cout << "Christmas" << endl;
  }else if(N == 24){
  	cout << "Christmas Eve" << endl;
  }else  if(N == 23){
 	cout << "Christmas Eve Eve" << endl;
  }else  if(N == 22){
	cout << "Christmas Eve Eve Eve" << endl;
  }
  
	return 0;
}


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

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

    vector<int> s(m);
    vector<char> c(m);

    bool firstZero = false;
    for (int i = 0; i < m; i++) {
        cin >> s[i] >> c[i];
        if (s[i] == 1 && c[i] == '0') firstZero = true;
    }
    
    int ans = -1;

    if (n != 1 && firstZero) {
        cout << ans << endl;
        return 0;
    }    

   for (int i = 0; i < 1000; i++) {

        string tmp_s = to_string(i);

        if (tmp_s.size() != n) continue;

        bool ok = true;
        for (int i = 0; i < m; i++) {
            if (tmp_s[s[i] - 1] != c[i]) {
                ok = false;
            }
        }
        if (ok) {
            ans = i;
            break;
        }

    }

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

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

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

const int N = 200005, inf = 99999999;

struct Edge {
	int to, cap;
	Edge *nxt, *pre;
	Edge(int to, int cap, Edge *nxt) : to(to), cap(cap), nxt(nxt), pre(NULL) {}
} *head[N], *cur[N];

int S, T, dep[N];

void add(int u, int v, int c) {
	head[u] = new Edge(v, c, head[u]);
	head[v] = new Edge(u, 0, head[v]);
	head[u]->pre = head[v];
	head[v]->pre = head[u];
}

int dfs(int x, int flow) {
	if(x == T || !flow) return flow;
	int king = 0;
	for(Edge *&i = cur[x]; i; i = i->nxt){
		if(dep[i->to] == dep[x] + 1 && i->cap){
			int o = dfs(i->to, std::min(i->cap, flow));
			if(o){
				i->cap -= o; i->pre->cap += o;
				flow -= o; king += o;
				if(!flow) return king;
			}
		}
	}
	return king;
}

std::queue<int> Q;

bool bfs() {
	for(int i = 1; i <= T; ++i) dep[i] = 0, cur[i] = head[i];
	dep[S] = 1; Q.push(S);
	while(Q.size()){
		int x = Q.front(); Q.pop();
		for(Edge *i = head[x]; i; i = i->nxt){
			if(i->cap && !dep[i->to]) dep[i->to] = dep[x] + 1, Q.push(i->to);
		}
	}
	return dep[T] > 0;
}

int Dinic() {
	int ans = 0, flow;
	while(bfs()) while((flow = dfs(S, inf))) ans += flow;
	return ans;
}

int p[N], q[N];
int id[2][N], tot;

void work(int u, int* nx, int* id) {
    if (id[u]) return;
    id[u] = tot, work(nx[u], nx, id);
}

int main() {
    int n = read();
    for (int i = 1; i <= n; ++i) p[i] = read() + 1;
    for (int i = 1; i <= n; ++i) q[i] = read() + 1;
    int res = n;
    for (int i = 1; i <= n; ++i) if (!id[0][i]) ++ tot, work(i, p, id[0]);
    for (int i = 1; i <= n; ++i) if (!id[1][i]) ++ tot, work(i, q, id[1]);
    S = ++tot, T = ++tot;
    for (int i = 1; i <= n; ++i) {
        if (p[i] == i && q[i] == i) --res;
        else if (p[i] == i) add(id[1][i], T, 1);
        else if (q[i] == i) add(S, id[0][i], 1);
        else if (p[i] != q[i]) add(id[1][i], id[0][i], 1);
        else add(id[1][i], id[0][i], 1), add(id[0][i], id[1][i], 1);
	}
    printf("%d\n", res - Dinic());
    return 0;
}

Measured memory_bytes: 16000
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  char a,b;
  cin >> a >> b;
  if(a==b) cout <<"H\n";
  else cout <<"D\n";
}


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

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    qsort(A,3,sizeof(int),compare_int);
    cout << A[0] + A[1] << endl;
    return 0;
}

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

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

int main(){
    int W, H, C;
    cin >> W >> H >> C;

    int GCD = gcd(W, H);
    cout << W/GCD * H/GCD * C << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m;
	cin >> n >> m;

	vl ac(n), wa(n);

	ll k = 0, res = 0;
	while (m--) {
		ll i; cin >> i;
		string s; cin >> s;
		i--;

		if (s == "AC") {
			if (++ac[i] == 1) res += wa[i], k++;
		} else {
			wa[i]++;
		}
	}
	cout << k << " " << res << endl;
}



Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
for i in range(N - 1):
    if H[i] < H[i+1] :
        H[i+1] -= 1

    elif H[i] > H[i+1]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 14396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc =new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();

		if(a+b+c<22) {
			System.out.println("win");
		}
		else {
			System.out.println("bust");
		}
	}
}

Measured memory_bytes: 21972
N,M = map(int,input().split())
A = list(map(int,input().split()))
weight = [0,2,5,5,4,5,6,3,7,6]
dp=[-1]*(N+1)
dp[0] = 0

for i in range(N+1):
  if dp[i] == -1: continue
  for a in A:
    if i+weight[a]<N+1:
      dp[i+weight[a]] = max(dp[i+weight[a]],dp[i]*10+a)

print(dp[-1])

Measured memory_bytes: 14692
#include<iostream>
#include<algorithm>
 using namespace std;
 #define N 100010
 int main(){
   //速さ比べ
 int n,m,h[N],ma[N];
 cin>>n>>m;
 for(int i=1;i<=n;i++){
 cin>>h[i];
 ma[i]=0;
 }
 for(int i=0;i<m;i++){
int a,b;
 cin>>a>>b;
 ma[a]=max(ma[a],h[b]);
 ma[b]=max(ma[b],h[a]);
 }
 int ans=0;
 for(int i=1;i<=n;i++){
 ans+=h[i]>ma[i];
 }
 cout<<ans<<endl;
 }

Measured memory_bytes: 4428
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    T = list(map(int, readline().split()))
    M, *PX = map(int, read().split())

    s = sum(T)
    ans = [0] * M
    for i, (p, x) in enumerate(zip(*[iter(PX)] * 2)):
        p -= 1
        ans[i] = s + (x - T[p])

    print(*ans, sep='\n')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
long long n , j , i , a[100001];
int main(){
	pair<int, int>x[100001];
	cin >> n ;
	for (i=1; i<=n; i++){
	cin >> a[i] ;
	x[i].first=a[i];
	x[i].second=i;
	}
	sort(x+1, x+1+n);
	for (i=1; i<=n; i++)
	cout << x[i].second << " " ;
	cout << endl ; 
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;
using P = pair<int,int>;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];

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

    vector<P> l;
    l.emplace_back(a[0], 0);
    for (int i=0; i<n; i++) {
        if (l.back().first == a[i]) l.back().second++;
        else l.emplace_back(a[i], 1);
    }

    auto cmp = [](P x, P y) {return x.second < y.second;};
    sort(l.rbegin(), l.rend(), cmp);


    int ans = 0;
    for (auto it=l.begin()+k; it<l.end(); it++) {
        ans += (*it).second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3188
from operator import itemgetter
from operator import attrgetter
N = int(input())
SP = []
for i in range(N):
  s, p = input().split()
  SP.append({"index":i, "S":s, "P":-int(p)})
SP = sorted(SP, key = itemgetter("S", "P"))
for i in range(N):
  print("{}".format(SP[i]["index"]+1))

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

int main(){
	string s,big;
	int mi;
	string substr;
	while(cin >> s >> big){
		s=s.substr(0,2);
		if(s=="ES")
			cout << 2;
		else if(s=="GG")
			cout << 17;
		else if(s=="BB")
			cout << 0;
		else if(s=="BP")
			cout << 5;
		else if(s=="EE")
			cout << 1951;
		else if(s=="KF")
			cout << 1440;
		else if(s=="VV")
			cout << 904;
		else if(s=="KK")
			cout << 719;
		else if(s=="CC")
			cout << 3995;
		else if(s=="AW")
			cout << 0;
		cout << endl;
	}
}

Measured memory_bytes: 0
main = do
  n <- readLn :: IO Integer
  a <- readLn :: IO Integer
  b <- readLn :: IO Integer
  c <- readLn :: IO Integer
  d <- readLn :: IO Integer
  e <- readLn :: IO Integer
  print $ if n `mod` minimum [a,b,c,d,e] == 0 then 4 + n `div` minimum [a,b,c,d,e] else 5 + n `div` minimum [a,b,c,d,e]


Measured memory_bytes: 508
def watch(s):
    hh = s // (60 * 60) # ??????????????????
    mm_s = s % (60 * 60) # s??????hh??§??¨??????????§???°???????????????(??????:?§?)
    mm = mm_s // 60 # ???????????????
    ss = mm_s % 60 # mm_s??????mm??§??¨??????????§???°???????????????(??????????§?)

    print(str(hh) + ":" + str(mm) + ":" + str(ss))

s = int(input())
watch(s)

Measured memory_bytes: 7724
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int a,b;
  cin >> a >> b;
  string ans = "";
  if(a > b){
    rep(i,a) printf("%d", b);
  }else{
    rep(i,b) printf("%d", a);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

char a[200000];

int main()
{
	int i, j, k, l;
	scanf("%s", a);
	int n=strlen(a);
	if(a[0] == a[n-1]) n--;
	if(n%2 == 0) printf("Second\n");
	else printf("First\n");
	return 0;
}
//*/

Measured memory_bytes: 384