akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define il inline
#define rg register
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define rep(i,st,ed) for(rg int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(rg int i=(ed);i>=(st);--i)
#define rep0(i,n) for(rg int i=0;i<(n);++i)
#define per0(i,n) for(rg int i=(n)-1;i>=0;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &x,const T &y){return x<y?x:y;}
template<typename T> il T qmax(const T &x,const T &y){return x>y?x:y;}
template<typename T> il void getmin(T &x,const T &y){if(y<x) x=y;}
template<typename T> il void getmax(T &x,const T &y){if(y>x) x=y;}
il void fileio(const string &s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e18+7;
const int N=30004,K=404,mod=(int)1e9+7;

int a[N],n,k,m;
int tot[K],cnt;
int f[N][K],g[N][K];
ll fac[N],inv[N];

il ll qpow(ll x,int y){
	ll ans=1;
	for(;y;y>>=1,x=x*x%mod){
		if(y&1) ans=ans*x%mod;
	}
	return ans;
}

il void inc(int &x,const int &y){
	if((x+=y)>=mod) x-=mod;
}

il void dec(int &x,const int &y){
	if((x-=y)<0) x+=mod;
}

int main(){
//	fileio("test");
	fac[0]=inv[0]=1;
	rep(i,1,N-1){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=qpow(fac[i],mod-2);
	}
	scanf("%d%d%d",&n,&k,&m);
	rep(i,1,m) scanf("%d",a+i);
	bool flag=false;
	rep(i,1,m){
		if(++tot[a[i]]==1) ++cnt;
		if(i>k){
			if(!--tot[a[i-k]]) --cnt;
		}
		if(cnt==k){
			flag=true;
			break;
		}
	}
	ll res=(n-m+1)*qpow(k,n-m)%mod;
	if(flag){
		printf("%lld\n",res);
	}else if(cnt==m){
		rep(i,1,k) f[1][i]=k,g[1][i]=(m==1?k:0);
		rep(i,2,n){
			rep(j,1,k-1){
				f[i][j]=ll(f[i-1][j-1]-(j>=2?f[i-1][j-2]:0)+mod)*(k-j+1)%mod;
				inc(f[i][j],(f[i-1][k-1]-f[i-1][j-1]+mod)%mod);
				g[i][j]=ll(g[i-1][j-1]-(j>=2?g[i-1][j-2]:0)+mod)*(k-j+1)%mod;
				inc(g[i][j],(g[i-1][k-1]-g[i-1][j-1]+mod)%mod);
				if(j>=m) inc(g[i][j],f[i][j]);
				inc(f[i][j],f[i][j-1]);
				inc(g[i][j],g[i][j-1]);
			}
		}
		printf("%lld\n",(res-inv[k]*fac[k-m]%mod*g[n][k-1]%mod+mod)%mod);
	}else{
		memset(tot+1,0,sizeof(int)*k);
		int cnt1=0,cnt2=0;
		rep(i,1,m){
			if(tot[a[i]]){
				cnt1=i-1;
				break;
			}else{
				++tot[a[i]];
			}
		}
		memset(tot+1,0,sizeof(int)*k);
		per(i,m,1){
			if(tot[a[i]]){
				cnt2=m-i;
				break;
			}else{
				++tot[a[i]];
			}
		}
		f[0][cnt1]=1;
		g[0][cnt2]=1;
		rep(i,2,k-1){
			inc(f[0][i],f[0][i-1]);
			inc(g[0][i],g[0][i-1]);
		}
		rep(i,1,n){
			rep(j,1,k-1){
				f[i][j]=ll(f[i-1][j-1]-(j>=2?f[i-1][j-2]:0)+mod)*(k-j+1)%mod;
				inc(f[i][j],(f[i-1][k-1]-f[i-1][j-1]+mod)%mod);
				inc(f[i][j],f[i][j-1]);
				g[i][j]=ll(g[i-1][j-1]-(j>=2?g[i-1][j-2]:0)+mod)*(k-j+1)%mod;
				inc(g[i][j],(g[i-1][k-1]-g[i-1][j-1]+mod)%mod);
				inc(g[i][j],g[i][j-1]);
			}
		}
		ll cur=0;
		rep(i,0,n-m){
			cur+=(ll)f[i][k-1]*g[n-m-i][k-1]%mod;
		}
		cur%=mod;
		printf("%lld\n",(res-cur+mod)%mod);
	}
	return 0;
}

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

const int MOD = (int)1e9+7;

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

	int N=S.size()+1;
	vector<int> x(N,1);
	for(int i=0;i<N-2;i++){
		if(S.at(i)=='>' && S.at(i+1)=='<')	x.at(i+1)=0;
		if(S.at(i)=='<' && S.at(i+1)=='>')	x.at(i+1)=2;
	}
	int aa=0;
	if(S.at(0)=='<')	x.at(0)=0;
	else{
		x.at(0)=2;
		x.insert(x.begin(),0);
		aa++;
	}
	if(S.at(N-2)=='>')	x.at(N-1+aa)=0;
	else{
		x.at(N-1+aa)=2;
		x.push_back(0);
		aa++;
	}

	long long ans=0;
	for(int i=0;i<N+aa-1;i++){
		long long count1=0;
		long long count2=0;
		while(1){
			i++;
			count1++;
			if(x.at(i)==2)	break;
		}
		while(1){
			i++;
			count2++;
			if(x.at(i)==0)	break;
		}
		i--;
		long long ma=max(count1,count2);
		long long mi=min(count1-1,count2-1);
		ans+=ma*(ma+1)/2 + mi*(mi+1)/2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6532
import math
def q77(N, a):
    i = 0
    o = 0
    while True:
        b = False
        for j in range(o, N):
            a[j] = a[j]/2
            if a[j].is_integer():
                i += 1
                b = True
                break
            else:
                o = j
        if not b:
            break
    return i

N = int(input())
a = [int(i) for i in input().split()]

print(q77(N, a))

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

const int INF = 1001001001;
vector<int> to[100005];

int main(){
	int n, m;
  	cin >> n >> m;
  	rep(i, m){
    	int a, b;
     	cin >> a >> b;
      	a--; b--;
      	to[a].push_back(b);
        to[b].push_back(a);
    }
  
  	queue<int> q;
  	vector<int> dist(n, INF);
  	vector<int> pre(n, -1);
  	dist[0] = 0;
  	q.push(0);
  	while(!q.empty()){
    	int v = q.front();
      	q.pop();
      	for(int u : to[v]){
        	if(dist[u] != INF) continue;
          	dist[u] = dist[v]+1;
          	pre[u] = v;
          	q.push(u);
        }
    }
  
  	cout << "Yes" << endl;
  	rep(i, n){
    	if(i == 0) continue;
      	int ans = pre[i];
      	ans++;
      	cout << ans << endl;
    }
}

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

int main(){
	int ans=0;
	string S;
	cin>>S;
	char state=S[0];
	for(int i=1;i<S.length();++i){
		if(state!=S[i]){
			ans++;
			state=S[i];
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
A, B = map(int, input().split())

def fact(n):
    k = 2
    l = [] 
    temp=n
    while pow(k, 2)<=n:
        if temp%k==0:
            l.append(k)
            while temp%k==0:
                temp//=k
        k+=1
    if temp!=1:
        l.append(temp)
    return l

if A==1 and B==1:
    print(1)
elif A==B:
    print(len(set(fact(A)))+1)
else:
    print(len(set(fact(A))&set(fact(B)))+1)

Measured memory_bytes: 63500
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
char s[200005];
int yes=0;
scanf("%s",s);
for(int i=0;s[i]!='\0';i++){
    if(s[i]=='?'){
        s[i]='D';
    }
}
printf("%s",s);
/*for(int i=0;s[i]!='\0';i++){
    if(s[i]=='D'){
        yes++;
        if(s[i-1]=='P'&&i-1>=0){yes++;}
    }
}*/

//printf("%d",yes);
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int r;
	cin >> r;
    cout<<fixed<<setprecision(5)<<((float)r*2)*3.14159265;
	return 0;
}

Measured memory_bytes: 3788
import java.util.*;

class Main{

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

    public Main(){
        Scanner scanner = new Scanner(System.in);
        long H = scanner.nextLong();

        System.out.println(search(H));
    }

    public long search(long H){
        if(H == 1L) return 1L;

        return 2*search(H/2L) + 1L;
    }
}


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

using namespace std;

const int SIZE = 105;
int a[SIZE]; 

int main()
{
	int n;
	scanf("%d", &n);
	for(int i =0; i<n; ++i)
	{
		scanf("%d", &a[i]);
	}
	int cnt = 0;
	for(int i=0; i<n; ++i)
	{
		for(int j=n-1;j >i; --j)
		{
			if(a[j] < a[j-1])
			{
				swap(a[j], a[j-1]);
				++cnt;
			}
		}
	}
	for(int i=0; i<n; ++i)
	{
		if(i!=n-1) printf("%d ", a[i]);
		else printf("%d\n", a[i]);
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 3200
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        String s = buf.readLine();
        int x = Integer.parseInt(s);
        int res = x * x * x;
        System.out.println(res);
    }
}

Measured memory_bytes: 24204
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import copy

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''

n = int(stdin.readline().rstrip())
d = stdin.readline().rstrip().split()
res = 0
count1 = 0
for el1 in d:
    count2 = 0
    for el2 in d:
        if (count2 > count1):
            res += int(el1) * int(el2)
        count2 += 1
    count1 += 1

print(res)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin>>S;
    int count=0;
    for(int i=1;i<3;i++){
        if(S[i]==S[i-1]){
            count++;
        }
    }
    if(count==2){
        cout<<"No"<<endl;
        return 0;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


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

  d *= d;
  int cnt = 0;
  REP(i,n){
    ll x, y;
    cin >> x >> y;
    if(x*x + y*y <= d) cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
const int N=110;
int f[N][N][N],a[N];
#define mod 1000000007
inline void inc(int &x,int y) { (x+=y)>=mod?x-=mod:0; }
int main()
{
	int n=gi(),i,j,k,t,x,y;
	for (i=1;i<n*2;i++) a[i]=gi();
	sort(a+1,a+n*2);
	f[n][1][1]=1;
	for (i=n;i;i--) {
		x=a[i]!=a[i-1];
		y=a[n*2-i+1]!=a[n*2-i];
		for (j=1;j<2*n;j++)
			for (k=1;k<=j;k++)
				if (f[i][j][k]) {
					for (t=1;t<k+x;t++)
						inc(f[i-1][j+x+y-(k+x-t-1)][t],f[i][j][k]);
					for (t=k+x+1;t<=j+x+y;t++)
						inc(f[i-1][j+x+y-(t-(k+x)-1)][k+x+1],f[i][j][k]);
					inc(f[i-1][j+x+y][k+x],f[i][j][k]);
				}
	}
	x=0;
	for (j=1;j<n*2;j++)
		for (k=1;k<=j;k++)
			inc(x,f[1][j][k]);
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PA;
int main(){
  bool sosu[10001];
  PA p,sou[10001];
  for(int i=3;i<=10000;i+=2){
    for(int j=i*i;j<=10000&&sosu[i]==false;j+=i)
      sosu[j] = true;
    if(sosu[i-2] == false && sosu[i] == false)
      p = PA(i-2,i);
    sou[i] = p;
  }
  int a;
  while(cin>>a,a!=0){
    if(a%2 == 0) a--;
    cout << sou[a].first << ' ' << sou[a].second << endl;
  }  
  return (0);
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long int a,b,x;
  cin >> a >> b >> x;
  if(a == 0){
    cout << b/x + 1 << endl;
  }else{
    cout << b/x - (a-1)/x << endl; 
  }
}


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

bool isPrime(int x){
    bool flag=true;
    for(int i=2;i*i<=x;i++){
        if(x%i==0) flag=false;
    }
    if(flag)return true;
    else return false;
}

int main(){
    int x;
    cin>>x;
    for(int i=x;i<=200000;i++){
        if(isPrime(i)){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
N, T = map(int, input().split())
route = []
for _ in range(N):
    c, t = map(int, input().split())
    route.append((c, t))

min_cost = float('inf')
for c, t in route:
    if t <= T:
        min_cost = min(min_cost, c)

print(min_cost if min_cost != float('inf') else 'TLE')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
        if(b&1)res = res * x % MOD;
        x = x * x % MOD;
        b>>=1;
    }
    return res;
}

ll modinv(ll x){
    return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
}
void outendl(){
    was_output = false;
    cout << endl;
}
ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
}

template<class t>
istream& operator>>(istream& is, vector<t> &x){
    for(auto &i:x)is >> i;
    return is;
}

template<class t, class u>
istream& operator>>(istream& is, pair<t, u> x){
    is >> x.first >> x.second;
    return is;
}


int main(){
    int n = in();
    int m = in();
    vector<pair<int,char>> line(m);
    foreach(i,line){
        cin >> i.first >> i.second;
    }
    rep(i,1000){
        string str = to_string(i);
        if(str.size()!=n)continue;
        bool flag = true;
        foreach(j,line){
            if(str[j.first-1]!=j.second){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << str << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}


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

typedef long long ll;

ll n, x;

ll Get(ll x, ll y)
{
    if (x < y) return Get(y, x);
    if (y == 0) return 0;
    ll d = x / y;
    return 3ll * d * y + Get(y, x % y);
}

int main()
{
    cin >> n >> x;
    printf("%lld\n", Get(x, n - x));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

ll gcd(ll a, ll b)
{

    if (a < b)
        swap(a, b);
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll p2 = 1;
    ll l = 1;
    while (a[0] % p2 == 0)
    {
        p2 *= 2;
    }
    p2 /= 2;
    rep(i, n)
    {
        if (a[i] % p2 != 0 || (a[i] / p2) % 2 == 0)
        {
            cerr << p2 << " " << a[i] << endl;
            cout << 0 << endl;
            return 0;
        }
        else
        {
            l = lcm(l, a[i] / p2);
            cerr << a[i] / p2 << endl;
            if (l * (p2 / 2) > m)
            {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cerr << l << endl;
    cout << ((m / (l * (p2 / 2))) + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 1024
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define exists(x,m) m.find(x) != m.end()
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

template<typename T>
pair<vector<T>, vector<bool>> prime_sieve(T lim) {
	vector<T> primes = vector<T>();
	vector<bool> composite = vector<bool>(lim+1);
	for (T num = 2; num <= lim; num++) {
		if (!composite[num]) primes.pb(num);
		for (int i = 0; i < isize(primes) and num * primes[i] <= lim; i++) {
			composite[num * primes[i]] = true;
			if (num % primes[i] == 0) break;
		}
	}
	return {primes, composite};
}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vi A = vi();
	int maxx = 0;
	rep(i, n) {
		int x; cin >> x;
		A.pb(x);
		maxx = max(maxx, x);
	}	
	auto [primes, composite] = prime_sieve((ll)min(1e3+100, ceil(sqrt(maxx)) + 100));
	umap<int, int> prime_freq = umap<int, int>();
	for (const int& a : A) {
		int b = a;
		for (int i = 0; primes[i]*primes[i] <= b; i++) {
			if (b % primes[i] == 0) prime_freq[primes[i]]++;
			while(b % primes[i] == 0) b /= primes[i];
		}
		if (b != 1) prime_freq[b]++;
	}
	int max_freq = 0;
	for (const auto& [p, freq] : prime_freq) {
		max_freq = max(max_freq, freq);
	}
	if (max_freq <= 1) {
		cout << "pairwise coprime";
	} else {
		cout << (max_freq < n ? "setwise coprime" : "not coprime");
	}
}

Measured memory_bytes: 10472
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    int64 ans = LONG_MIN;
    for (int i=0; i<n; i++) {
        vector<int64> s(1,0);

        int64 cnt = 0;
        int now = i;
        int64 score = 0;

        do {
            cnt++;
            now = p[now]-1;
            score += c[now];
            s.push_back(score);
            ans = max(ans, score);
        } while(now != i && cnt<k);

        if (score>=0 && cnt<=k) {
            for (int j=0; j<=(k%cnt); j++) {
                ans = max(ans, score*(k/cnt) + s[j]);
            }

            for (int j=cnt-(k%cnt); j>=0; j--) {
                ans = max(ans, score*(k/cnt-1) + s[cnt-j]);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3324
#include<cstdio>
#include<cstring>
struct vec{
	int x,nx;
}e[5000001];
int h[200001],p,cnt,co[200001];
void ae(int fr,int to){
	e[++p]=(vec){to,h[fr]};h[fr]=p; 
}
int mi[200001<<2];
int n,f[200001],q;
int Min(int p,int q){
	return p<q?p:q;
}
int Max(int p,int q){
	return p>q?p:q;
}
int ask(int i,int l,int r,int ql,int qr){
	if(r<ql||l>qr) return 2147483647;
	if(ql<=l&&r<=qr) return mi[i];
	int m=(l+r)>>1;
	return Min(ask(i<<1,l,m,ql,qr),ask(i<<1|1,m+1,r,ql,qr));
}
void upd(int i,int l,int r,int k,int pos){
	if(r<pos||l>pos) return;
	if(l==r&&r==pos){
		mi[i]=Min(mi[i],k);return;
	}
	int m=(l+r)>>1;
	upd(i<<1,l,m,k,pos);upd(i<<1|1,m+1,r,k,pos);
	mi[i]=Min(mi[i<<1],mi[i<<1|1]);
}
int main(){
	scanf("%d",&n);
	for(int i=1,a;i<=n;i++){
		scanf("%d",&a);
		cnt+=!a;
		co[i]=a?1:-1;
	}
	scanf("%d",&q);
	for(int i=1,l,r;i<=q;i++){
		scanf("%d%d",&l,&r);
		ae(l,r);
	}
	memset(mi,0x3f,sizeof(mi));
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=h[i];j;j=e[j].nx){
			int mi=f[i-1];
			mi=Min(mi,ask(1,1,n,Max(i-1,1),e[j].x));
			if(mi<f[e[j].x]){
				f[e[j].x]=mi;
				upd(1,1,n,mi,e[j].x);
			}
		}
		f[i]=Min(f[i],f[i-1]+co[i]);
	}
	printf("%d\n",f[n]+cnt);
}

Measured memory_bytes: 8320
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2010,mod=924844033;
int n,k,g[N<<1],f[N<<1][N][2],cnt,fac[N],ans;

int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++){
        for(int j=i;j<=n;j+=k)g[++cnt]=(j==i);
        for(int j=i;j<=n;j+=k)g[++cnt]=(j==i);
    }
    f[0][0][0]=fac[0]=1;
    for(int i=1;i<=n;i++)fac[i]=1LL*i*fac[i-1]%mod;
    for(int i=0;i<n*2;i++)
        for(int j=0;j<=min(i,n);j++){
            f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mod;
            if(!g[i+1])f[i+1][j+1][1]=f[i][j][0];
        }
    for(int i=0;i<=n;i++){
        int tmp=1LL*(f[n<<1][i][0]+f[n<<1][i][1])*fac[n-i]%mod;
        ans=(mod+(ans+(i&1?-1:1)*tmp)%mod)%mod;
    }
    printf("%d\n",ans);
}


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

using namespace std;
    
int main(){

    string s;
    cin >> s;

    int zero = 0;
    int one = 0;

    for(int i = 0; i < s.size(); i++){
       if(s[i] - 48 != (i % 2)) zero++;
    }

    for(int i = 0; i < s.size(); i++){
        if(s[i] - 48 == (i % 2)) one++;
    }

    cout << min(zero,one) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    int iLeft1, iLeft2, iRight1, iRight2;
    cin >> iLeft1 >> iLeft2 >> iRight1 >> iRight2;
    if (iLeft1 + iLeft2 > iRight1 + iRight2)
        cout << "Left\n";
    else if (iLeft1 + iLeft2 == iRight1 + iRight2)
        cout << "Balanced"<<endl;
    else
        cout << "Right"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
    int N, R;
    
    scanf("%d", &N);

    if((N % 1000) == 0) {
        printf("0\n");
    }
    else {
        printf("%d\n", 1000 - (N % 1000) );
    }
    
    return 0;
}


Measured memory_bytes: 1732
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long int;

// to format a document: ctrl + K -> ctrl + D

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

    if (A <= 5)
        cout << 0 << endl;
    else if (A <= 12)
        cout << B / 2 << endl;
    else
        cout << B << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int a[26] = {0};

int main(){
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        a[s[i] - 'a']++;
    }
    bool flag = true;
    for (int i = 0; i < 26; i++) {
        if(a[i]%2==0)continue;
        flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<set>

using namespace std;

int main(void){

	string index;
	int page;
	map<string,set<int> >dic;
	
	while(cin >> index >> page)
		dic[index].insert(page);
	
	 map<string,set<int> >::iterator it = dic.begin();
    for(;it != dic.end();it++){
        cout << it->first << endl;
    	
        set<int>::iterator its = (it->second).begin();
    	
        while(its != (it->second).end()){
            cout << *its;
        	if(++its != (it->second).end())cout << " ";
        	else cout << endl;
        }
    }
	
return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int d; cin >> d;

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

    vector<vector<int>> s(d, vector<int>(26));
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < d; ++i) {
        int idx = 0;
        int mx = 0;
        for (int j = 0; j < 26; ++j) {
            if (mx < s[i][j]) {
                mx = s[i][j];
                idx = j;
            }
        }
        cout << idx + 1 << endl;
    }
}

Measured memory_bytes: 3680
#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>

using namespace std;

using ll = long long int;

ll arr[300010] = {};


ll resR[100010] = {};
ll resL[100010] = {};

int main(void){
    
    ll k,sum = 0,result = 0;
    cin >> k;
    
    priority_queue<ll, vector<ll>, greater<ll> > que;
    
    for(int i = 0; i < 3*k; i++){
        cin >> arr[i];
    }
    
    //init
    
    for(int i = 0; i < k; i++){
        sum += arr[i];
        que.push(arr[i]);
    }
    
    resL[0] = sum;
    
    for(int i = 0; i < k; i++){
        
        que.push(arr[i+k]);
        ll a = que.top();
        que.pop();
        
        sum += arr[i+k]-a;
        
        resL[i+1] = sum;
    }
    
    /// left
    
    priority_queue<ll> que1;
    sum = 0;
    
    for(int i = 1; i <= k; i++){
        sum += arr[3*k-i];
        que1.push(arr[3*k-i]);
    }
    
    resR[k] = sum;
    
    for(int i = 1; i <= k; i++){
        
        que1.push(arr[2*k-i]);
        ll a = que1.top();
        que1.pop();
        
        sum += arr[2*k-i]-a;
        
        resR[k-i] = sum;
    }
    
    /// right
    
    result = resL[0] - resR[0];
    
    for(int i = 0; i <= k; i++){
        //cout << resL[i] << " " << resR[i] << endl;
        result = max(resL[i] - resR[i],result);
    }
    cout << result << endl;
}


Measured memory_bytes: 5876
n = int(input())
s = input()
e = s.count("E")
w = s.count("W")
min_ = 10**9
l = [[0, 0] for i in range(n)]
if s[0] == "E":
  l[0] = [0, e-1]
else:
  l[0] = [0, e]
min_ = min(min_, sum(l[0]))
for i in range(1, n):
  if s[i-1] == "E":
    if s[i] == "E":
      l[i] = [l[i-1][0], l[i-1][1]-1]
    else:
      l[i] = [l[i-1][0], l[i-1][1]]
  else:
    if s[i] == "E":
      l[i] = [l[i-1][0]+1, l[i-1][1]-1]
    else:
      l[i] = [l[i-1][0]+1, l[i-1][1]]
  min_ = min(min_, sum(l[i]))
print(min_)
  
  

Measured memory_bytes: 43592
s=list(input())
x=0
y=0
for i in range(0,len(s)):
  if i%2==0:
    if s[i]=="0":
      x+=1
  else:
    if s[i]=="1":
      x+=1
      
for j in range(0,len(s)):
  if j%2==0:
    if s[j]=="1":
      y+=1
  else:
    if s[j]=="0":
      y+=1
      
print(min(x,y))      
  


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if (e - a <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

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

  int ans = INT_MAX;
  rep(i, s.size() - t.size() + 1) {
    int tmp = 0;
    rep(j, t.size()) {
      if(s[j + i] != t[j]) {
        tmp++;
      }
    }
    ans = min(ans, tmp);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main(){
    fast_io();
    ll N,K; cin >> N >> K;
    N++;
    ll min = 0,max = 0, ans = 0;
    for(ll k = K; k <= N; k++){
        min = ( (k - 1) * k ) / 2;
        max = ( (N - 1) * k ) - min;
        ans += max - min + 1;
    }
    cout << ans % MOD;
}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.q = l
        heapq.heapify(self.q)
        return

    def push(self, n):
        heapq.heappush(self.q, n)
        return

    def pop(self):
        return heapq.heappop(self.q)


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    L = Scanner.int()
    print((L / 3) ** 3)


if __name__ == "__main__":
    main()


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

int main(void){
  const int V = 10, W = 100, C = 10;
  // dp[i][j][k]: ??¢?????????i?????§??§???k????????¢?????????????????£????????????????¨????j??????????????????????????????????????°
  vector<vector<vector<int> > > dp(V, vector<vector<int> >(W + 1, vector<int>(C + 1, 0)));
  dp[0][0][1] = 1;
  for(int i = 1; i < V; i++){
    
    for(int j = 0; j < i; j++){
      for(int k = 0; k <= C; k++){
        dp[i][j][k] = dp[i - 1][j][k];
      }
    }
    
    //printf("%d\n", i);

    //printf("     ");
    for(int k = 1; k <= C; k++){
      //printf(" %d ", k);
    }
    //printf("\n");
    
    for(int j = i; j <= W; j++){
      //printf("%3d: ", j);
      for(int k = 1; k <= C; k++){
        dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - i][k - 1];
        if(j == i && k == 1){ ++dp[i][j][k]; }
        //printf("[%d]", dp[i][j][k]);
      }
      //printf("\n");
    }
    //printf("\n\n");
  }

  /*
  printf("%d\n", V - 1);
  for(int j = 0; j <= W; j++){
    printf("%3d: ", j);
    for(int k = 0; k <= C; k++){
      printf("[%d]", dp[V - 1][j][k]);
    }
    printf("\n");
  }
  printf("\n");
  */

  while(true){
    int n, s;
    cin >> n >> s;
    if(n == 0 && s == 0){ break; }
    cout << dp[V - 1][s][n] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3156
def cumsum(l):
    for i in range(1, len(l)):
        l[i] += l[i-1]
    return l


def main():
    N, M = map(int, input().split())

    imos = [0] * (N+1)

    for _ in range(M):
        l, r = map(int, input().split())
        l -= 1
        r -= 1
        imos[l] += 1
        imos[r+1] -= 1

    imos = cumsum(imos)
    # print(imos)

    print(len([x for x in imos if x == M]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7860
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b;
    cin>>a>>b;
    cout<<a*b-a-b+1<<endl;
}

Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
int n,m,i,j,k,ans;
int a[305][305],b[305];
bool ban[305];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>m;
	for(i=1;i<=n;i++)
	for(j=1;j<=m;j++)
	cin>>a[i][j];
	ans=n;
	for(i=1;i<=m;i++){
		for(j=1;j<=m;j++)
		b[j]=0;
		for(j=1;j<=n;j++)
		for(k=1;k<=m;k++)
		if(!ban[a[j][k]]){
			b[a[j][k]]++;
			break;
		}
		for(j=k=1;j<=m;j++)
		if(b[j]>b[k])
		k=j;
		ban[k]=true;
		if(b[k]<ans)
		ans=b[k];
	}
	cout<<ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
def main():
    n=int(input())
    a=list(map(int,input().split()))
    # 0個の皿がx0枚、1個の皿がx1枚、2個の皿がx2枚、3個の皿がx3枚
    # x0=n-x1-x2-x3
    ca={1:a.count(1),2:a.count(2),3:a.count(3)}
    memo=[[[-1]*(n+2) for _ in range(n+2)] for _ in range(n+2)]
    memo[0][0][0]=0
    for x3 in range(ca[3]+1):
        for x2 in range(ca[2]+ca[3]+1-x3):
            for x1 in range(ca[1]+ca[2]+ca[3]+1-x3-x2):
                if (x1,x2,x3)==(0,0,0):continue
                tmp=0
                if x1>0:tmp+=memo[x1-1][x2][x3]*x1
                if x2>0:tmp+=memo[x1+1][x2-1][x3]*x2
                if x3>0:tmp+=memo[x1][x2+1][x3-1]*x3
                tmp+=n
                tmp/=x1+x2+x3
                memo[x1][x2][x3]=tmp
    print(memo[ca[1]][ca[2]][ca[3]])
if __name__=='__main__':
    main()


Measured memory_bytes: 385344
T,K = (i for i in input().split())
N = input()
K = int(K)
X = list(N)
if X[K-1] == 'A':
    X[K-1] = 'a'
if X[K-1] == 'B':
    X[K-1] = 'b'
if X[K-1] == 'C':
    X[K-1] = 'c'
print(''.join(X))

Measured memory_bytes: 3064
N = int(input())
H = [int(i) for i in input().split()]
dp = [0] * N

dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1]))
print(dp[-1])

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

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


Measured memory_bytes: 256
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <limits>
#include <numeric>
#include <queue>
#include <memory>

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>; using sl = unordered_set<l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; const double PI = M_PI;
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream& in, ostream& out);
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7; // end of template

void solve(istream& in, ostream& out) {
  l n, m, x, y; in >> n >> m >> x >> y;
  vl xx(n + 1), yy(m + 1);
  F(i, 0, n) in >> xx[i];
  xx[n] = x;
  F(i, 0, m) in >> yy[i];
  yy[m] = y;
  sort(all(xx)); sort(all(yy));
  if (yy[0] > xx.back()) {
    out << "No War" << lf;
  } else {
    out << "War" << lf;
  }
}


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

int main() {
    ll n,k;
    cin >> n >> k;
    vector<int> tp(n),town(n+1);
    town.at(0) = 1;
    rep(i,n) cin >> tp.at(i);
    rep(i,n){
        town.at(i+1) = tp.at(town.at(i)-1);
    }
    int count=0,syuki=0;
    for(int i=n-1;i>=0;i--){
      count++;  
      if(town.at(i) == town.at(n)){
        syuki=i;
            break;
        }
    }
    int ans;
    ans=(k-(n-count))%count;
  if(n>k){
    cout << town.at(k) << endl;;
  }else{
    cout << town.at(syuki+ans) << endl;
  }
    return 0;
}

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

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;

lint combi[51][51];
lint my_pow(lint a, lint b) { //a^b
	lint ret = 1;
	while (b != 0) {
		if (b % 2 == 0) {
			a = a*a;
			b /= 2;
		}
		else {
			ret = ret * a;
			b--;
		}
	}
	return ret;
}

int main(void) {
	combi[0][0] = 1;
	for (int i = 0; i <= 50; i++) {
		combi[i][0] = 1;
		combi[i][i] = 1;
		for (int j = 1; j < i; j++) {
			combi[i][j] = combi[i - 1][j] + combi[i - 1][j - 1];
		}
	}
	int N, P;
	scanf("%d %d", &N, &P);
	int hol = 0, jak = 0;
	for (int i = 1; i <= N; i++) {
		int temp;
		scanf("%d", &temp);
		if (temp % 2 == 0) {
			jak++;
		}
		else {
			hol++;
		}
	}

	lint ans = my_pow(2, jak);
	lint temp = 0;

	if (P % 2 == 1) {
		for (int i = 1; i <= hol; i += 2) {
			temp += combi[hol][i];
		}
	}
	else {
		for (int i = 0; i <= hol; i += 2) {
			temp += combi[hol][i];
		}
	}

	ans *= temp;

	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 256
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
          #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
           ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
               # #  # # #                   # #      ###### #    # #    # #      #####
          #    # #   #  #              #    # #      #    # #    # #    # #      #   #
           ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
    */
     
    #include<bits/stdc++.h>
    using namespace std;
     
    typedef long long int LLi;
    typedef long long LL;
    typedef vector<long long> VLL;
    typedef vector<string> VS;
    typedef vector<pair<LLi, LLi> > VP;
     
     
    #define For(in) for (LLi i = 0; i < (n); i++)
    #define FOR(in) for(LLi i=1; i <= (n); i++)
    #define pb push_back
    #define sr(v) sort(v.begin(), v.end())
    #define rev(v) reverse(v.begin(), v.end())
    #define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
    #define exit(); return 0;
    #define no "NO"
    #define yes "YES"
    #define con continue;
     
     
    LLi concate(LLi a, LLi b)
    {
        ostringstream os;
        os <<a <<b;
        istringstream is(os.str());
        LLi c;
        is>> c;
        return c;
    }
     
     
    LLi check(char c)
    {
        return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
    }
     
     
    main()
    {
        LLi q,t;
     //   cin>>t;
      //  while(t--)
      //  {
            LLi a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
            LLi aa[1000];
            LLi flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
            LLi ma=0, mi=100000000;
            LLi mid=0, temp=0, stop=0, start=0;
            double pi= 3.141592653589793;
            double d1=0.0, d2, d3, d4;
            VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
            VS vs, vs1, vs2, vs3, vs4;
            VP vp, vp1,vp2;
            char ch, ch1, ch2[1001];
            string str, str1, str2, str3, str4, str5;
            pair<LLi, LLi> pa;
    //        list<LLi> li, li1;
      //      map<LLi, LLi> mp, mp1;
            set<LLi> st;
        //    map<LLi ,LLi> :: iterator imll;
            VLL :: iterator ivll;
            set<LLi> :: iterator isll;
            VP :: iterator ivp;
     
     
     
            cin>>str>>str1;
            for(i=0; i<str.size(); i++)
            {
    			if(str[i]!=str1[i])co++;
    		}
    		cout<<co<<endl;
     //    }
     
     
        exit()
     
     
    }

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int ans = 700;
    rep(i, 3){
        if(s[i] == 'o') ans += 100;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[5]={'a','e','i','o','u'},k;
    k=getchar();
    for(int i=0;i<5;i++){
        if(k==a[i]){
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

vector <int> v[N];
ll dp[N][2];
void dfs(int s, int pr)
{
	dp[s][0] = 1;
	dp[s][1] = 1;
	for (auto g : v[s])
	{
		if(g != pr)
		{
			dfs(g, s);
			dp[s][0] = (dp[s][0] * dp[g][1]) % MOD;
			dp[s][1] = (dp[s][1] * (dp[g][0] + dp[g][1])) % MOD;
		}
	}
}
int main()
{
	int n, x, y;
	cin >> n;
	for (int i = 0; i < n - 1; ++i)
	{
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1, 0);
	cout << (dp[1][0] + dp[1][1]) % MOD << "\n";
}


Measured memory_bytes: 14208
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n;
    cin>>n;
    int l=0,r=n-1;
    string t;
    string st;
    cout<<l<<endl;
    cin>>st;
    if(st=="Vacant"){
        cout<<l<<endl;
        return 0;
    }
    cout<<r<<endl;
    cin>>t;
    if(t=="Vacant") {
        cout << r << endl;
        return 0;
    }


    while(l<r){
        int mid = (l+r)/2;
        cout<<mid<<endl;
        cin>>t;
        if(t=="Vacant"){
            cout<<t<<endl;
            break;
        }
        if(mid%2==l%2){
            if(st==t){
                l=mid;
                st=t;

            }else{
                r=mid;
            }

        }else {
            if(st==t){
                r=mid;

            }else{
                l=mid;
                st=t;
            }

        }
    }









return 0;
}


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

const int N=100005;
int n,h[N],to[N+N],las[N+N],cnt,sg[N];

void dfs(int x,int fa)
{
	for(int i=h[x];i;i=las[i])
	    if(to[i]!=fa)
	    	dfs(to[i],x),sg[x]^=(sg[to[i]]+1);
}

int main()
{
	scanf("%d",&n);
	int i,u,v;
	for(i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		las[++cnt]=h[u],h[u]=cnt,to[cnt]=v;
		las[++cnt]=h[v],h[v]=cnt,to[cnt]=u;
	}
	dfs(1,-1);
	if(sg[1])printf("Alice");
	else printf("Bob");
	return 0;
}


Measured memory_bytes: 7296