akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

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

  int pnum = 1;
  int qnum = 1;
  rep(i,N) {
    int p = 1;
    rep1(j,N-i) p *= j;
    int np = P[i]-1;
    int nq = Q[i]-1;
    rep(j,i) {
      if (P[j] < P[i]) np--;
      if (Q[j] < Q[i]) nq--;
    } 
    pnum += p * np;
    qnum += p * nq;
  }

  int ans = abs(pnum - qnum);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// @author: arch_

#include <bits/stdc++.h>
using namespace std;

vector<char> grades;

int main(void) {
    char tmp;
    int m, f, r;
    while (cin >> m >> f >> r,
           m != -1 | f != -1 | r != -1) {
        if ((m == -1 || f == -1)
            || m + f < 30) tmp = 'F';
        else if (80 <= m + f) tmp = 'A';
        else if (65 <= m + f) tmp = 'B';
        else if (50 <= m + f
                 || (30 <= m + f & 50 <= r)) tmp = 'C';
        else if (30 <= m + f) tmp = 'D';
        grades.emplace_back(tmp);
    }
    for (auto&& g : grades) cout << g << "\n";
    return 0;
}

Measured memory_bytes: 3120
N=int(input())
L=[int(input()) for _ in range(5)]
ans=0
l=min(L)

for i in range(5):
    if L[i]==l:
        break

if N<min(L):
    ans=5
else:
    if N%L[i]==0:
        ans=N//L[i]+4
    else:
        ans=N//L[i]+5

print(ans)

Measured memory_bytes: 3064
#  very slow solution
def main():
	N = int(input())
	for n in range(1, 3502):
		for h in range(1,3502):
			t = n*h*N
			p = 4*n*h-(n*N+h*N)
			if p>0 and t%p==0:
				w = t//p
				print(n , h, w)
				exit()


if __name__=="__main__":
	main()

Measured memory_bytes: 64468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int V=sc.nextInt();	//Vertex->頂点数
		int E=sc.nextInt();//Edge->辺の数
		int[][] rinsetu=new int[V][V];
		int INF=1000000007;
		int[][] bitDP=new int[1<<V][V];
		//最初だからねしょうがないね
		//巡回セールスマン問題は、最初の地点は決まっておらず、任意の頂点からスタートできるので、
		//かならずしもスタートを頂点0からできないのでは？と思うが、それは偽で、
		//巡回セールスマン問題でもとめる最短経路は閉路（サイクル）なので、そのサイクルを構成する任意の点から始めても、
		//同じ答えを出すことができるので、スタートを頂点0だと決め打ちしても問題ない。
		for (int i = 0; i < V; i++) {
			Arrays.fill(rinsetu[i], INF);
		}
		for(int i=0; i<(1<<V); i++) {
			for(int j=0; j<V; j++) {
				bitDP[i][j]=INF;
			}
		}
		for(int i=0; i<E; i++) {
			int from=sc.nextInt();
			int to=sc.nextInt();
			int cost=sc.nextInt();
			rinsetu[from][to]=cost;
		}
		bitDP[1][0]=0;
		for(int i=0; i<(1<<V); i++) {
			for(int j=0; j<V; j++) {
				if(bitDP[i][j]==INF) {
					continue;		//経路を確立していないなら
				}
				else {
					for(int k=0; k<V; k++) {
						if((1&i>>k)==1) {
							continue;
						}
						else if(rinsetu[j][k]==INF){
							continue;
						}
						else {
							int nexti=i|(1<<k);
							bitDP[nexti][k]=Math.min(bitDP[nexti][k], bitDP[i][j]+rinsetu[j][k]);
						}
					}
				}
			}
		}
		int all=(1<<V)-1;
		int min=INF;
		for(int i=0; i<V; i++) {
			if(bitDP[all][i]==INF) {
				continue;
			}
			else if(rinsetu[i][0]==INF) {//さいしょにもどれないとき
				continue;
			}
			else {
				int allcost=bitDP[all][i]+rinsetu[i][0];
				min=Math.min(min, allcost);
			}
		}
		if(min==INF) {
			pl(-1);
		}
		else {
			pl(min);
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 28792
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int[] v = new int[n];
		int[] c = new int[n];
		for(int i = 0;i < n;i++){
			v[i] = sc.nextInt();
		}
		for(int i = 0;i < n;i++){
			c[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0;i < n;i++){
			if(v[i] - c[i] > 0){
				ans += v[i] - c[i];
			}
		}
		System.out.print(ans);
		
	}
	




static String deletestr(String base,String remove){
	boolean flag = true;
	for(int i = 0;i < remove.length();i++){
		if(i == base.length()){
			flag = false;
			break;
		}
		if(base.charAt(i) - remove.charAt(i) != 0 && base.charAt(i) - remove.charAt(i) != 32 &&remove.charAt(i) - base.charAt(i)  != 32){
			flag = false;
			break;
		}
	}

	if(flag){
		base = base.substring(remove.length());
	}

	return base;

}



}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




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

using namespace std;

typedef long long ll;

const ll mod = 1000000007;

ll dp[60][5][5];

int tr[60];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string r1[2];
	int N;
	cin >> N;
	cin >> r1[0] >> r1[1];
	for (int i = 0; i < N; ++i){
		if (r1[0][i] == r1[1][i]){
			tr[i+1] = 1;
		}
		else{
			i++;
			tr[i+1] = 2;
		}
	}
	if (tr[1] == 1){
		for (int i = 0; i < 3; ++i){
			for (int j = 0; j < 3; ++j){
				dp[1][i][j] = (i == j);
			}
		}
		
	}
	else{
		for (int i = 0; i < 3; ++i){
			for (int j = 0; j < 3; ++j){
				dp[2][i][j] = (i != j);
			}
		}

	}
	for (int i = 2+(bool)(tr[1] == 2); i <= N; ++i){
		if (tr[i] == 0) continue;
		else{
			if (tr[i] == 1){
				for (int j = 0; j < 3; ++j){
					for (int k = 0; k < 3; ++k){
						for (int l = 0; l < 3; ++l){
							for (int m = 0; m < 3; ++m){
								dp[i][j][k] += (j == k)*(j != l)*(k != m)*dp[i-1][l][m];
								dp[i][j][k] %= mod;
							}
						}
					}
				}
			}
			else{
				for (int j = 0; j < 3; ++j){
					for (int k = 0; k < 3; ++k){
						for (int l = 0; l < 3; ++l){
							for (int m = 0; m < 3; ++m){
								dp[i][j][k] += (j != k)*(j != l)*(k != m)*dp[i-2][l][m];
								dp[i][j][k] %= mod;
							}
						}
					}
				}
			}
		}
	}
	ll sum = 0;
	for (int i = 0; i < 3; ++i){
		for (int j = 0; j < 3; ++j){
			 sum += dp[N][i][j];
			 sum %= mod;
		}
	}
	cout << sum << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static String solve(String s) {
        return IntStream.range(0, s.length()).filter(i -> i % 2 == 0).mapToObj(i -> String.valueOf(s.charAt(i)))
                .collect(Collectors.joining());
    }
}

Measured memory_bytes: 28728
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll A,B,C; cin >> A >> B >> C;
    if (A%2==0 || B%2==0 || C%2==0) {
        cout << 0 << endl;
        return 0;
    }
    cout << min({A*B,B*C,C*A}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

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

	vector<int> l(N+1, 0);
	rep(i, N) {
		cin >> l[i+1];
	}

	vector<int> l2(N+1);
	rep_r(i, N) {
		int sum = 0;
		for(int j = i+i; j <= N; j += i) {
			sum ^= l2[j]; // 排他的論理和: XOR
		}
		l2[i] = sum ^ l[i];
	}

	vector<int> result;
	rep(i, N) {
		if(l2[i+1] == 1) result.push_back(i+1);
	}

	cout << result.size() << endl;
	rep(i, result.size()) {
		cout << result[i] << endl;
	}
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end(), greater<ll>());
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        ans += A[i/2];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
string S;
  cin >>S;
  ll Q;
  cin >>Q;
  vector<pair<ll,char>> ps(Q);
  rep(i,Q) {
    ll a;
    cin>>a;
    if(a==1) {
      ps.at(i).first=0;
      continue;
    }
    else if(a==2) {
      ll b;
      char c;
      cin >>b>>c;
      ps.at(i).first=b;
      ps.at(i).second=c;
    }
  }
  bool ans=true;
 rep(i,Q) {
   if(ps.at(i).first==0) {
     if(ans) {
       ans=false;
     }
     else {
       ans=true;
     }
   }
 }
   
  
  string onsid;
string othsid;

   bool tomo=true;
  rep(i,Q) {
    if(ps.at(i).first==0) {
      if(tomo) {
        tomo=false;
      }
      else {
        tomo=true;
      }
    }
    
    
    
    else if((ps.at(i).fi==1) &&(tomo==true)) {
      onsid+=ps.at(i).se;
    }
    
    else if((ps.at(i).fi==2) &&(tomo==true)) {
      othsid+=ps.at(i).se;
    }
    
    else if((ps.at(i).fi==1) &&(tomo==false)) {
      othsid+=ps.at(i).se;
    }
    
    else if((ps.at(i).fi==2) &&(tomo==false)) {
      onsid+=ps.at(i).se;
    }
    
    
  }
  
  
  
if(tomo==false) {
  reverse(all(S));
  reverse(all(othsid));
  cout<<othsid+S+onsid;
}
  
  else if(tomo==true) {
reverse(all(onsid));
  cout<<onsid+S+othsid;
}
  
  
  
}
  
  

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

int main(){
    string S,T;
    cin >> S >> T;
    int x = S.size(),y = T.size();
    string S1 = S;
    bool judje = 0;
    for(int i = x - y;i >= 0;i--){
        string S2 = S;
        bool frag = 1;
        for(int j = 0;j < y;j++){
            if(S[i + j] == T[j] || S[i + j] == '?'){
                S2[i+j] = T[j];
            }else{
                frag = 0;
            }
        }
        if(frag){
            S1 = S2;
            judje = 1;
            break;
        }
    }
    for(int i = 0;i < x;i++){
        if(S1[i] == '?'){
            S1[i] = 'a';
        }
    }
    if(judje){
        cout << S1 << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
}



Measured memory_bytes: 256
import sys
s=list(input())
n=len(s)
if n==1:
  print(1)
  sys.exit()
if n==2:
  if s[0]==s[1]:
    print(1)
  else:
    print(2)
  sys.exit()
ans=[0,1]
if s[0]==s[1]:
  ans.append(1)
else:
  ans.append(2)
for i in range(3,n+1):
  if s[i-2]==s[i-1]:
    ans.append(ans[i-3]+2)
  else:
    ans.append(ans[i-1]+1)
print(ans[n])

Measured memory_bytes: 12604
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  int a[100001];
  for (int i = 0; i <= 100000; ++i) a[i] = 0;
  for (int i = 0; i < n; ++i) {
    int ai;
    cin >> ai;
    a[ai]++;
  }
  int cnt = 0;
  for (int i = 0; i <= 100000; ++i) {
    if (a[i]>1) {
      cnt+=(a[i]-1);
    }
  }
  cout << n-(cnt+cnt%2) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	ll ans=0ll;
	ll a,b;
	cin>>a>>b;
	b/=a;
	a/=a;
	ll base=1ll;
	while(base<=b)
	{
		ans++;
		base*=2ll;
	}
	cout<<ans<<endl;
	
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define I(x, a) for(auto x : a)
#define F(i, l, r) for(auto i = l; i < r; ++i)
#define E(i, l, r) for(auto i = l; i <= r; ++i)
#define DF(i, l, r) for(auto i = l; i >= r; --i)
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define sz(a) ((int)(a).size())

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)1e9 + 7;
const dbl eps = (dbl)1e-8;
const int maxn = (int)1e5 + 5;
const dbl pi = acos(-1);

int n;
vector <int> a[333];
int dist[333], p[333];
int mx, mx_x;

void dfs(int v, int pr = -1) {
	if (pr == -1)
		dist[v] = 0;
	else
		dist[v] = dist[pr] + 1;
	if (dist[v] > mx) {
		mx_x = v;
		mx = dist[v];
	}
	p[v] = pr;
	I(to, a[v]) {
		if (to != pr)
			dfs(to, v);
	}
}

pair <ull, ull> solve() {
	mx = 0;
	mx_x = -1;
	clean(p);
	clean(dist);
	dfs(1);
	mx = 0;
	clean(p);
	clean(dist);
	dfs(mx_x);
	int x = mx_x;
	while (dist[x] != dist[mx_x] / 2 + dist[mx_x] % 2) {
		x = p[x];
	}
	vector <int> b, c;
	if (mx % 2 == 0) {
		b.pb(x);
		p[x] = -1;
	} else {
		b.pb(x);
		b.pb(p[x]);
		p[p[x]] = x;
	}
	/*
	cout << "B:" << endl;
	I(x, b)
		cout << x << " " << p[x] << endl;
	cout << endl;
	*/
	ull ansx = mx / 2 + 1;
	ull ans = 0;
	ull copies = 0;
//	exit(0);
//	int num = 0;
	while (1) {
		c.clear();
		ull mxcnt = 0;
		I(v, b) {
//			cout << v << " ";
			ull cnt = 0;
			I(to, a[v]) {
				if (to != p[v]) {
					++cnt;
					c.pb(to);
					p[to] = v;
				}
			}
			mxcnt = max(mxcnt, cnt);
		}
//		cout << endl;
		if (mxcnt == 0) {
//			cout << sz(b) << " " << copies << endl;
			ans = (ull)sz(b) + copies;
			break;
		}
		ull new_copies = 0;
		I(v, b) {
			ll cnt = 0;
			I(to, a[v]) {
				if (to != p[v])
					++cnt;
			}
			new_copies += (mxcnt - cnt);
		}
		new_copies += copies * mxcnt;
		copies = new_copies;
		swap(b, c);
	}
	return mp(ansx, ans);
}

int main() {
//	fin("t.in");
	sync;
	cin >> n;
	F(i, 1, n) {
		int x, y;
		cin >> x >> y;
		a[x].pb(y);
		a[y].pb(x);
	}
	ull ansx0, ans0;
	ull ansx1, ans1;
	tie(ansx0, ans0) = solve();
	E(i, 1, n) {
		int x = i;
		vector <pii> todel;
		int oldn = n;
		while (1) {
			a[x].pb(n + 1);
			a[n + 1].pb(x);
			todel.pb({x, n + 1});
			++n;
			tie(ansx1, ans1) = solve();
			if (ansx1 == ansx0) {
				ans0 = min(ans0, ans1);
			} else {
				break;
			}
			x = n;
		}
		n = oldn;
		I(p, todel) {
			a[p.X].pop_back();
			a[p.Y].pop_back();
		}
	}
	cout << ansx0 << " " << ans0 << endl;
	return 0;
}

Measured memory_bytes: 256
import statistics,collections

n = int(input())
a = list(map(int,input().split()))
ans = []

for i in range(n):
    ans.append(a[i])
    ans.append(a[i]-1)
    ans.append(a[i]+1)

c = collections.Counter(ans)
print(c.most_common()[0][1])

Measured memory_bytes: 32576
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

pair<long long, long long> extended_gcd(long long a, long long b) {
	if (b == 0) return { 1, 0 };
	auto t = extended_gcd(b, a % b);
	return { t.second, t.first - t.second * (a / b) };
}

inline long long modinv(long long a, long long m) {
	return (extended_gcd(a, m).first % m + m) % m;
}

const int MOD = 1000000007;
int fact[4000001], factinv[4000001];

inline int comb(int n, int m) {
	if (m < 0 || m > n) return 0;
	return ((long long)fact[n] * factinv[m] % MOD) * factinv[n - m] % MOD;
}

int n, k;
int d[2001][2001];

int main() {
	scanf("%d %d", &n, &k);

	fact[0] = 1;
	for (int i = 1; i <= n * k; ++i) {
		fact[i] = (long long)fact[i - 1] * i % MOD;
	}
	factinv[0] = 1;
	factinv[n * k] = modinv(fact[n * k], MOD);
	for (int i = n * k; i > 1; --i) {
		factinv[i - 1] = (long long)factinv[i] * i % MOD;
	}
	if (k == 1) {
		printf("1\n");
		return 0;
	}

	for (int i = 0; i <= n; ++i) {
		for (int j = i; j <= n; ++j) {
			if (i == 0 && j == 0) {
				d[i][j] = 1;
				continue;
			}
			d[i][j] = ((i > 0 ? d[i - 1][j] : 0) + (long long)d[i][j - 1] * comb(i + j * (k - 1) - 1, k - 2)) % MOD;
		}
	}
	int ans = d[n][n];
	for (int i = 2; i <= n; ++i) {
		ans = (long long)ans * i % MOD;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

	int n; cin >> n;

  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(i%3 == 0 || i%5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;

 	return 0;
}


Measured memory_bytes: 3592
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
edges = {}
flag = 'IMPOSSIBLE'
for a, b in AB:
    if a in edges:
        edges[a].append(b)
    else:
        edges[a] = [b]
for i in edges[1]:
    if i not in edges:
        continue
    if N in edges[i]:
        flag = 'POSSIBLE'
        break

print(flag)

Measured memory_bytes: 66572
#include<stdio.h>
int main(void){
    int a,b,c,d,e=0,f,g,h,i,j,k;
    for(d=1;d<=100;d++){
    scanf("%d %d %d",&a,&b,&c);
     
    if(a==-1&&b==-1&&c==-1){
        break;
    }
    if(a==-1||b==-1){
        printf("F\n");
        continue;
    }
     e=a+b;
    if(e>=80){
        printf("A\n");
        continue;
    }
    else if(e>=65){
        printf("B\n");
        continue;
    }
    else if(e>=50||c>=50){
        printf("C\n");
        continue;
    }
    else if(e>=30){
        printf("D\n");
        continue;
    }
    else if(e<30){
        printf("F\n");
        continue;
    }   
    }
}


Measured memory_bytes: 2112
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <stdio.h>
//#include <cstdlib>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue() {
  int a;
  cin >> a;
  return a;
};

void inputArray(int * p, int a) {
  rep(i, a) {
    cin >> p[i];
  }
};

void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, int r, int c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}



int main(int argc, const char * argv[]) {
  int width = 100;
  int n = inputValue();
  auto a1 = vector<vector<int>>(n, vector<int>(3, 0));
  auto seikai = vector<int>(3, 0);
  inputVector2(a1, n, 3);
  int htemp = 0;
  bool T = true;

  for (int i = 0; i <= width; i++)
  {
    for (int j = 0; j <= width; j++)
    {
      T = true;
      for (int k = 0; k < n; k++) {
        if (a1[k][2] > 0) {
          htemp = a1[k][2] + abs(i - a1[k][0]) + abs(j - a1[k][1]);
          break;
        }
      }
      for (int k = 0; k < n; k++) {
        if (a1[k][2] > 0 && a1[k][2] + abs(i - a1[k][0]) + abs(j - a1[k][1]) != htemp) {
          T = false;
          break;
        }
        else if (a1[k][2] == 0 && htemp - abs(i - a1[k][0]) - abs(j - a1[k][1]) > 0) {
          T = false;
          break;
        }
      }
      if (T) {
        seikai[0] = i;
        seikai[1] = j;
        seikai[2] = htemp;
        goto LABEL;
      }
    }
  }
LABEL:
  printf("%d %d %d", seikai[0], seikai[1], seikai[2]);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
  ll n, k;
  cin >> n >> k;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];

  ll ans = MOD;
  for(ll l = 0; l <= n - k; l++){
    ll dist = x[l + k - 1] - x[l];
    ll start = min(abs(x[l + k - 1]), abs(x[l]));
    ll tmp = dist + start;
    ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

ll N;
std::vector<ll> a;
vector<vector<vector<double>>> dp;

double f(ll c1, ll c2, ll c3) {
  if (dp[c1][c2][c3] != -1.0) return dp[c1][c2][c3];

  if (c1 == 0 && c2 == 0 && c3 == 0) return 0.0;

  double ret = 0.0;
  if (c1 > 0) ret += f(c1 - 1, c2, c3) * c1;
  if (c2 > 0) ret += f(c1 + 1, c2 - 1, c3) * c2;
  if (c3 > 0) ret += f(c1, c2 + 1, c3 - 1) * c3;
  ret += N;
  ret *= 1.0 / (c1 + c2 + c3);
  return dp[c1][c2][c3] = ret;
}

void solve() {
  dp.resize(310, vector<vector<double>>(310, vector<double>(310, -1.0)));

  ll c1 = 0, c2 = 0, c3 = 0;
  rep(i, N) {
    if (a.at(i) == 1) c1++;
    if (a.at(i) == 2) c2++;
    if (a.at(i) == 3) c3++;
  }
  cout << f(c1, c2, c3) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  scanf("%lld", &N);
  a.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve();
  return 0;
}


Measured memory_bytes: 240628
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto a = readln.chomp.to!int;
    auto b = readln.chomp.to!int;
    auto c = readln.chomp.to!int;
    auto d = readln.chomp.to!int;
    auto e = readln.chomp.to!int;
    auto k = readln.chomp.to!int;

    auto ts = [a, b, c, d, e];
    foreach (i; 0..5) {
        foreach (j; i+1..5) {
            if (ts[j] - ts[i] > k) {
                writeln(":(");
                return;
            }
        }
    }
    writeln("Yay!");
}

Measured memory_bytes: 256
while True:
    try:
        s = input()
    except:
        break
    joi = 0
    ioi = 0
    for i in range(len(s) - 2):
        x = s[i] + s[i + 1] + s[i + 2]
        if x == "JOI":
            joi += 1
        if x == "IOI":
            ioi += 1
    print(joi)
    print(ioi)

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

uint64_t srv_f(string N, int c, int K)
{
	int l = N.length() - c;
	if(l < K){
		return 0;
	} else {
		if(K == 0){
			return 1;
		} else if(K == 1){
			return 9 * l;
		} else if(K == 2){
			return 9 * 9 * l * (l-1) / 2;
		} else if(K == 3){
			return 9 * 9 * 9 * l * (l-1) * (l-2) / 3 / 2;
		}
	}
}

uint64_t srv(string N, int c, int K)
{
	if(K == 0){
		return 1;
	}
	if(N.length() == c){
		return 0;
	}

	char t = N[c];
	if(t == '0'){
		return srv(N, c+1, K);
	} else {
		return srv_f(N, c+1, K)
			+ (t - '1') * srv_f(N, c+1, K-1)
			+ srv(N, c+1, K-1);
	}
}

int main()
{
	string N;
	int K;
	cin >> N >> K;

	cout << srv(N, 0, K);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int i, j;
	string s, res, tmp;
	while (!cin.eof())
	{
		getline(cin, s);
		res = tmp = s;
		for (i = 0; i < 27; i++)
		{
			res = tmp;
			for (j = 0; j < (int)s.size(); j++)
			{
				if (s[j] != ' ' && s[j] != '.')
				{
					if (s[j] + i > 'z')
						res[j] = 'a' + s[j] + i - 'z' - 1;
					else
						res[j] = s[j] + i;
				}
				else
				{
					res[j] = s[j];
				}
			}
			if (res.find("the") != string::npos || res.find("this") != string::npos || res.find("that") != string::npos)
			{
				cout << res << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 0
/**
 *     author: qodjf
 *     created: 05.01.2020 01:24:47
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

bool solve(int N) {
  int sum = 0;
  vector<int> nums;
  for (int i = 2;; i++) {
    if (i % 2 == 0 || i % 3 == 0) {
      nums.push_back(i);
      sum += i;
      if (nums.size() == N - 1) break;
    }
  }
  if (sum % 6 == 5 && N > 6) {
    for (int i = N - 2; i >= 0; i--) {
      if (nums[i] % 6 == 3) {
        sum -= nums[i];
        nums.erase(nums.begin() + i);
        nums.push_back(nums.back() + 2);
        sum += nums.back();
        break;
      }
    }
  }

  for (int x : nums) {
    cout << x << ' ';
  }
  for (int x = nums.back() + 1; x <= 30000; x++) {
    if ((x + sum) % 6 == 0 && __gcd(x, sum) > 1) {
      cout << x << endl;
      return true;
    }
  }
  dbg(N, sum, sum % 6);
  return false;
}

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

  int N;
  cin >> N;
  solve(N);
}


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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N,0));
    vector<vector<int>> v(N*N);
    vector<int> cnt(N*N, 0);

    auto id = [&](int x, int y){
        return x*N+y;
    };
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin >> A[i][j];
            A[i][j]--;
            if(j == 0) continue;
            
            int a = (i < A[i][j-1] ? id(i, A[i][j-1]) : id(A[i][j-1], i));
            int b = (i < A[i][j]? id (i, A[i][j]) : id(A[i][j], i));
            v[a].push_back(b);
            cnt[b]++;
        }
    }

    vector<int> vis(N*N);
    function<bool(int)> dfs = [&](int n){
        bool ok = true;
        vis[n] = -1;
        for(auto x:v[n]){
            //未訪問　=> 再帰
            if(vis[x] == 0) ok &= dfs(x);
            //閉路検出 => false
            else if(vis[x] == -1) return false;
        }
        vis[n] = 1;
        return ok;
    };

    for(int i=0;i<N*N;i++){
        if(!vis[i] && !dfs(i)){
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i=0;i<N*N;i++) vis[i] = 0;
    vector<int> u;
    function<void(int)> dfs2 = [&](int n){
        vis[n] = 1;
        for(auto x:v[n]) if(vis[x] == 0) dfs2(x);
        u.push_back(n);
    };
    for(int i=0;i<N*N;i++) if(cnt[i] == 0) dfs2(i);
    reverse(u.begin(), u.end());
    vector<int> dp(N*N);
    for(int i=0;i<u.size();i++){
        for(auto x:v[u[i]]){
            dp[x] = max(dp[x], dp[u[i]] + 1);
        }
    }
    int ans = 0;
    for(int i=0;i<N*N;i++) ans = max(ans, dp[i]);
    cout << ans+1 << endl;
}

Measured memory_bytes: 59120
#include <bits/stdc++.h>
using namespace std;
const int Maxn=200005;
int n,ans,head[Maxn],cnt,dp[Maxn];
struct edg
{
	int nxt,to;
}edge[2*Maxn];
void add(int x,int y)
{
	edge[++cnt]=(edg){head[x],y};
	head[x]=cnt;
}
void dfs(int u,int fa)
{
	dp[u]=1;
	for(int i=head[u];i;i=edge[i].nxt)
	{
		int to=edge[i].to;
		if(to!=fa)
		{
			dfs(to,u);
			ans=max(ans,dp[u]+dp[to]);
			dp[u]=max(dp[u],dp[to]+1);
		}
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		add(a,b);
		add(b,a);
	}
	dfs(1,0);
	if(ans%3==2)
	{
		printf("Second");
		return 0;
	}
	printf("First");
	return 0;
}

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

int main(){
  
  int a,b;
  cin >> a >> b;
  
  int length = b*2;
  
  if(a > length){
    cout << a - length << endl;
  }
  else{
    cout << 0 << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int x[2];
  while(true){
    cin >> x[0] >> x[1];
    if(x[0]==0 && x[1]==0)
      break;
    sort(x,x+2);
    cout << x[0] << " " << x[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
/* ***********************************************
Author        :yang12138
Created Time  :2017年04月13日 星期四 01时52分59秒
File Name     :F.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1e6+10;
const int mod=1e9+7;
ll dp[N],s[N];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	int n;
	scanf("%d",&n);

	dp[0]=1,dp[1]=n,dp[2]=n;
	s[0]=1,s[1]=n+1,s[2]=2*n+1;
	for(int i=3;i<n;i++){
		dp[i]=dp[i-1]+s[i-3];
		dp[i]%=mod;
		s[i]=s[i-1]+dp[i];
		s[i]%=mod;
	}

	ll ans=(n+(s[n-1]-1)*(n-1))%mod;
	printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

int main(){
	int N=0, M=0;
	cin >> N >> M;

	vector<unsigned int> s(M, 0);
	unsigned int p;

	for(int i=0; i<M; i++){
		int k;
		cin >> k;
		for(int j=0; j<k; j++){
			int l;
			cin >> l;
			l--;
			s[i]|=(1<<l);
		}
	}

	for(int i=0; i<M; i++){
		int k;
		cin >> k;
		p|=(k<<i);
	}

	int r=0;
	for(int i=0; i<(1<<N); i++){
		int f=1;
		for(int j=0; j<M; j++){
			if(((p&(1<<j))>>j)!=(__builtin_popcount(i&s[j])&(1))){
				f=0; break;
			}
		}
		r+=f;
	}

	cout << r << endl;

	return 0;

}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  int A,B,C;
  cin>>A>>B>>C;
  
  if(A==B && A!=C) cout<<"Yes"<<endl;
  else if(C==B && A!=C) cout<<"Yes"<<endl;
  else if(A==C && B!=C) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
// #define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair<int,int>
// #define pii pair< int, pi >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
using namespace std::chrono;

string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<int> prime={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199,
211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293,
307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397,
401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499,
503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599,
601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691,
701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797,
809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887,
907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997,1009
};

void solve(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int gcdglobal=__gcd(a[0],a[1]);
  rep(i,2,n) gcdglobal=__gcd(gcdglobal,a[i]);

  map<int,int> m1;
  rep(i,0,n){
    rep(kl,0,(int)prime.size()){
      int c=0;
      while(a[i]%prime[kl]==0) a[i]=a[i]/prime[kl],c++;
      if(c>0) m1[prime[kl]]++;
    }
    if(a[i]>1) m1[a[i]]++;
  }

  int mx=1;
  for(auto i:m1) mx=max(mx,i.s);

  if(mx==1) cout<<"pairwise coprime\n";
  else if(gcdglobal==1) cout<<"setwise coprime\n";
  else cout<<"not coprime\n";
}
int main(){
    optimizeIO();
    solve();
}


Measured memory_bytes: 11140
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;typedef vector<int> ivec;typedef vector<string> svec;

int main(){
	char N[10];
	int ans = 0;
	scanf("%s",&N);
	for(int i=0;i<4;i++){
		if(N[i]=='2') ++ans;
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		String[] inputString = input.split("");
		int[] inputInt = new int[4];
		for (int i = 0; i < inputString.length; i++) {
			inputInt[i] = Integer.parseInt(inputString[i]);
		}
		String[][] op = { { "+", "+", "+" }, { "+", "+", "-" }, { "+", "-", "+" }, { "+", "-", "-" }, { "-", "+", "+" },
				{ "-", "+", "-" }, { "-", "-", "+" }, { "-", "-", "-" } };
		for (String[] strArray : op) {
			int sum = inputInt[0];
			for (int i = 0; i < strArray.length; i++) {
				if ("+".equals(strArray[i])) {
					sum += inputInt[i + 1];
				} else {
					sum -= inputInt[i + 1];
				}
			}
			if (sum == 7) {
				System.out.print(inputInt[0]);
				for (int i = 0; i < strArray.length; i++) {
					System.out.print(strArray[i]);
					System.out.print(inputInt[i + 1]);
				}
				System.out.print("=7");
				break;
			}
		}
	}
}


Measured memory_bytes: 21716
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 1000000007
#define meme(x) memset((x), 0, sizeof((x)))
#define memo(x) memset((x),-1, sizeof((x)))
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll

ll egcd(ll a, ll b, ll &x, ll &y){
    if (a == 0LL){  
        x = 0LL;  
        y = 1LL;  
        return b;  
    }
    ll xx, yy;
    ll val = egcd(b % a, a, xx, yy);  
    x = yy - (b / a) * xx;  
    y = xx;  
    return val;
}

ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}

//  ==========      //\\       //||     ||====//||
//      ||         //  \\        ||     ||   // ||
//      ||        //====\\       ||     ||  //  ||
//      ||       //      \\      ||     || //   ||
//  ==========  //        \\  ========  ||//====|| 
//  code

void solve(){
    int n,m,i,j,k,l,p;
    cin >> n >> m;
    vector<string> a(n);
    vector< vector<int> > dp(n, vector<int>(m));

    for(auto &i : a)
        cin >> i;
    
    dp[0][0] = 1;
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            if(i == 0 && j == 0)
                continue;

            if(a[i][j] == '#'){
                dp[i][j] = 0;
                continue;
            }

            else if(i == 0)dp[i][j] = dp[i][j - 1];
            else if(j == 0)dp[i][j] = dp[i - 1][j];
            else dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    }

    cout << dp[n - 1][m - 1] << endc;
}

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


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

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

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

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

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

    ll cnt = 1;
    bool f = false;
    REP(i,0,N) {
        if(a[i] == cnt) {
            ++cnt;
            f = true;
        }
    }
    if(f) PR(N-(cnt-1));
    else PR(-1);

    return 0;
}

/*



*/

Measured memory_bytes: 4812
#include <iostream>
#include <vector>
using namespace std;
int p[1000000];
int main()
{
  int i,j,k=1;
  vector<int> v(10000);
  v[0] = 2;
  for(i=3;i<1000000;i+=2){
    if(p[i] == 0){
      v[k] = i + v[k-1];
      k++;
      if(k >= 10000) break;
      for(j=i*2;j<1000000;j+=i){
	p[j] = 1;
      }
    }
  }
  while(cin >> i,i){
    cout << v[i-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <bitset>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

vector<vector<int>> g[2];

vector<int> col[2];

void dfs(int v, int t, int c) {
	col[t][v] = c;
	for (int u : g[t][v]) {
		if (col[t][u] == -1)
			dfs(u, t, c);
	} 
}

struct City {
	int x, y;
	int id;
};

bool operator < (const City &a, const City &b) {
	if (a.x != b.x)
		return a.x < b.x;
	if (a.y != b.y)
		return a.y < b.y;
	return a.id < b.id;
}

int main() {
	int n;
	cin >> n;
	int k, l;
	cin >> k >> l;
	for (int i = 0; i < 2; ++i) {
		g[i].resize(n);
		col[i].resize(n, -1);
	}

	for (int i = 0; i < k; ++i) {
		int u, v;
		cin >> u >> v;
		--u; --v;

		g[0][u].push_back(v);
		g[0][v].push_back(u);
	}

	for (int i = 0; i < l; ++i) {
		int u, v;
		cin >> u >> v;
		--u; --v;

		g[1][u].push_back(v);
		g[1][v].push_back(u);
	}

	for (int t = 0; t < 2; ++t) {
		int color = 0;
		for (int i = 0; i < n; ++i) {
			if (col[t][i] == -1)
				dfs(i, t, color++);
		}
	}

	vector<City> type(n);

	for (int i = 0; i < n; ++i) {
		type[i].x = col[0][i];
		type[i].y = col[1][i];
		type[i].id = i;
 	}

 	sort(all(type));

 	vector<int> res(n);

 	int prev = 0;
 	for (int i = 1; i <= n; ++i) {
 		if (i == n || type[i].x != type[i - 1].x || type[i].y != type[i - 1].y) {
 			for (int j = prev; j < i; ++j)
 				res[type[j].id] = i - prev;
 			prev = i;
 		}
 	}
	
	for (int i = 0; i < n; ++i)
		cout << res[i] << " ";
	cout << endl;



	return 0;
}

Measured memory_bytes: 20480