akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

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

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

const int MAXN = 10e5 + 5;

int a[MAXN];

void yes() {
  puts("Yes");
  exit(0);
}

void no() {
  puts("No");
  exit(0);
}

int main(void) 
{
  int N;
  scanf("%d", &N);
  REP(i, N) scanf("%d", a + i);

  int cnt0 = 0;
  int cnt1 = 0;
  int cnt2 = 0;

  REP(i, N) {
    if (a[i] % 2) ++cnt0;
    else if (a[i] % 4) ++cnt1;
    else ++cnt2;
  }

  if (cnt1 == 0 && cnt2 >= cnt0 - 1)
    yes();

  if (cnt2 >= cnt0)
    yes();

  no();

  return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n,k;
	 cin>>n>>k;
	 vector<int> v(n);
	 for(int i=0;i<n;i++)
	 cin>>v[i];
	 
	 sort(v.begin(),v.end());
	 int ans=0;
	 for(int i=0;i<k;i++)
	 ans+=v[i];
	 cout<<ans;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int> v(2);
	vector<vector<int> > s;
	int a,b,i=-1;
	while(cin>>a>>b,a||i!=-1){
		v[0]=a+b,v[1]=++i,s.push_back(v);
		if(i==4){
			sort(s.begin(),s.end());
			cout<<char('A'+s[i][1])<<" "<<s[i][0]<<endl;
			s.clear(); i=-1;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N;
    cin >> N;
    if(N % 2 == 0){
        ll count = 0;
        for(int i = 1; i < N + 1; i++){
            for(int j = i + 1; j < N + 1; j++){
                if(i + j == N + 1){
                    continue;
                }
                count++;
            }
        }
        cout << count << endl;
        for(int i = 1; i < N + 1; i++){
            for(int j = i + 1; j < N + 1; j++){
                if(i + j == N + 1){
                    continue;
                }
                cout << i << " " << j << endl;
            }
        }
    }else{
        ll count = 0;
        for(int i = 1; i < N + 1; i++){
            for(int j = i + 1; j < N + 1; j++){
                if(i + j == N){
                    continue;
                }
                count++;
            }
        }
        cout << count << endl;
        for(int i = 1; i < N + 1; i++){
            for(int j = i + 1; j < N + 1; j++){
                if(i + j == N){
                    continue;
                }
                cout << i << " " << j << endl;
            }
        }

    }

}


Measured memory_bytes: 256
n, m = map(int, input().split())
tree = [-i for i in range(n+1)]

def search_root(num, tree=tree):
    if tree[num] < 0:
        return num
    else:
        tree[num] = search_root(tree[num])
        return tree[num]

for _i in range(m):
    x, y, z = map(int, input().split())
    x, y = sorted([search_root(x), search_root(y)])
    if x==y:
        continue
    else:
        tree[x] = y
print(sum(1 for i in tree if i<0))

Measured memory_bytes: 7088
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
static const ll MAX_L = (ll)1 << 62;

ll m[31][200001] = {};
ll sum[200001] = {};
int main() {
	ll n, C; cin >> n >> C;

	rep(i, 0, n) {
		ll s, t, c; cin >> s >> t >> c;

		if (m[c][2 * s] < 0) {
			m[c][2 * s]++;
		}
		else {
			m[c][2 * s - 1]++;
		}

		if (m[c][2 * t - 1] > 0) {
			m[c][2 * t - 1]--;
		}
		else {
			m[c][2 * t]--;
		}
	}
	repe(i, 1, C) {
		rep(j, 1, 200001) {
			m[i][j] += m[i][j - 1];
		}
	}

	ll maxV = 0;
	rep(i, 1, 200001) {
		repe(j, 1, C) {
			sum[i] += m[j][i];
		}
		maxV = max(maxV, sum[i]);
	}

	cout << maxV << endl;
	return 0;
}

Measured memory_bytes: 49792
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    t = gete()

    print(t.replace("?", "D"))


if __name__ == "__main__":
    main()

Measured memory_bytes: 65900
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    int n; cin>>n;
    vi a(n-1);
    rep(i,0,n-1) cin>>a[i];
    int ans = a[0]+a[n-2];
    if(n>2)
    {
        rep(i,0,n-2)
        {
            ans+=min(a[i],a[i+1]);
        }
    }
    cout<<ans;    
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int len) {
	
		unordered_map<string, int> mp;
		for (int j = 0; j <= N - len; j++) {
			string tmp = s.substr(j, len);
			auto itr = mp.find(tmp);
			if (itr == mp.end()) mp.emplace(tmp, j);
			else if (j - itr->second >= len) return true;
		}
		
		return false;
	};

	
	auto biSearch = [&](auto f) {
      int ok = -1;
      int ng = N;

      while (abs(ok - ng) > 1) {
          int mid = (ok + ng) / 2;
          if (f(mid)) ok = mid;
          else ng = mid;
      }

      return ok;
	};
	
	cout << biSearch(check) << endl;
	
	return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

int A, B, N;
int main()
{
    cin >> N >> A >> B;
    printf("%d\n", (A*N>B) ? B : A*N);
    return 0;
}


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

const int limit = 50;
int N, M;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];


void dfs(int v)
{

        visited[v] = true;

        for (int v2 = 0; v2 < N; ++v2) {

                if (graph[v][v2] == false) {
                        continue;
                }
                if (visited[v2] == true) {
                        continue;
                }
                dfs(v2);
        }
}



int main()
{

        cin >> N >> M;

        for (int i=0; i < M; ++i) {
                cin >> a[i] >> b[i];
                a[i]--;
                b[i]--;
                graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }

        int ans = 0;

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

                // 辺をこわす
                graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

                // visitedをクリア
                for (int j = 0; j < N; ++j) {
                        visited[j] = false;
                }

                // 端から端までいけるか。
                dfs(0);

                bool bridge = false;
                for (int j = 0; j < N; ++j) {
                        if (visited[j] == false) {
                                bridge = true;
                        }
                }
                if (bridge) {
                        ans++;
                }

                // こわした端を脅す
                graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;


        }

        cout << ans << endl;






}


Measured memory_bytes: 256
n=int(input())
dic={}#辞書
for i in range(n):
    tmp="".join(sorted(input()))
    if tmp in dic.keys():
        dic[tmp]+=1
    else:
        dic[tmp]=1

ans=0
for i in dic.values():
    ans+=i*(i-1)/2
print(int(ans))

Measured memory_bytes: 17852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    string S, T;
    cin >> S >> T;
    T.pop_back();
    cout << (S == T ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
int main() {
	int n, b[111], i, j, c[111], ans[111],k,count,t=0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &b[i]);
	for (i = 0; i < n; i++) {
		if (b[i] > i + 1) {
			printf("-1\n");
			return 0;
		}
		c[i] = 0;
	}
	for (i = 0; i < n; i++) {
		for (j = n - 1; j >= 0; j--) {
          count = 0;
			for (k = j - 1; k >= 0; k--) {
				if (c[k] == 1)
					count++;
			}
			if (count + 1 == b[j] && c[j] == 0) {
				ans[t] = b[j];
				c[j]++;
              t++;
				break;
			}
		}
	}
	for (i = 0; i < n; i++)
		printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 128
x, y = gets().chomp.split("\s")

list = {'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15}

if x == y
  puts '='
elsif list[x] > list[y]
  puts '>'
else
  puts '<'
end

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

const int V[6] = {1,5,10,50,100,500};
int a;

void solve()
{
	int ans = 0;
	for(int i=5;i>=0;i--){
		int t = a/V[i];
		a -= V[i]*t;
		ans += t;
	}
	cout << ans << endl;
}

int main()
{
	cin >> a;
	while(a){
		a = 1000-a;
		solve();
		cin >> a;
	}
	return 0;
}

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

int main() {
  int n;double sum = 0;
  cin >> n;
  vector<double>d(n);
  for(int i = 0;i < n;i++){
    cin >> d.at(i);
    sum += 1/d.at(i);
  }
  cout << fixed << setprecision(6);
  cout << 1/sum << endl;
}


Measured memory_bytes: 256
//#include"cpp_kyopro.h"
#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 <stdlib.h>
#include <math.h>
using namespace std;
int main(){
	int x, a; cin >> x >> a;
	if (x < a)printf("0");
	else printf("10");
	return 0;
	}

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

vector<vector<int>> to;
vector<int> ans;

void dfs(int v, int p = -1) {
  rep(i, to[v].size()) {
    int u = to[v][i];
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}
int main() {
  int n, q;
  cin >> n >> q;

  to.resize(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 23424
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    const evens = A.filter(n=>n % 2 === 0);
    
    console.log(evens.filter(n=>n % 3 === 0 || n % 5 === 0).length == evens.length ? "APPROVED" : "DENIED");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int n;
	while (true) {
		cin >> n;
		if (!n)break;

		int s, M, m, sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> s;
			if (!i) {
				M = m = s;
			}
			else if (i == 1) {
				M = max(s, M);
				m = min(s, m);
			}
			else if (s > M) {
				sum += M;
				M = s;
			}
			else if (s < m) {
				sum += m;
				m = s;
			}
			else {
				sum += s;
			}
		}
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
int s,k; 
int count=0;
cin>>k>>s; 
for(int x=0;x<=k;x++) { 
for(int y=0;y<=k;y++) {
int z=s-(x+y);
if(z>=0&&z<=k)
count++;
}
}
cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
#define ull unsigned long long
const int MAXN = 1e2 + 5;
const int MOD = 1e9 + 7;

using namespace std;
vector<int> g[MAXN];
int main() {

int n,m;
cin >> n >> m;

for(int i = 0 ; i < m ; i++)
 {
    int u,v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
 }

 for(int i = 1 ; i <= n ; i++)
 	 {
 	 	if(g[i].empty()) cout << "0\n";
 	 	else cout << g[i].size() << '\n';
 	 }



} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
//#define rep(i, n) for(unsigned int i = 0; i < (unsigned int)(n); i++)
using namespace std;

int main(){
  long N;
  cin >> N;
  long fN = N/3;
  long bN = N/5;
  long fbN = N/15;

  long ans = (1+N)*N/2 - 3*(1+fN)*fN/2 - 5*(1+bN)*bN/2 + 15*(1+fbN)*fbN/2;
  cout << setw(12) << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(){
  int a,b,c,x,ai,bi,ci,total;
  total=0;
  scanf("%d\n%d\n%d\n%d",&a,&b,&c,&x);
  for(ai=0;ai<=a;ai++){
    for(bi=0;bi<=b;bi++){
      for(ci=0;ci<=c;ci++){
        if(500*ai+100*bi+50*ci==x){
          total+=1;
        }
      }
    }
  }
  printf("%d",total);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a%3 == 0){cout<<"Possible"<<endl;return 0;}
    if(b%3 == 0){cout<<"Possible"<<endl;return 0;}
    if((a+b)%3==0){cout<<"Possible"<<endl;return 0;}
    cout<<"Impossible"<<endl;
    return 0;
}

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

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

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

int main(){

    string str;
    getline(cin, str);
    str += ' ';

    stack<int> st;

    string tmp = "";
    for(int i = 0; str[i] != '\0';i++){
        // cout << "i:" << i << endl;
        if(str[i] == ' '){
            // cout << "tmp:" << tmp << endl;
            if(tmp == "+"){
                int a = st.top(); st.pop();
                int b = st.top(); st.pop();
                st.push(b+a);
            }else if(tmp == "-"){
                int a = st.top(); st.pop();
                int b = st.top(); st.pop();
                st.push(b-a);
            }else if(tmp == "*"){
                int a = st.top(); st.pop();
                int b = st.top(); st.pop();
                st.push(b*a);
            }else{
                st.push(atoi(tmp.c_str()));
            }

            tmp = "";
        }else{
            tmp += str[i];
        }
    }

    cout << st.top() << endl;

    return 0;
}




Measured memory_bytes: 3208
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-15 14:04:58
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-15 14:18:47
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;

ll n,m,w,h;
int main()
{
    read(n),read(m),read(w),read(h);
    for(int i=1;i<=n-h;i++)
    {
        for(int j=1;j<=m-w;j++)
        cout<<"1";
        for(int j=m-w+1;j<=m;j++)
        cout<<"0";
        cout<<endl;
    }
    for(int i=n-h+1;i<=n;i++)
    {
        for(int j=1;j<=m-w;j++)
        cout<<"0";
        for(int j=m-w+1;j<=m;j++)
        cout<<"1";
        cout<<endl;
    }
}

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

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int    a;
    int    b;
    int    c;
    int    d;

    try
    {

      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");


      a = Integer.parseInt(in_str_split[0]);
      b = Integer.parseInt(in_str_split[1]);
      c = Integer.parseInt(in_str_split[2]);
      d = Integer.parseInt(in_str_split[3]);

      if((a+b) < (c+d))
      {
        UtilLog.ans_ln("Right");
      }
      else if((a+b) > (c+d))
      {
        UtilLog.ans_ln("Left");
      }
      else
      {
        UtilLog.ans_ln("Balanced");
      }
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;

bool myCompare(pll const &p1, pll const &p2)
{
        return p1.snd>p2.snd;
}

pll check(string &s)
{
        pll p;
        stack<char>st;
        for(int i=0;i<s.length();i++)
        {
                if(s[i]=='(')
                {
                        st.push(s[i]);
                }
                else
                {
                        if(st.empty())
                        {
                                p.ff++;
                        }
                        else
                        {
                                st.pop();
                        }
                }
        }
        while(!st.empty())
        {
                p.snd++;
                st.pop();
        }
        return p;
}

void solve()
{
   ll n;
   cin>>n;
   string s;
   
   vector<pll> p1,p2;
   for(int i=0;i<n;i++)
   {
        cin>>s;
        pll p = check(s);
        if(p.ff==0 && p.snd==0)
        continue;
        if(p.ff>p.snd)
        {
                p2.pb(p);
                continue;
        }
        p1.pb(p);
   }
   
   sort(p1.begin(),p1.end());
   sort(p2.begin(),p2.end(),myCompare);
   
   ll open = 0;
   for(int i=0;i<p1.size();i++)
   {
        //cout<<p1[i].ff<<" "<<p1[i].snd<<" "<<open<<endl;   
        if(open<p1[i].ff)
        {
                cout<<"No\n";
                return;
        }
        open-=p1[i].ff;
        open+=p1[i].snd;
   }
   
   for(int i=0;i<p2.size();i++)
   {
        //cout<<p2[i].ff<<" "<<p2[i].snd<<" "<<open<<endl;
        if(open<p2[i].ff)
        {
                cout<<"No\n";
                return;
        }
        open-=p2[i].ff;
        open+=p2[i].snd;
   }
   
   //cout<<open<<" ";
   if(open==0)cout<<"Yes\n";
   else
   cout<<"No\n";
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 19056
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
int main()
{
    string str;
    int n, str_len;
    n = 0;
    cin >> str;
    str_len = str.length();
    for (int i=0; i<str_len-1; ++i){
        if(str[i] != str[i+1]){
            n++;
        }
    }
    cout << n << endl;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] test = new int[n];
		
		for(int i = 0; i < n; i++){
			test[i] = sc.nextInt();
		}
		
		for(int i = k; i < n; i++){
			if(test[i-k] < test[i]){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 60276
/**
*    created: 01.07.2020 21:19:30
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int MOD = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int INF = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    cout << n / 3 << endl;
    return 0;
}

Measured memory_bytes: 3636
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
a = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
while n > 0:
    t = (n-1) % 26
    n = (n-1) // 26
    ans = a[t] + ans
print(ans)

Measured memory_bytes: 9200
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
using namespace std;
class dice {
public:
	int a[6];
	int b;
	void moveN() {
		b = a[0];
		a[0] = a[1];
		a[1] = a[5];
		a[5] = a[4];
		a[4] = b;
	}
	void moveS() {
		b = a[0];
		a[0] = a[4];
		a[4] = a[5];
		a[5] = a[1];
		a[1] = b;
	}
	void moveE() {
		b = a[0];
		a[0] = a[3];
		a[3] = a[5];
		a[5] = a[2];
		a[2] = b;
	}
	void moveW() {
		b = a[0];
		a[0] = a[2];
		a[2] = a[5];
		a[5] = a[3];
		a[3] = b;
	}
	void moveR() {
		b = a[1];
		a[1] = a[2];
		a[2] = a[4];
		a[4] = a[3];
		a[3] = b;
	}
	void moveL() {
		b = a[1];
		a[1] = a[3];
		a[3] = a[4];
		a[4] = a[2];
		a[2] = b;
	}
};
int main() {
	int a = 0;
	int b = 0;
	dice dice[1000];
	int n = 0;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 6; j++) {
			cin >> dice[i].a[j];
		}
	}

	while (1) {

		if (a == b) {
			b++;
		}

		if (a == n - 1)break;

		if (dice[a].a[2] == dice[b].a[2] && dice[a].a[3] == dice[b].a[3] && dice[a].a[4] == dice[b].a[4] && dice[a].a[0] == dice[b].a[0] && dice[a].a[1] == dice[b].a[1] && dice[a].a[5] == dice[b].a[5]) {
			cout << "No" << endl;
			return 0;
		}

		for (int i = 0; i < 4; i++) {
			dice[b].moveR();
			for (int j = 0; j < 4; j++) {
				dice[b].moveN();
				if (dice[a].a[2] == dice[b].a[2] && dice[a].a[3] == dice[b].a[3] && dice[a].a[4] == dice[b].a[4] && dice[a].a[0] == dice[b].a[0] && dice[a].a[1] == dice[b].a[1] && dice[a].a[5] == dice[b].a[5]) {
					cout << "No" << endl;
					return 0;
				}
			}
		}

		for (int i = 0; i < 4; i++) {
			dice[b].moveE();
			for (int j = 0; j < 4; j++) {
				dice[b].moveN();
				if (dice[a].a[2] == dice[b].a[2] && dice[a].a[3] == dice[b].a[3] && dice[a].a[4] == dice[b].a[4] && dice[a].a[0] == dice[b].a[0] && dice[a].a[1] == dice[b].a[1] && dice[a].a[5] == dice[b].a[5]) {
					cout << "No" << endl;
					return 0;
				}
			}
		}

		if (b < n) {
			b++;
		}
		else {
			b = 0;
			a++;
		}
	}
	

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3096
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll height(ll h){
	return (3*h*(h-1))/2 + 2*h;
}
 
void solve()
{
  ll a ,  b , c;
  ll  k ;
  cin>>a>>b>>c>>k ;
  ll ans = 0 ;
  if(k>a){
  	ans += a;
  	k -= a;
  	if(k>b){
  		k-=b;
  		ans -= k;
  		cout<<ans;
  	}
  	else{
  		cout<<ans;
  	}

  }
  else{
  	cout<<k;
  }

}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
int dp[100005];
bool visited[100005];
vector<int>adj[100005];
void find(int src){
    visited[src]=true;
    dp[src]=0;
    for(auto edge:adj[src]){
        if(!visited[edge])
        find(edge);
        dp[src]=max(dp[src],dp[edge]+1);
    }
}
void solve(){
    memset(dp,0,sizeof(dp));
    memset(visited,false,sizeof(visited));
	int n,m;cin>>n>>m;int x,y;
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        adj[x].push_back(y);
    }
    for(int i=1;i<=n;i++){
        if(!visited[i]) find(i);
    }
    int maxx=-1;
    for(int i=1;i<=n;i++) maxx=max(maxx,dp[i]);
    cout<<maxx;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

int main() {
    int N, M;
    string S;
    cin >> N >> M >> S;
    vector<int>safe;
    for (int i = 0; i <= N; ++i) {
        if(S[i] == '0') safe.push_back(i);
    }
    stack<int>st;
    int cur = N;
    while (cur > M) {
        auto iter = lower_bound(safe.begin(), safe.end(), cur-M);
        int nxt = *iter;
        if(nxt == cur){
            cout << -1 << "\n";
            return 0;
        }
        st.push(cur - nxt);
        cur = nxt;
    }
    st.push(cur);
    while (! st.empty()){
        int ans = st.top(); st.pop();
        cout << ans << " ";
    }
    return 0;
}

Measured memory_bytes: 1400
from collections import defaultdict,deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


k = inp()
a, b = inpl()
if a%k==0 or b // k > a // k:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 68996
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

//<editor-fold defaultstate="collapsed" desc="Headers & Macros">
#include <bits/stdc++.h>

#pragma GCC optimize("O3")

using namespace std;
//</editor-fold>

class AFiveVariables {
public:
    int testNumber = 0;
    void solve(std::istream& in, std::ostream& out) {
        for (int x = 1; x <= 5; ++x) {
            int tmp;

            in >> tmp;

            if (tmp == 0) {
                out << x << '\n';
                return;
            }
        }
    }
};


int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    AFiveVariables solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    int s = 0;
    rep(i, n) {
        cin >> A[i];
        s ^= A[i];
    }
    rep(i, n) {
        int ans = s ^ A[i];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3964
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next()) - 1;
            int b = Integer.parseInt(sc.next()) - 1;
            if (!map.containsKey(a)) {
                map.put(a, new ArrayList<>());
            }
            map.get(a).add(b);
            if (!map.containsKey(b)) {
                map.put(b, new ArrayList<>());
            }
            map.get(b).add(a);
        }
        int[] ans = new int[n];
        Arrays.fill(ans, -1);
        Deque<Integer> dq = new ArrayDeque<>();
        dq.add(0);
        while (!dq.isEmpty()) {
            int temp = dq.poll();
            List<Integer> list = map.get(temp);
            for (int num : list) {
                if (ans[num] == -1) {
                    ans[num] = temp;
                    dq.add(num);
                }
            }
        }
        System.out.println("Yes");
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < n; i++) {
            sb.append(ans[i] + 1);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 86924
#include<stdio.h>
#include<string.h>
int main()
{
	char S[4];
	scanf("%s",S);
	if(S[0]==S[1] || S[2]==S[3] || S[1]==S[2])
	{
		printf("Bad\n");
	}
	else
		printf("Good\n");
	return 0;
}

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

int pos;
string str;

int exp();

int factor() {
  if(str[pos] >= '0' && str[pos] <= '9') {
    string tmp = "";
    while(str[pos] >= '0' && str[pos] <= '9') {
      tmp += str[pos++];
    }
    return atoi(tmp.c_str());
  }

  if(str[pos] == '(') {
    pos++;
    int tmp = exp();
    pos++;
    return tmp;
  }
}

int term() {
  int x = factor();
  while(str[pos] == '*' || str[pos] == '/') {
    if(str[pos] == '*') {
      pos++;
      x *= factor();
    } else if(str[pos] == '/') {
      pos++;
      x /= factor();
    }
  }
  return x;
}

int exp() {
  int x = term();
  while(str[pos] == '+' || str[pos] == '-') {
    if(str[pos] == '+') {
      pos++;
      x += term();
    } else if(str[pos] == '-') {
      pos++;
      x -= term();
    }
  }
  return x;
}

main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    pos = 0;
    cin >> str;
    str = str.substr(0, str.length()-1);
    cout << exp() << endl;
  }
}

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

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

  vector<int> a(n);
  vector<int> cnt(10001, 0);
  for ( int i = 0; i < n; i++ ) cin >> a[i], cnt[a[i]]++;

  bool flag = false;
  for ( int i = 0; i < 10001; i++ ) {
    for ( int j = 0; j < cnt[i]; j++ ) {
      if ( flag ) cout << " ";
      else flag = true;
      cout << i;
    }
  }
  cout << endl;
  
  return 0;
}



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

int main() {
    int ans[26], cnt[26], n, a = 0;
    string buf;
    char w[26];

    for (char x = 'a'; x <= 'z'; x++, a++)
    {
        w[a] = x;
    }

    cin >> n;
    for (int i = 0; i < 26; i++)
    {
        ans[i] = 0;
        cnt[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> buf;
        for (int j = 0; j < buf.size(); j++)
        {
            for (int k = 0; k < 26; k++)
            {
                if (w[k] == buf[j]) {
                    cnt[k]++;
                    break;
                }
            }
        }
        for (int j = 0; j < 26; j++)
        {
            if (i != 0) {
                ans[j] = min(ans[j], cnt[j]);
            } else {
                ans[j] = cnt[j];
            }
            cnt[j] = 0;
        }
    }
    for (int i = 0; i < 26; i++)
    {
        if (ans[i] != 0) {
            for (int j = ans[i]; j > 0; j--)
                cout << w[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<pll> arms(N);
    for(int i = 0; i < N;i++){
        ll X,L; cin >> X >> L;
        arms[i] = pll(X+L,X-L);
    }
    sort(arms.begin(),arms.end());
    ll left = -LINF;
    for(int i = 0; i < N;i++){
        if(arms[i].second < left) continue;
        res++;
        left = arms[i].first;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 1; i <= n; i++)
typedef long long ll;
int main() {
    int n; cin >> n;
    int count = 0;
    rep(i, n){
        if(0 < i && i < 10) count++;
        if(99 < i && i < 1000) count++;
        if(9999 < i && i < 100000) count++;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n+1);
    REP(i, n+1) cin >> a[n-i];

    auto test = [&](ll p) {
        if(a[0]%p) return false;
        vector<ll> sum(p);
        FOR(i, 1, n+1) sum[i%(p-1)] += a[i];
        bool flag = true;
        REP(i, p) if(sum[i]%p != 0) flag = false;
        return flag;
    };

    vector<ll> ans;

    // P <= N
    vector<bool> prime(n+2, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (prime[i]) {
            if(test(i)) ans.push_back(i);
            for (int j = 2 * i; j <= n; j += i) {
                prime[j] = false;
            }
        }
    }

    // P > N
    ll t = abs(a[n]);
    vector<ll> div;
    for(ll i=2; i*i<=t; ++i) {
        if(t%i==0) div.push_back(i);
        while(t%i==0) t/=i;
    }
    if(t>1) div.push_back(t);
    for(auto i: div) {
        if(i <= n) continue;
        bool flag = true;
        REP(j, n+1) if(a[j]%i != 0) flag = false;
        if(flag) ans.push_back(i);
    }

    for(auto i: ans) cout << i << endl;

    return 0;
}


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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; 
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    long long n,p;
    cin >> n >> p;
    const auto &decom = prime_factorize(p);
    long long ans = 1;
    for(auto p : decom){
        for(int j = 0; j < p.second/n; j++){
            ans *= p.first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

ll r, c, n;
ll a, b, e, d;
vector<pair<ll, ll>> p;

bool check(ll x, ll y) {
  return x != 0 && x != r && y != 0 && y != c;
}

ll calc(ll x, ll y) {
  if (x == 0) return y;
  if (y == c) return inf + x;
  if (x == r) return inf * 2 + r - y;
  if (y == 0) return inf * 3 + c - x;
  return -1;
}

void upd() {
  cin >> a >> b >> e >> d;
  if (check(a, b) || check(e, d)) return;
  p.push_back({calc(a, b), n});
  p.push_back({calc(e, d), n});
}

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

  cin >> r >> c >> n;
  while (n--) upd();
  sort(p.begin(), p.end());
  stack<ll> s;
  for (auto q: p) {
    ll x = q.second;
    if (s.size() && s.top() == x) s.pop();
    else s.push(x);
  }
  cout << (s.size() ? "NO" : "YES") << '\n';


  




  
  return 0;
}

Measured memory_bytes: 7396
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0

int w,h;
char field[1024][1024];
int sx,sy,gx,gy;
int dp[7][1024];

class state{
  public:
	int x,y;
	state(int _x, int _y){
		x = _x;  y = _y;
	}
};
vector<state> joutai[7];

int main(){
	while(scanf("%d%d",&w,&h),w|h){
		rep(i,7)rep(j,1024)dp[i][j]=INT_MAX;
		rep(i,7)joutai[i].clear();
		
		rep(i,h){
			scanf("%s",field[i]);
			rep(j,w){
				switch(field[i][j]){
				  case 'S' :
					sx=j; sy=i;
					break;
				  case 'G' :
					gx=j; gy=i;
					break;
				  case '1': case '2': case '3': case '4': case '5':
					joutai[field[i][j]-'0'].push_back(state(j,i));
					break;
				}
			}
		}
		joutai[0].push_back(state(sx,sy));
		joutai[6].push_back(state(gx,gy));

#if DEB
		rep(i,7){
			rep(j,joutai[i].size()){
				printf("(%d,%d), ",joutai[i][j].x, joutai[i][j].y);
			}
			puts("");
		}
#endif


		int ans = INT_MAX;
		int idx = INT_MAX;
		dp[0][0] = 0;
		rep(init,5){ //zurasi  5
			int cur,next;
			rep(i,6)rep(j,1024)dp[i][j]=INT_MAX;
			cur = 0;
			dp[0][0] = 0;
			
#if DEB
			printf("-------------init:%d------------\n",init);
#endif			
			rep(i,4){
				next = i+init+1;
				if( next>5 )next -= 5;
#if DEB
				printf("cur:%d  --> next:%d\n",cur,next);
#endif				
				rep(j,joutai[cur].size())if( dp[cur][j]!=INT_MAX ){
					rep(k,joutai[next].size()){
						int dx,dy;
						dx = abs(joutai[cur][j].x - joutai[next][k].x);
						dy = abs(joutai[cur][j].y - joutai[next][k].y);
#if DEB
						printf("(%d,%d) --> (%d,%d)  cost:%d\n",joutai[cur][j].x,
							   joutai[cur][j].y,joutai[next][k].x,joutai[next][k].y,dx+dy);
#endif						
						dp[next][k] = min(dp[next][k], dp[cur][j]+dx+dy);

#if DEB
						printf("dp[%d][%d] : %d\n",next,k,dp[next][k]);
#endif						
					}
				}
				cur = next;
			}

			// cur is last . 6 is goal
#if DEB
			printf("____init:%d  cur:%d   cur.size:%d\n",init,cur,joutai[cur].size());
#endif			
			rep(j,joutai[cur].size())if( dp[cur][j]!=INT_MAX ){
				int dx = abs(joutai[cur][j].x - gx);
				int dy = abs(joutai[cur][j].y - gy);
				if( ans>=dp[cur][j]+dx+dy ){
					int tmp;
					if( init==0 ){
						tmp = 5;
					}else{
						tmp = init;
					}
					if( ans==dp[cur][j]+dx+dy ){
						idx = min(idx, tmp);
					}else{
						idx = tmp;
						ans = dp[cur][j] + dx+dy;
					}
				}
			}
		}

		if( ans==INT_MAX ){
			puts("NA");
		}else{
			printf("%d %d\n",idx,ans);
		}
	}
	return 0;
}

Measured memory_bytes: 2004