akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(int a, int b) {
    return (ll)a * b / gcd(a, b);
}
int main() {
    int n, m; cin >> n >> m;
    string s, t; cin >> s >> t;
    int g = gcd(n, m);
    rep(i, g) {
        if (s[i * n / g] != t[i * m / g]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << lcm(n, m) << endl;
}


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

int N, A[100005], B[100005], C[100005], dp[100005][3];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i] >> B[i] >> C[i];
	for (int i = 1; i <= N; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i];
	}
	cout << max({dp[N][0], dp[N][1], dp[N][2]}) << '\n';
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

//input
int X;

 
//processing


//dpTable
//int dp[100050];

int main(){
    cin >> X;
    for (int i = X; i <= 100003; i++){
        if (IsPrime(i)){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


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

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

  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  if (a[0] + a[1] + a[2] > 21)
  {
    cout << "bust" << endl;
  }
  else
  {
    cout << "win" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll l;
    cin>>l;
    printf("%.6lf\n",(double)l*l*l/27);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, M;
pii drink[100100];

signed main() {
    cin >> N >> M;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        drink[i] = pii(a, b);
    }
    sort(drink, drink + N);
    int n = 0, p = 0;
    rep(i, N) {
        if (n == M)break;
        pii d = drink[i];
        if (n + d.second > M) {
            int c = M - n;
            n = M;
            p += d.first * c;
        } else {
            n += d.second;
            p += d.first * d.second;
        }
    }
    cout << p << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author k15115kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String str = reader.readLine();
             String[] arr = str.split(" ");
            int a = Integer.parseInt(arr[0]);
            int b = Integer.parseInt(arr[1]);
            int c = Integer.parseInt(arr[2]);
            
            Arrays.sort(arr);
            System.out.println(arr[0]+" "+arr[1]+" "+arr[2]);
        }catch(IOException e){
            e.printStackTrace();
        }
    }
    
}

Measured memory_bytes: 24208
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
vector<pair<int,int> > v;
int main() {
	int n,m;
	cin >> n>>m;
	int x,y,cnt = 0;
	for(int i = 0; i < m; i++){
		cin >> x >> y;
		v.push_back({y,x});
	}
	sort(v.begin(),v.end());
	int nowpos = v[0].second;
	for(int i = 0; i < m;i++){
		//cout << "***" << v[i].first << " "<<v[i].second<<endl;
		 if(v[i].second >= nowpos){
			nowpos = v[i].first;
			cnt++;
		}
		//cout << "now:" <<nowpos <<" cnt:" << cnt<< endl;
	}
	cout << cnt << endl;
    return 0;
}

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

using namespace std;

int main() {
	int k;
	cin >> k;
	vector <int>d(k, -1);
	d[1] = 1;
	queue <int> q;
	queue <int> aux;
	q.push(1);
	while (!q.empty() || !aux.empty()) {
		if (q.empty()) {
			q = aux;
			while (!aux.empty()) aux.pop();
		}
		int u = q.front();
		q.pop();
		if (d[(10*u)%k] == -1 || d[(10*u)%k] > d[u]) {
			q.push((10*u)%k);
			d[(10*u)%k] = d[u];
		}
		if (d[(10*u+1)%k] == -1) {
			aux.push((10*u+1)%k);
			d[(10*u+1)%k] = d[u]+1;
		}
	}
	cout << d[0] << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		StringBuffer S = new StringBuffer(scan.next());
		int Q = scan.nextInt();
		int f = 0;

		for (int i = 0; i < Q; i ++) {
			int t = scan.nextInt();

			if (t == 1) {
				f++;
			} else {
				int F = scan.nextInt();
				String C = scan.next();

				if (f % 2 == 0) {
					if (F == 1) {
						S.insert(0, C);
					} else {
						S.insert(S.length(), C);
					}
				} else {
					if (F == 2) {
						S.insert(0, C);
					} else {
						S.insert(S.length(), C);
					}
				}
			}
		}

		if (f % 2 == 1) {
			S.reverse();
		}

		System.out.println(S);

	}

}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

struct UnionFind {
	vector<int> p, r;

	UnionFind() {}
	UnionFind(int size) { init(size); }

	void init(int size) {
		p.resize(size);
		r.resize(size);
		for (int i = 0; i < size; ++i) {
			p[i] = i; r[i] = 1;
		}
	}

	int root(int x) {
		if (p[x] == x) return x;
		else return p[x] = root(p[x]);
	}

	void unite(int x, int y) {
		x = root(x); y = root(y);

		if (x == y) return;

		if (r[x] > r[y]) swap(x, y);
		r[x] += r[y];
		p[y] = x;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

struct edge {
	int from, to, cost;
	edge () {}
	edge (int from, int to, int cost) :from(from), to(to), cost(cost) {}
	bool operator<(const edge& e) const{
		return cost<e.cost;
	}
};

int kruskal(int V, vector<edge> &edges) {
	int res = 0;
	sort(edges.begin(), edges.end());
	UnionFind uf(V + 1);
	for (int i = 0; i < (int)edges.size(); ++i) {
		edge e = edges[i];
		if (!uf.same(e.from, e.to)) {
			res += e.cost;
			uf.unite(e.from, e.to);
		}
	}

	return res;
}

signed main() {
	int n = in();
	vector<pii> x, y;
	rep(i, n) {
		int a = in(), b = in();
		x.pb(mp(a, i));
		y.pb(mp(b, i));
	}

	sort(all(x));
	sort(all(y));

	vector<edge> e;
	for (int i = 1; i < n; ++i) {
		e.pb(edge(x[i].sc, x[i - 1].sc, x[i].fs - x[i - 1].fs));
		e.pb(edge(y[i].sc, y[i - 1].sc, y[i].fs - y[i - 1].fs));
	}

	cout << kruskal(n, e) << endl;
}


Measured memory_bytes: 7144
s = gets.chomp.split('')
t = gets.chomp.split('')
hs = {}
ht = {}
s.size.times do |i|
  if hs[s[i]]
    if hs[s[i]] != t[i]
      puts 'No'
      exit
    end
  elsif ht[t[i]]
    if ht[t[i]] != s[i]
      puts 'No'
      exit
    end
  else
    hs[s[i]] = t[i]
    ht[t[i]] = s[i]
  end
end
puts 'Yes'


Measured memory_bytes: 24828
#include <iostream>
#include <map>
using namespace std;
int main()
{
  int N;
  cin >> N;
  map<string, int> mp;
  for (int i = 0; i < N; i++)
  {
    string s;
    cin >> s;
    mp[s]++;
  }
  int M;
  cin >> M;
  for (int i = 0; i < M; i++)
  {
    string t;
    cin >> t;
    mp[t]--;
  }
  int ans = 0;
  for (auto a : mp)
  {
    if (ans < a.second)
      ans = a.second;
  }
  cout << ans << endl;
}

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

int main() {
    int n,k;
    cin >> n;
    int a[n][3], dp[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)
            cin >> a[i][j];
    }
    dp[0][0] = a[0][0]; dp[0][1] = a[0][1]; dp[0][2] = a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    int ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    cout << ans;
	return 0;
}


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

int main(int argc, char const *argv[]) {
    int N, num=0, max=0;
    cin >> N;
    vector<int> height(N);

    for (int i=0; i<N; i++) {
        cin >> height.at(i);
        if (i!=0 && height.at(i-1) >= height.at(i)) {
            num++;
            if (max < num) {
                max = num;
            }
        } else {
            num = 0;
        }
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 640
#define rep(i,n) for (int i=0; i<(int)(n); ++i)

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

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

    vector<int> A(N);
    rep(i,N) cin >> A[i];

    bool flg = true;

    rep(i,N){
        if(A[i] % 2 == 0){
            if(A[i] % 3 != 0){
                if(A[i] % 5 != 0){
                    flg = false;
                }
            }
        }
    }
    if(flg) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    char str[3];
    cin >> str;

    if (str[0] == str[1] && str[0] == str[2] && str[1] == str[2])
    {
        cout << "No" << endl;
    }else
    {
        cout << "Yes" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[10];
long long c[5][4200000];
long long d[5][4200000];
int C[5];
int D[5];
long long p10[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000LL};
int main(){
	int a;scanf("%d",&a);
	long long S=0;
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
		b[i]--;
		S*=10;
		S+=b[i];
	}
	int ans=a-1;
	int start=123456789;
	for(int i=0;i<10-a;i++)start/=10;
	c[0][C[0]++]=start;
	d[0][D[0]++]=S;
	for(int i=0;i<4;i++){
	//	printf("%d %d\n",C[i],D[i]);
		for(int j=0;j<C[i];j++){
			for(int k=0;k<a;k++){
				for(int l=k+1;l<a;l++){
					long long TO=0;
					for(int m=0;m<a;m++){
						TO*=10;
						if(k<=m&&m<=l)TO+=c[i][j]%p10[a-k-l+m]/p10[a-k-l+m-1];
						else TO+=c[i][j]%p10[a-m]/p10[a-1-m];
					}
					c[i+1][C[i+1]++]=TO;
				}
			}
		}
		for(int j=0;j<D[i];j++){
			for(int k=0;k<a;k++){
				for(int l=k+1;l<a;l++){
					long long TO=0;
					for(int m=0;m<a;m++){
						TO*=10;
						if(k<=m&&m<=l)TO+=d[i][j]%p10[a-k-l+m]/p10[a-k-l+m-1];
						else TO+=d[i][j]%p10[a-m]/p10[a-1-m];
					}
					d[i+1][D[i+1]++]=TO;
				}
			}
		}
	}
	for(int i=0;i<5;i++){
		std::sort(d[i],d[i]+D[i]);
	}
	for(int i=0;i<a-1;i++){
		int n=i/2;
		bool ok=false;
		for(int j=0;j<C[n];j++)if(binary_search(d[i-n],d[i-n]+D[i-n],c[n][j]))ok=true;
		if(ok){
			printf("%d\n",i);
			return 0;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 80916
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int v[6];
  REP(i, 5) cin >> v[i];
  int k;
  cin >> k;
  bool flag = false;
  REP(i, 5){
    FOR(j, i+1, 5){
      //cerr << abs(v[i] - v[j]) << endl;
      if(v[j] - v[i] > k){
	flag = true;
      }
    }
  }
  if(flag) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
if n == 2:
    print(1)
    exit()

fact = [n]
fact1 = [n-1]
i = 2
while i * i <= n:
    if n % i == 0:
        fact += [i]
        if n // i != i:
            fact += [n//i]
    i += 1

i = 2
while i * i <= n-1:
    if (n-1) % i == 0:
        fact1 += [i]
        if (n-1) // i != i:
            fact1 += [(n-1)//i]
    i += 1

ans = 0
for x in fact:
    k = n
    while k % x == 0:
        k //= x
    if k % x == 1:
        ans += 1

print(ans + len(fact1))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
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 fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, 1, 0, -1};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n - 1) {
		int b;
		cin >> b;
		a[b - 1]++;
	}
	rep(i, n) {
		if (i) cout << " ";
		cout << a[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int cnt=0;
  for(int i=0;i<N;i++){
    int h;
    cin >> h;
    if(h>=K){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
S = input()

s = list(S)
a = []
b = []
if N % 2 != 0:
    print('No')
else:
    M = int(N/2)
    for i in range(M):
        a.append(s[i])
        b.append(s[i+M])
    if a == b:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

string dif(vector<int> A) 
{
	bool TF = true;
	sort(A.begin(), A.end());
	for (int i = 0; i < A.size() - 1; i++) 
	{
		if (A.at(i) == A.at(i + 1)) 
		{
			TF = false;
		}
	}
	if (TF == true) 
	{
		return "YES";
	}
	else 
	{
		return "NO";
	}
}

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

	vector<int> A(N);
	for (int i = 0; i < N; i++) 
	{
		cin >> A.at(i);
	}

	cout << dif(A) << endl;

	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;

  int cnt = 0, ext_rank = 1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'c') {
      cout << "No\n";
      continue;
    }

    if (s[i] == 'a') {
      if (a + b > cnt) {
        cout << "Yes" << '\n';
        cnt++;
      } else {
        cout << "No\n";
      }
    } else {
      if (a + b > cnt && ext_rank <= b) {
        cout << "Yes\n";
        cnt++;
        ext_rank++;
      } else {
        cout << "No\n";
      }
    }
  }

  return 0;
}

Measured memory_bytes: 896
fun main(args: Array<String>) {
    a55(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a55(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val n = args[0].toInt()
    print(800 * n - 200 * (n / 15))
}

Measured memory_bytes: 33656
#include<bits/stdc++.h>
using namespace std;
long long N;
int main(){
    cin>>N;
    vector<long long>A(N+1),P(N+1,0LL);
    for(int i=0;i<=N;i++)cin>>A[i];
    if(N==0LL&&A[0]!=1LL){cout<<-1<<endl;return 0;}
    if(N==0LL&&A[0]==1LL){cout<<1<<endl;return 0;}
    if(N!=0LL&&A[0]!=0LL){cout<<-1<<endl;return 0;}
    long long P_num=1LL,ans=1LL;

    for(int i=1;i<=N;i++){
        //cout<<"i:"<<i<<"A[i]:"<<A[i]<<"P_num:"<<P_num<<endl;
        if(A[i]>P_num*2LL){cout<<-1<<endl;return 0;}
        P_num*=2LL;
        P_num-=A[i];
        ans+=P_num+A[i];
        P[i]=P_num;
        if(P_num>100000000000000LL)P_num=100000000000000LL;
    }
    P[0]=1LL;

    //for(auto x:P)cout<<x<<endl;
    //if(P_num==0LL){cout<<ans<<endl;return 0;}
    //if(A[N]==0LL){cout<<-1<<endl;return 0;}
    long long active=A[N];
    ans=active;
    for(int i=N-1;i>=0;i--){
        if(active>P[i]*2LL){cout<<-1<<endl;return 0;}
        active=min(active,P[i]);
        active+=A[i];
        ans+=active;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4752
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int N, K;
int D[2001];
int E[4001], ne[4001], he[2001];
int d, k;
void dfs(int v) {
	D[v] = d;
	d++;
	for (int to = he[v]; to; to = ne[to]) {
		if (D[E[to]] == -1) dfs(E[to]);
	}
	d--;
}
int dfs2(int v, int prev) {
	int ret = 1;
	d++;
	for (int to = he[v]; to; to = ne[to]) {
		if (E[to] != prev && d <= k) ret += dfs2(E[to], v);
	}
	d--;
	return ret;
}

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


	N = getint();
	K = getint();
	k = K / 2;
	int tmp = 1;
	int jisuu[2001] = {};
	rep(i, N - 1) {
		int a = getint(), b = getint();
		E[tmp] = b;
		ne[tmp] = he[a];
		he[a] = tmp++;
		E[tmp] = a;
		ne[tmp] = he[b];
		he[b] = tmp++;
		jisuu[a]++;
		jisuu[b]++;
	}

	if (K == 1) {
		printf("%d\n", N - 2);
		return 0;
	}

	rep1(j, N) D[j] = -1;
	dfs(1);
	int saidai = 0;
	int doko, doko2;
	rep1(i, N) if (saidai < D[i]) {
		saidai = D[i];
		doko = i;
	}
	rep1(j, N) D[j] = -1;
	dfs(doko);
	saidai = 0;
	bool muri[2001] = {};
	rep1(i, N) {
		if (saidai < D[i]) {
			saidai = D[i];
			doko2 = i;
		}
		if (D[i] < k) {
			muri[i] = 1;
		}
	}
	if (saidai <= K) {
		printf("0\n");
		return 0;
	}
	rep1(j, N) D[j] = -1;
	dfs(doko2);
	rep1(i, N) {
		if (D[i] < k) muri[i] = 1;
		if (jisuu[i] == 1 && !muri[i]) {
			muri[i] = 1;
			if (k > 1) {
				int tmp = k - 1;
				int mae = i;
				int j = E[he[i]];
				while (tmp && !muri[j] && jisuu[j] == 2) {
					muri[j] = 1;
					int j1 = E[he[j]];
					if (j1 != mae) {
						mae = j;
						j = j1;
					}
					else {
						mae = j;
						j = E[ne[he[j]]];
					}
					tmp--;
				}
			}
		}
	}

	if (K % 2 == 0) {
		int kotae = N;
		rep1(i, N) {
			if (!muri[i]) {
				int kazu = dfs2(i, -1);
				kotae = min(kotae, N - kazu);
			}
		}
		printf("%d", kotae);
	}
	else {
		int kotae = N;
		rep1(z, N - 1) {
			int i = E[z * 2];
			int j = E[z * 2 - 1];
			if (!muri[i] && !muri[j]) {
				int kazu = dfs2(i, j) + dfs2(j, i);
				kotae = min(kotae, N - kazu);
			}
		}
		printf("%d\n", kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#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 <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    vector<int> val;

    void input() {

    }

    bool check(int s) {
        vector<int> tanka{5, 7, 5, 7, 7};
        vector<int> v(5);
        int pt = 0;

        for (int i = s;; ++i) {
            v[pt] += val[i];
            if (v[pt] == tanka[pt]) {
                pt++;
            } else if (v[pt] > tanka[pt]) {
                return false;
            }

            if (pt == 5) {
                return true;
            }
        }

    }

    bool solve() {
        input();
        int n;
        cin >> n;
        if (n == 0) return false;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            val.push_back(s.size());
        }

        for (int i = 0; i < n; ++i) {
            if (check(i)) {
                cout << i + 1 << endl;
                return true;
            }
        }

        return true;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while (Solve().solve()) {}

    return 0;
}



Measured memory_bytes: 3160
def test(m):
    t = [i for i in range(2**m)]
    for i in range(2**m):
        t.append(i)
    t.sort()
    st = set()
    bt = set()
    from itertools import permutations
    for v in permutations(t):
        taget = v[0]
        x = 0
        idx = 1
        while idx < len(v) and v[idx] != taget:
            x = x ^ v[idx]
            idx += 1
        if x in st or x in bt:
            continue
        f = True
        for i in range(1, len(v)):
            g = False
            y = 0
            idx = i+1
            while idx < len(v):
                if v[i] == v[idx]:
                    g = True
                    break
                y = y ^ v[idx]
                idx += 1
            if g:
                if y != x:
                    f = False
                    break
        if f:
            st.add(x)
            print(x, v)

def main():
    m, k = map(int, input().split())
#    test(m)
    x = 0
    for i in range(2**m):
        if i == k:
            continue
        x ^= i
    if k == 0:
        for i in range(2**m):
            print(i, i, end=" ")
    elif x == k:
        for i in range(2**m):
            if i == k:
                continue
            print(i, end=" ")
        print(k, end=" ")
        for i in reversed(range(2**m)):
            if i == k:
                continue
            print(i, end=" ")
        print(k)
    else:
        print(-1)

if __name__ == "__main__":
    main()

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

using namespace std;

int main(){
    int n,k;
    cin >> n>> k;
    int i,j,l;
    int c[100];
    int ans=0;
    for(i=0;i<=n;i++)
        c[i]=0;
    int tmp;
    for(i=0;i<k;i++){
        cin >>j;
        for(l=0;l<j;l++){
            cin >> tmp;
            c[tmp]++;
        }
    }
    for(i=1;i<=n;i++)
        if(c[i]==0)
            ans++;
    cout << ans;

}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

BufferedReader br =new BufferedReader (new InputStreamReader (System.in));

String line = br.readLine( );
String[] list = line.split(" ");
int x = Integer.parseInt(list[0]);
int a = Integer.parseInt(list[1]);
int b = Integer.parseInt(list[2]);


int n=b-a;
String z = "p";


if(n>0&&x>=n){
z ="safe";
}else if(n<=0){
z="delicious";
}else if(x+1<=n){
z="dangerous";
}
System. out. println(z);
}}

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

#define chmax(x, y) x = max(x, y)
using P = pair<int, int>;

P dp[300005];

// dp テーブルの更新
void update(P& a, P b){
    if(a.first < b.first){
        a.second = max(a.first, b.second);
        a.first = b.first;
    }
    else    chmax(a.second, b.first);
    return;
}

// 最大値になり得る値の取得
int get_value(P& a){
    return a.first + a.second;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(1 << N);
    for(int i = 0; i < (1 << N); ++i){
        cin >> A[i];
        dp[i] = P(A[i], 0);
    }
    
    // 高速ゼータ変換
    for(int i = 0; i < N; ++i){
        for(int K = 0; K < (1 << N); ++K){
            if(K & (1 << i)){
                update(dp[K], dp[K ^ (1 << i)]);
            }    
        }
    }
    
    int res = 0;
    for(int K = 1; K < (1 << N); ++K){
        chmax(res, get_value(dp[K]));
        cout << res << "\n";
    }
}

Measured memory_bytes: 6144
import java.util.Scanner;
import java.io.IOException;
class Main {
  	public static void main(String[] args)throws IOException{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] A = new int[n];
		int[] B = new int[n];
		int k = Integer.MIN_VALUE;
		
		for(int i = 0; i < n; i++){
			A[i] = scan.nextInt();
			k = Math.max(k, A[i]);
		}
		
		CountingSort(A, B, n, k);
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++){
			if(i != n - 1){
				sb.append(B[i]).append(" ");
			}else{
				sb.append(B[i]);
			}
		}
		System.out.println(sb);
	}
	
	public static void CountingSort(int[] A, int[] B, int n, int k){
		int[] C = new int[k + 1];
		int i;
		
		for(i = 0; i < n; i++){
			C[A[i]]++;
		}
		for(i = 1; i <= k; i++){
			C[i] += C[i - 1];
		}
		for(i = n - 1; i >= 0; i--){
			B[C[A[i]] - 1] = A[i];
			C[A[i]]--;
		}
	}
} 

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

int main(){
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  vector<int> emerge(N);

  /*出現位置を記録する*/
  char before = S[0];                             //最初の文字を取得
  for(int i = 1; i < N; i++){
    if(before == 'A' && S[i] == 'C')   
      emerge[i]++;
    before = S[i];
  }

  /*i文字目までに出現したACの数がemerge[i]*/
  for(int i = 1; i < N; i++)
    emerge[i] += emerge[i-1];

  for(int i = 0; i < Q; i++){
    int a, b;
    cin >> a >> b;
    cout << emerge[b-1] - emerge[a-1] << endl;
  }

  return 0;
    
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <string>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int n;
long long ans=1;
string s[2];
void dfs(int i)
{
    if(i==n)
    {
        return;
    }
    else
    {
        if(s[0][i]==s[1][i]&&i==0)
        {
            ans*=3;
            ans=ans%MOD;
            dfs(i+1);
        }
        else if(s[0][i]==s[1][i]&&i!=0&&s[0][i-1]==s[1][i-1])
        {
            ans*=2;
            ans=ans%MOD;
            dfs(i+1);
        }
        else if(s[0][i]==s[1][i]&&i!=0&&s[0][i-1]!=s[1][i-1])
        {
            ans*=1;
            ans=ans%MOD;
            dfs(i+1);
        }
        else if(s[0][i]!=s[1][i]&&i==0)
        {
            ans*=6;
            ans=ans%MOD;
            dfs(i+2);
        }
        else if(s[0][i]!=s[1][i]&&i!=0&&s[0][i-1]==s[1][i-1])
        {
            ans*=2;
            ans=ans%MOD;
            dfs(i+2);
        }
        else if(s[0][i]!=s[1][i]&&i!=0&&s[0][i-1]!=s[1][i-1])
        {
            ans*=3;
            ans=ans%MOD;
            dfs(i+2);
        }
    }
}
int main(void)
{
    cin>>n;
    cin>>s[0];
    cin>>s[1];
    dfs(0);
    cout << ans <<endl;
    return 0;
}


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

const double INF = 1e30;

int main()
{
  int N;
  while (cin >> N) {
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
      cin >> a[i];

    const int MAX = 200000;
    vector<vector<double> > dp(N, vector<double>(MAX, INF));
    for (int i = 1; i < MAX; ++i)
      dp[0][i] = abs(a[0] - i) / static_cast<double>(a[0]);

    for (int i = 1; i < N; ++i) {
      for (int j = 1; j < MAX; ++j) {
	for (int k = j; k < MAX; k += j) {
	  dp[i][k] = min(dp[i][k],
			   max(dp[i-1][j], abs(a[i] - k) / static_cast<double>(a[i])));
	}
      }
    }

    double ans = INF;
    for (int i = 0; i < MAX; ++i)
      ans = min(ans, dp[N-1][i]);
    printf("%.12f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 31000
/*
 *
 *    I am o0o0oo00.
 *
 */
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll          long long
#define p7          1000000007
#define p9          998244353
#define pb          push_back
#define ff          first
#define ss          second
#define vll         vector<ll>
#define pll         pair<ll,ll>
#define vpll        vector<pll>
#define mll         map<ll,ll>
#define test        ll T;cin>>T;while(T--)
#define ad(a,n)     vll a;a.resize(n);for(ll i=0;i<n;i++)cin>>a[i];
#define as(a,n)     for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define all(x)      x.begin(),x.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll powm(ll x, ll y, ll m = p7) {
    x = x % m; ll res = 1; while (y)
    {if (y & 1)res = res * x; res %= m; y = y >> 1; x = x * x; x %= m;} return res;
}
ll modi(ll a, ll m = p7) {return powm(a, m - 2, m);}
void yesno(bool f) {f ? cout << "YES" << endl : cout << "NO" << endl;}


void ss99()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

vll adj[100001];
ll dp[100001][2];

void dfs(ll node , ll par)
{
    for (auto x : adj[node])
    {
        if (x != par)
        {
            dfs(x, node);
            dp[node][0] = (dp[node][0] % p7 * (dp[x][0] + dp[x][1]) % p7) % p7;
            dp[node][1] = (dp[node][1] % p7 * dp[x][0] % p7) % p7;
        }
    }
}



int32_t main()
{
    ss99();
//    test
    {
        ll n; cin >> n;
        for (ll i = 1; i < n; i++)
        {
            ll x, y; cin >> x >> y;
            adj[x].pb(y);
            adj[y].pb(x);
            dp[i][0] = dp[i][1] = 1;
        }
        dp[0][0] = dp[0][1] = dp[n][0] = dp[n][1] = 1;
        dfs(1, 0);
        cout << (dp[1][0] + dp[1][1]) % p7 << endl;
    }
    return 0;
}

Measured memory_bytes: 14208
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	string s;
	int n;
	cin >> n;
	rep(i,n) {
		cin >> s;
		int len = s.length();
		bool fa = 0, fb = 0;
		if(len > 5 && len % 2 == 0) {
			fa = 1;
			string ns;
			ns += s.substr(2,len/2-2);
			ns += s.substr(len/2+1,len/2-2);
			rep(i,ns.length()) {
				if(ns[i] != '=') fa = 0;
			}
			if(s[0] != '>' || s[1] != '\'' || s[len/2] != '#' || s[len-1] != '~') {
				fa = 0;
			}
			fb = 1;
			rep2(i,1,(len-2)/2) {
				if(s[2*i] != 'Q' || s[2*i+1] != '=') fb = 0;
			}
			if(s[0] != '>' || s[1] != '^' || s[len-2] != '~' || s[len-1] != '~') {
				fb = 0;
			}
		}
		if(fa) cout << "A" << endl;
		else if(fb) cout << "B" << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    int N;
    cin >> N;
    map<string, ll> C;
    ll count = 0;

    for(int i=0; i<N; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        C[s]++;
    }
    for(auto c:C){
        if(c.second >= 2) {
            count += (c.second * (c.second - 1)) / 2;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1000000007;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> plates(N);
    for( ll i = 0; i < N; ++ i ){
        cin >> plates[i];
    }
    sort(plates.begin(), plates.end());
    ll count = 1;
    for ( ll i = 1; i < N; ++ i ){
        if ( plates[i-1] != plates[i] ){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define sfor(i,a,n) for(int i=a;i<n;i++)
#define efor(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define t int tc; cin>>tc; while(tc--)
#define ll long long
const ll mod=1000000007;

int solve(){
    return 0;
}
int32_t main(){
    static const int _ = []() {
        ios::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        return 0;
    }();
    int n;
    vector<int> vec;
    //idhar dekho idhar
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;++i){
        cin>>arr[i];
    }
    sort(all(arr));
    for(int i=1;i<n;++i){
        if(arr[i]==arr[i-1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

signed main() {
    int N; cin >> N;
    cout << (N-1)/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n, i, k, a[111111], g;
	cin >> n>>k;
	for (i = 0; i < n; i++)
		cin >> a[i];
	if (n == 1) {
		if (a[0] == k)
			cout << "POSSIBLE" << endl;
		else
			cout << "IMPOSSIBLE" <<  endl;
		return 0;
	}
	g = gcd(a[0], a[1]);
	for (i = 2; i < n; i++)
		g = gcd(g, a[i]);
	for (i = 0; i < n; i++) {
		if (a[i] >= k && (a[i] - k) % g == 0) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n , m;
    cin >> n >> m;
    int left = m / 2;
    int right = m - left;
    int tar = 0;
    for (int i = right ; i > 0 ; i--) {
        int dif = i * 2;
        if ((n-n/2)%2==0) {
            dif--;
        }
        cout << n - tar - dif <<' '<<n - tar << '\n';
        tar++;
    }
    tar = 0;
    for (int i = left ;i > 0 ; i--) {
        int dif = i * 2;
        if ((n - n / 2) & 1) {
            dif--;
        }
        cout << n / 2 - tar - dif <<' '<<n/2-tar << '\n';
        tar++;
    }
}

Measured memory_bytes: 3656
T = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
print(T[int(input())-1])

Measured memory_bytes: 3060
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
L = [A[0]]
R = [A[-1]]

for i in range(N-1):
    L.append(gcd(L[-1], A[i+1]))
    R.append(gcd(R[-1], A[N-i-2]))

ans = max(L[-2], R[-2])
for i in range(1, N-1):
    ans = max(ans, gcd(L[i-1], R[-i-2]))

print(ans)

Measured memory_bytes: 16152
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;
typedef pair<int,int> P;

int main()
{

    int N,L;
    cin >> N >> L;

    vector<int> t(N);
    REP(i,N) t[i]=L+i;

    int ans=0;
    REP(i,N) ans+=t[i];

    int tmp=1000;
    int tmpi=0;
    REP(i,N){
    	if(tmp>abs(t[i])){
    		tmp=abs(t[i]);
    		tmpi=i;
    	}
    }

    ans -= t[tmpi];

    cout << ans << endl;



}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  ll n;
  cin >> n;
  int i = 0;
  vector<char> ans;
  while(n){
    n--;
    ans.push_back(char('a'+n%26));
    n/=26;
    i++;
  }
  for(int i=ans.size()-1; i>=0; i--){
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 300005
#define INF 1000005
#define endl "\n"
int arr[MAX];
int h,w,k;
string c[] = {"AC", "WA", "TLE", "RE"};

int main(){
    int n;
    cin>>n;
    for(int i = 0; i<n; i++){
        cin>>arr[i];
    }   
    lli ctr = n-1;
    sort(arr,arr+n);
    lli sum = 0;
    for(int i = n-1; i>=0; i--){
        if(ctr > 0){
            if(ctr == 1 || i == n-1){
                sum += arr[i];
                ctr--;
            }
            else{
                sum += 2*arr[i];
                ctr -=2;
            }
        }
        else{
            break;
        }
    }
    cout<<sum;
}


Measured memory_bytes: 4396
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    vector<int>v(3);
    for(int i = 0;i < 3;i++)
        cin >> v[i];

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

    cout <<v[0]+v[1] << endl;



    return 0;
}

Measured memory_bytes: 256
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    vi abc(3);
    REP(i, 3)
    cin >> abc[i];

    int max = MAX(abc);
    int playCoutnt = 0;

    REP(i, 3) {
        playCoutnt += (max - abc[i]) / 2;
    }

    int oddCount;
    REP(i, 3) {
        oddCount += (abc[i] + max) % 2;
    }

    if (oddCount == 1) {
        playCoutnt += 2;
    } else if (oddCount == 2) {
        playCoutnt++;
    }

    cout << playCoutnt;
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

void search(int node, vector<vector<pair<int,long>>> &path,vector<long> &route, vector<int> &s, vector<int> v){
    static int isSearch=1;
    vector<int> next;
    for(auto n : v){
        for(auto p : path[n]){
            if(s[p.first]==0){
                s[p.first]=1;
                isSearch++;
                next.push_back(p.first);
                route[p.first]=route[n]+p.second;
            }
        }
    }
    if(isSearch!=node){
        search(node,path,route,s,next);
    }
}

int main(void){
    int n,q,k;
    cin>>n;
    vector<vector<pair<int,long>>> path(n+1);
    vector<long> route(n+1,0);
    for(int i=0;i<n-1;i++){
        int a,b;
        long c;
        cin>>a>>b>>c;
        path[a].push_back(pair<int,long>(b,c));
        path[b].push_back(pair<int,long>(a,c));
    }
    //for(auto a:path){for(auto p:a)cout<<p.first<<",";cout<<endl;}
    cin>>q>>k;
    vector<int> s(n+1,0);
    s[k]=1;
    search(n,path,route,s,vector<int>(1,k));
    for(int i=0;i<q;i++){
        int a,b;
        cin>>a>>b;
        cout<<route[a]+route[b]<<endl;
    }
}


Measured memory_bytes: 33408
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	const int M = 2e5;
	vector<int> d(M + 1);
	inc1(i, M) {
		for(int j = 0; j <= M; j += i) { d[j]++; }
	}
	
	int x;
	cin >> x;
	incII(i, x, M) {
		if(d[i] == 2) { cout << i << endl; return 0; }
	}
	
	UR;
}


Measured memory_bytes: 1024