akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................
 static List<Character> l;
 static void rec(long n,String s){
 	if(n<=26l){
 		 l.add(s.charAt(((int)n-1+26)%26));
 		return;
 	}
 	long k=n/26l;int r=(int)(n%26l);
 	
 	l.add(s.charAt((r-1+26)%26));
 	rec(k,s);
 }
   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	int n=int_v(read());
	        		  	int[] arr=int_arr();
	        		  	long sum=0;
	        		  	Map<Integer,Integer> map=new HashMap<>();
	        		  	for(int i=0;i<n;i++){
	        		  		sum+=arr[i];
	        		  		map.put(arr[i],map.getOrDefault(arr[i],0)+1);
	        		  	}
	        		  	int q=int_v(read());
	        		  	while(q--!=0){
	        		  		int[] b=int_arr();
	        		  		long s1=sum-(long)map.getOrDefault(b[0],0)*b[0]+(long)map.getOrDefault(b[0],0)*b[1];
	        		  		sum=s1;
	        		  		int f=map.getOrDefault(b[0],0);
	        		  		map.remove(b[0]);
	        		  		map.put(b[1],map.getOrDefault(b[1],0)+f);
	        		  		out.write(s1+"\n");
	        		  	}

	        		  	//out.write(res+"");
                      	out.flush();
	        		 
	}
}
	       

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> q[i];
    }

    //並び替えたい数列をaという配列に入れる
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        a[i] = i+1;
    }

    int x, y, i = 0;
    do {
        if (a == p) x = i;
        if (a == q) y = i;
        i++;
    } while (next_permutation(a.begin(), a.end()));
    
    int ans = abs(x - y);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  bool can=false;
  
  int64_t A,B,C;

  cin >> A >> B >> C ;

  int64_t ans=0;

  for(int i=A;i<=B*A;i++){
    int64_t x=(int64_t)A*i;
    if(x%B==C){can=true; break;}
  }

  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int a,b,c;
    while (~scanf("%d %d %d", &a,&b,&c)) {
        printf("%d\n", c/a*b);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n)
    {
        cin >> l.at(i);
    }

    int sum = 0;
    int ans = 1;

    for (int i = 0; i < n; i++)
    {
        sum += l.at(i);
        if (sum > x)
        {
            break;
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

#define PI 3.14159265359

double evaluate(double a, double b, double theta)
{
	double rad = theta / 180.0 * PI;
	if (rad < atan2(b, a)) {
		double c = a * tan(rad);
		return a * (((b - c) * a) + (a * c) / 2);
	}
	else {
		return a * b / tan(rad) * b / 2;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	double a, b, x; cin >> a >> b >> x;

	double bot = 0.0;
	double up = 90.0;

	while (true) {
		if (up - bot < 0.00000000001) {
			break;
		}

		double val = evaluate(a, b, (bot + up) / 2);
		if (x < val) {
			bot = (bot + up) / 2;
		}
		else {
			up = (bot + up) / 2;
		}
	}


	cout << setprecision(20) << (bot + up) / 2.0 << endl;

	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (n); i++)
int main(){
string s, t;
cin >> s >> t;
int sizes=s.size(), sizet=t.size();
vector<string> vecs(sizes);
vector<string> vect(sizet);
rep(i, sizes) vecs[i]=s[i];
rep(i, sizet) vect[i]=t[i];
sort(vecs.begin(), vecs.end());
sort(vect.begin(), vect.end());
reverse(vect.begin(), vect.end());
string ss=vecs[0], tt=vect[0];
for (int i=1; i<sizes; ++i) ss += vecs[i];
for (int i=1; i<sizet; ++i) tt += vect[i];
if (ss<tt) cout << "Yes" << endl;
else cout << "No" << endl;


}

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

int main(){
  char A,B;
  cin>>A>>B;
  if(A=='H' && B=='H') {
     cout<<"H"<<endl;
  }
  if(A=='D' && B=='D') {
     cout<<"H"<<endl;
  }
  if(A=='H' && B=='D') {
     cout<<"D"<<endl;
  }
  if(A=='D' && B=='H') {
     cout<<"D"<<endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

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

  double sum = 0;
  rep(i, n){
    int x = i+1;
    double p = 1;
    while(x < k){
      x *= 2;
      p /= 2;
    }
    sum += p;
  }

  cout << fixed << setprecision(12) << sum/n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int main()
{
    char c;
    scanf("%c",&c);

    if (c=='A')printf("T");
    else if (c=='T')printf("A");
    else if (c=='C')printf("G");
    else if (c=='G')printf("C");

    return 0;
}


Measured memory_bytes: 128
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n, k;
    string s;
    cin >> n >> k >> s;

    s[k - 1] = tolower(s[k - 1]);
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

struct {
	int parent;
	int left;
	int right;
} typedef node;


void depth(int a, int b);
int height(int a);
void print(int n);

using namespace std;
const int NIL = -1;

node tree[100000];
int D[100000];
int H[100000];

int main(int argc, char** argv)
{
	int n, v, l, r, root;
	cin >> n;
	for (int i = 0; i < n; i++) {
		tree[i].left = tree[i].parent = tree[i].right = NIL;
	}
	for (int i = 0; i < n; i++) {
		cin >> v >> l >> r;
		tree[v].left = l;
		tree[v].right = r;
		tree[l].parent = v;
		tree[r].parent = v;
	}
    root = 0;
	while (tree[root].parent != NIL) {
		root = tree[root].parent;
	}
	depth(root, 0);
	height(root);

    print(n);

	return 0;
}

void depth(int a, int b)
{
	D[a] = b;
	if (tree[a].right != NIL)
		depth(tree[a].right, b + 1);
	if (tree[a].left != NIL)
		depth(tree[a].left, b + 1);
}

int height(int a)
{
	int h1, h2;
	h1 = h2 = 0;
	if (tree[a].left != NIL)
		h1 = height(tree[a].left) + 1;
	if (tree[a].right != NIL)
		h2 = height(tree[a].right) + 1;
	return H[a] = max(h1, h2);
}

void print(int n) {
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ":" << " parent = " << tree[i].parent << ", ";
		cout << "sibling = ";
		if (tree[i].parent == NIL)
			cout << -1;
		else if (tree[tree[i].parent].left != i)
			cout << tree[tree[i].parent].left;
		else
			cout << tree[tree[i].parent].right;
		cout << ", degree = ";
		if (tree[i].left != NIL && tree[i].right != NIL)
			cout << 2;
		else if (tree[i].left == NIL && tree[i].right == NIL)
			cout << 0;
		else
			cout << 1;
		cout << ", depth = " << D[i];
		cout << ", height = " << H[i];
		cout << ", ";
		if (tree[i].parent == NIL)
			cout << "root";
		else if (tree[i].left == NIL && tree[i].right == NIL)
			cout << "leaf";
		else
			cout << "internal node";
		cout << endl;
	}
}



Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			String line = sc.nextLine();
			
			String[] nico = line.split(" ");

			int a = Integer.parseInt(nico[0]);
			int b = Integer.parseInt(nico[1]);
			int n = Integer.parseInt(nico[2]);
			
			String s = String.valueOf((double)(a % b) / b);
			
			int ans = 0;
			for (int i = 2; i < s.length(); i++) {
				ans = ans + s.charAt(i) - '0';
				if (i == (n + 1)) break;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 26196
#include<bits/stdc++.h>
#include<iostream>
#include <cstdio>
#define endl '\n'
using namespace std;
int main(int argc, char const *argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	int turn;
	if(a==b && b==c && c==a) {
            if(a%2==1)turn = 0;
            else if(a%2==0)turn = -1;
    }
	else{
            turn = 0;
	while(!(a%2) && !(b%2) && !(c%2))
	{
		int A = (b/2)+(c/2);
		int B = (a/2)+(c/2);
		int C = (a/2)+(b/2);
		turn++;
		a = A,b = B,c = C;
		//cout<<a<<" "<<b<<" "<<c<<endl;
	}
	}
	cout<<turn<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    bool flag=true;
    vector<char> ans(n);
    vector<bool> mark(n,false);
    int od, num;
    if( n> 1){
        for( int i=0; i<m; i++){
            cin >> s[i] >> c[i];
            od = s[i]-1;
            num = c[i];
            if(mark[od]==true && ans[od] !='0'+ num){
                flag=false;
                break;
            }
            if(od==0 && num ==0){
                flag=false;
                break;
            }
            ans[od] = '0'+num;
            mark[od] = true;
        }
        if(flag==true){
            for( int i=0; i<n; i++){
                if(mark[i] == false && i != 0){
                    ans[i] = '0';
                }else if( mark[i] == false && i==0){
                    ans[i] = '1';
                }
            }
        }
    }else{
        if(m>1){
            flag=false;
        }else if(m==1){
            int ss, cc;
            cin >> ss >> cc;
            ans[0] = '0'+cc;
        }else if(m==0){
            ans[0] = '0';
        }
    }
    if(flag==true){
        for(int i=0; i<n; i++){
            cout << ans[i];
        }
        cout << endl;
    }else if(flag==false){
        cout << -1 << endl;
    }
}




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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;



int main()
{
    int n;cin >> n;
    int res=n;
    for(int i=0;i<=n;i++){
        int cc=0;
        int t=i;
        while(t>0){
            cc += t%6;
            t /= 6;
        }
        t = n - i;
        while(t>0){
            cc += t%9;
            t /= 9;
        }
        res = min(res,cc);
    }
    p(res)
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
ll power(ll x,ll y,ll p){
ll res = 1;x = x % p;
while (y > 0){
if (y & 1){res = (res*x) % p;}
y = y>>1;
x = (x*x) % p;}
return res;}
ll mcd(ll a,ll b){
    if(b>a)swap(a,b);
    if(b==0)return a;
    else return mcd(b,a%b);
}
ll t,n,m,k;
bool esprimo(ll n){
ll s=0;
for(ll i=1;i*i<=n;i++){
    if(n%i==0){s++;}}
if(s>=2){return false;}
return true;
}
int main(){
    //    cout<<fixed<<setprecision(2);
//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

cin>>n>>k;
ll a[n][2];
if(k>n){k=n;}
memset(a,0,sizeof a);
for(int i=0;i<n;i++){cin>>a[i][0];}
a[0][1]=0;
a[1][1]=abs(a[1][0]-a[0][0]);
for(int i=2;i<n;i++){
        a[i][1]=1e18;
for(int j=max((int)(i-k),0);j<i;j++){
    a[i][1]=min(a[i][1],abs(a[i][0]-a[j][0])+a[j][1]);
}
}
//for(int i=0;i<n;i++){cout<<a[i][1]<<" ";}
cout<<a[n-1][1]<<endl;
}


Measured memory_bytes: 1792
N, C, *STC = map(int, open(0).read().split())

T = [[0] * 10 ** 5 for _ in range(C + 1)]
for s, t, c in zip(*[iter(STC)] * 3):
    T[c][s - 1:t] = [1] * (t - s + 1)

print(max(map(sum, zip(*T))))

Measured memory_bytes: 36468
#include<cstdio>
#include<string>
int X,Y,Z;
char t[510],s[510];
void dfs(int x,int y,int z,int n){
	if(!x&&!y&&!z){
		t[n]=0;
		bool fl=1;
		for(int i=1;i<n&&fl;i++){
			int j=0;while(j<n&&t[(i+j)%n]==t[j])j++;
			if(j<n&&t[(i+j)%n]<t[j])fl=0;
		}
		if(fl)for(int i=0;i<=n;i++)s[i]=t[i];
	}
	else{
		if(x)t[n]='a',dfs(x-1,y,z,n+1);
		if(y)t[n]='b',dfs(x,y-1,z,n+1);
		if(z)t[n]='c',dfs(x,y,z-1,n+1);
	}
}
std::string con(int X,int Y,int Z){
	std::string S;
	if(!X){
		if(!Y&&!Z)return S;
		S=con(Y,Z,0);
		for(int i=0;i<S.length();i++)S[i]++;
		return S;
	}
	if(!Y){
		if(!Z){
			for(int i=0;i<X;i++)S.push_back('a');
			return S;
		}
		S=con(X,Z,0);
		for(int i=0;i<S.length();i++)S[i]=='b'?S[i]='c':1;
		return S;
	}
	if(!Z){
		for(int i=1;i<=X;i++){
			S.push_back('a');
			for(int j=Y*(i-1)/X;j<Y*i/X;j++)S.push_back('b');
		}
		return S;
	}
	int t=X-Z%X;
	std::string T=con(t-Y%t,Y%t,Z%X);
	for(int i=0;i<T.length();i++){
		S.push_back('a');
		if(T[i]=='a'){
			for(int j=0;j<Z/X;j++)S.push_back('c');
			for(int j=0;j<Y/t;j++)S.push_back('b');
		}
		if(T[i]=='b'){
			for(int j=0;j<Z/X;j++)S.push_back('c');
			for(int j=0;j<Y/t+1;j++)S.push_back('b');
		}
		if(T[i]=='c'){
			for(int j=0;j<Z/X+1;j++)S.push_back('c');
		}
	}
	return S;
}
int main(){
	/*
	for(X=0;X<=5;X++)
		for(Y=0;Y<=8;Y++)
			for(Z=0;Z<=8;Z++){
				printf("%d,%d,%d: ",X,Y,Z);
				dfs(X,Y,Z,0);
				for(int i=0,p=0;i<X;i++){
					int cs=0;
					for(++p;s[p]&&s[p]!='a';p++)if(s[p]=='c')cs++;
					printf("%d,",cs);
				}
				puts(s);
				printf("(%d,%d,%d)",X,Y,Z);
				puts(con(X,Y,Z).c_str());
				
				if(!X){
					printf("(%d,%d,%d)",X,Y,Z);
					for(int i=1;i<=Y;i++){
						putchar('b');
						for(int j=Z*(i-1)/Y;j<Z*i/Y;j++)putchar('c');
					}
					if(!Y)for(int i=0;i<Z;i++)putchar('c');
					puts("");
				}
			}*/
	int X,Y,Z;scanf("%d%d%d",&X,&Y,&Z);
	puts(con(X,Y,Z).c_str());
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int N, M, Q;
vector <int> a;
vector <int> b;
vector <int> c;
vector <int> d;

int ans;

void dfs(vector <int> A) {
	if (A.size() == N){
		int tmp = 0;
		for (int ii = 0; ii < Q; ++ii){
			if (A[b[ii]]-A[a[ii]]==c[ii]){
				tmp += d[ii];
			}
		}
		ans = max(ans, tmp);
	} else {
		if (A.size() == 0){
			A.push_back(1);
		} else {
			A.push_back(A.back());
		}

		while (A.back() <= M){
			dfs(A);
			A.back()++;
		}
	}
}

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

	a.assign(Q, 0);
	b.assign(Q, 0);
	c.assign(Q, 0);
	d.assign(Q, 0);
	for (int ii = 0; ii < Q; ++ii){
		cin >> a[ii] >> b[ii] >> c[ii] >> d[ii];
		a[ii]--; b[ii]--;
	}

	ans = 0;
	vector <int> A;
	dfs(A);

	cout << ans << "\n";

	return 0;
}


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

int main(){
    long long a, b, c, k, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
    d = a-b;
    if(k%2 == 0) printf("%lld\n", d);
    else printf("%lld\n", -d);
}

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

int main(){
  int n,c;
  cin >> n >> c;
  int p;
  int sum=0;
  for(int i=0;i<c;i++){
    cin >> p; sum+=p;
  }
  cout << (sum+n)/(n+1) << endl;
}


Measured memory_bytes: 3120
//#define debug

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

#define SZ(x) ((int)x.size())

int n, m, np, residue;
char a[13][13];
bool used[13], mark[13];
ii all_pairs[13];

struct data {
	ll hs, hp; int id;
	data(ll _hp, ll _hs, int _id) {
		hp = _hp;
		hs = _hs;
		id = _id;
	}
	bool operator<(const data &other) const {
		if (hp == other.hp) {
			if (hs == other.hs)
				return id < other.id;
			return hs < other.hs;
		}
		return hp < other.hp;
	}
};

set<data> s;
vector<pll> d;

pll calc_hash(int col) {
	ll hs = 0, hp = 0;
	for (int j = 1; j <= np; ++j) {
		hp = hp * 27ll + (ll)(a[all_pairs[j].first][col] - 'a' + 1);
		hs = hs * 27ll + (ll)(a[all_pairs[j].second][col] - 'a' + 1);
	}
	if (residue) {
		hp = hp * 27ll + (ll)(a[residue][col] - 'a' + 1);
		hs = hs * 27ll + (ll)(a[residue][col] - 'a' + 1);
	}
	return pll(hp, hs);
}

void check() {
	d.clear();
	s.clear();
	memset(mark, false, sizeof(mark));
	for (int i = 1; i <= m; ++i) {
		auto tmp = calc_hash(i);
		d.push_back(tmp);
		s.insert(data(tmp.first, tmp.second, i));
	}
	for (int i = 1; i <= m; ++i) {
		if (mark[i]) continue;
		auto tmp = d[i - 1];
		auto it = s.lower_bound(data(tmp.second, tmp.first, 0));
		if (it != s.end() && it->id == i) ++it;
		if (it == s.end() || it->hs != tmp.first || it->hp != tmp.second) continue;
		mark[i] = mark[it->id] = true;
		s.erase(it);
		s.erase(data(tmp.first, tmp.second, i));
	}
	if (!SZ(s)) {
		puts("YES");
		exit(0);
	}
	if (SZ(s) == 1 && (m & 1)) {
		int i = (*s.begin()).id;
		auto tmp = d[i - 1];
		if (tmp.first == tmp.second) {
			puts("YES");
			exit(0);
		}
	}
}

void brute(int cnt) {
	int p1 = -1;
	for (int i = all_pairs[cnt - 1].first + 1; i <= n; ++i) {
		if (!used[i]) {
			used[(p1 = i)] = true;
			break;
		}
	}
	if (p1 == -1) {
		check();
		return;
	}
	all_pairs[cnt].first = p1;
	for (int i = p1 + 1; i <= n; ++i) {
		if (used[i]) continue;
		all_pairs[cnt].second = i;
		used[i] = true;
		brute(cnt + 1);
		used[i] = false;
	}
	used[p1] = false;
}

int main() {
#ifdef debug
	clock_t tStart = clock();
#endif
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", a[i] + 1);
	}
	np = n / 2;
	for (int residue = n & 1; residue <= (n & 1) * n; ++residue) {
		used[residue] = true;
		brute(1);
		used[residue] = false;
	}
	puts("NO");
#ifdef debug
	printf("Total time: %d ms\n", (int)(1000.0 * (double)(clock() - tStart) / CLOCKS_PER_SEC));
#endif
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N;
    cin>>N;
    int a;
    int ans=0;
    for(int i=1;i<=N;i++){
        cin>>a;
        if(i%2==1){
            if(a%2==1){
                ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n;
	cin >> n;
	n %= 1000;
	if (n == 0) {
		cout << 0;
		return 0;
	}
	cout << 1000 - n;
	return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

int a, b, c, d, l, r;

int main(){

    cin >> a >> b >> c >> d;

    l = a + b;
    r = c + d;

    if(l > r){
        cout << "Left";
    } else if(l < r){
        cout << "Right";
    } else{
        cout << "Balanced";
    }






}

//g++ -std=c++14 comp.cpp -o b; ./b.exealso

Measured memory_bytes: 256
int a[200010];
int ans[200010];
int main(){
int n;
scanf("%d",&n);
for(int i=2;i<=n;i++)scanf("%d",&a[i]);
for(int i=2;i<=n;i++)ans[a[i]]++;
for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
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;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll INF = 100000007;

int main() {
  IN(ll,A);
  IN(ll,B);
  IN(ll,N);
  ll ans;
  if(B - 1 < N){
    ll f = (A*(B-1))/B;
    ans = f;
  }else{
    ll f = (A*(N))/B;
    ans = f;
  }
  OUT(ans);
}





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

int main() {
    int a, b;

    cin >> a >> b;

    for (ll i = a; i <= (ll)a*b; i+=a) {
        if (i % b == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
	using namespace std;
	static const int INPUT_H_MIN = 1;	/* 前提は1以上だが、入力終了時は0 */
	static const int INPUT_H_MAX = 300;
	static const int INPUT_W_MIN = 1;	/* 前提は1以上だが、入力終了時は0 */
	static const int INPUT_W_MAX = 300;
	int input_h = 0;
	int input_w = 0;
	
	do{
		/* 縦Hと横Wを入力 */
		cin >> input_h >> input_w;
		
		/* 入力値が、  両方0(入力終了時) or 前提条件 最大・最小の制限内の入力 */
		assert ((input_h == 0 && input_w == 0 ) || (INPUT_H_MIN <= input_h && input_h <= INPUT_H_MAX));
		assert ((input_h == 0 && input_w == 0 ) || (INPUT_W_MIN <= input_w && input_w <= INPUT_W_MAX));
		
		/* 出力 */
		if(input_h != 0 && input_w != 0){
			for (int i = 0; i < input_h; i++){		/* 縦 */
				for (int j = 0; j < input_w; j++){	/* 横 */
					cout << "#";
				}
				cout << "\n";
			}
			cout << "\n";							/* データセット間の空行 */
		}
		else{
			break;
		}
	}while(input_h != 0 && input_w != 0);
	
	return 0;
}



Measured memory_bytes: 3024
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class R
{
public:
    string city;
    int score;
    int num;

    R(string city, int score, int num)
    {
        this->city = city;
        this->score = score;
        this->num = num;
    }

    bool operator <(R& r)
    {
        if (this->city != r.city)
        {
            return this->city < r.city;
        }
        else
        {
            return this->score > r.score;
        }
    }
};

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

    int N;
    cin >> N;

    vector<R> v;
    rep(i, N)
    {
        string s;
        int p;
        cin >> s >> p;
        v.emplace_back(s, p, i + 1);
    }

    sort(all(v));

    for (auto x : v)
    {
        cout << x.num << endl;
    }

    return 0;
}

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

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

    rep(i,55556) {
        int t = i+2;

        bool isP=0;
        for(int j=2; j*j<=t; j++)
            if(t%j == 0)    
                isP = 1;
        
        if(!isP && t%5==1) {
            cout << t;
            c++;
            if(c == N)
                break;
            cout << " ";
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

    int len = s.length();

    string str = string();
    for (int i = 0; i < len; i++) {
        str += "x";
    }

    cout << str << '\n';

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = [0] * M
X[0:M] = map(int, input().split())
if N >= M:
    print(0)
else:
    Li = sorted(X)
    dff = [abs(Li[i] - Li[i - 1]) for i in range(1, M)]
    d = sorted(dff)
    print(sum(d[:M - N]))

Measured memory_bytes: 14736
import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N, M = read_values()
    A = read_list()
    R = {}
    R[0] = 1
    S = 0
    for a in A:
        S += a
        S %= M
        R[S] = R.setdefault(S, 0) + 1

    res = 0
    for r in R.values():
        res += r * (r - 1) // 2

    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14468
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int n;
  cin >> n;
  if ((n % 2) == 0){
    cout << n << endl;
  }
  else {
    cout << n * 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size,init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


def permutate(x,A):
    n=len(x)
    res=[-1]*n
    for i in range(n):

        res[i]=x[A[i]]
    return res


def generate_bin(digit):
    for b in range(2**digit):
        b=bin(b)
        tmp=b[2:].zfill(digit)
        yield list(map(int,tmp))
        #b=list(map(int,list(b[2:].zfill(digit))))
        #yield b
        

def search(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

A,V=acinput()
B,W=acinput()

T=II()


d=abs(A-B)

if d<=T*(V-W):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 27192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        var s_ = string.Join("", s.ToCharArray().OrderBy(i=>i));
        var t_ = string.Join("", t.ToCharArray().OrderByDescending(i=>i));
        Console.WriteLine(s_.CompareTo(t_) < 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 13536
import sys
d = [0] * 10**5
N, K = [int(x) for x in sys.stdin.readline().split()]

for i in range(N):
    a, b = [int(x) for x in sys.stdin.readline().split()]
    d[a-1] += b
    
cnt = 0

for i, j in enumerate(d):
    cnt += j
    if cnt >= K:
        print(i+1)
        break

Measured memory_bytes: 5744
#include<bits/stdc++.h>
using namespace std;
typedef double Float;
typedef pair<Float, Float> Point;
typedef pair<Float, Float> P;
typedef pair<Point, Point> Line; // (frm, to)
#define _IsLine    0
#define _IsRay     1
#define _IsSegment 2
const Float eps = 1e-12;

Float norm(Point a) {
    return sqrt(a.first * a.first + a.second * a.second);
}
Float det(Point a, Point b) {
    return a.first * b.second - a.second * b.first;
}
Point normalize(Point vec) {
    Float d = norm(vec);
    return d < eps ? vec : Point(vec.first / d, vec.second / d);
}
Point getvector(Point frm, Point to) {
    return Point(to.first - frm.first, to.second - frm.second);
}
Point getvector(Line a) {
    return getvector(a.first, a.second);
}
Float dist(Point a, Point b) {
    return norm(getvector(a, b));
}
pair<Point, Float> getcoeff(Line a) {
    // ax + by + c = 0, a^2 + b^2 = 1, c >= 0
    Point vec = normalize(getvector(a));
    Float c = det(a.first, vec);
    return c < 0 ? make_pair(Point(vec.second, -vec.first), -c) : make_pair(Point(-vec.second, vec.first), c);
}
Float dist(Point a, pair<Point, Float> c) {
    // !!! signed !!!
    // coefficient (ax + by + c = 0) : need a^2 + b^2 = 1
    return c.first.first * a.first + c.first.second * a.second + c.second;
}
Float getcos(Point frm, Point A, Point B) {
    Float a = dist(frm, A), b = dist(frm, B), c = dist(A, B);
    return (a * a + b * b - c * c) / (2 * a * b);
}
Float dist(Point a, Line b, int prop) {
    switch (prop) {
        case _IsLine:    return abs(dist(a, getcoeff(b)));
        case _IsRay:     return getcos(b.first, a, b.second) > -eps ? dist(a, b, _IsLine) : dist(a, b.first);
        case _IsSegment: return getcos(b.second, a, b.first) > -eps ? min(dist(a, b, _IsRay), dist(a, b.second)) : dist(a, b.second);
    }
    assert(0);
}

int memo[1<<16];
int n;
double r[16];
P p[2][16];

int ans = 0;

inline bool ok(int bit, int i) {
    bool ret = true;
    for(int k=0;k<n;k++){
        if(k==i) continue;
        P pp = p[(bit>>k)%2][k];
        P s = p[0][i];
        P t = p[1][i];
        if(dist(pp, Line(s, t), _IsSegment) < r[k]+r[i]){
            ret = false;
        }
    }
    return ret;
}

int solve(int bit, int count) {
    int ret = count;
    if(memo[bit] != -1) return memo[bit];
    for(int i=0;i<n;i++){
        if((bit>>i)%2 == 0){
            if(ok(bit, i)){
                ret = max(ret, solve((bit | (1<<i)), count+1));
            }
        }
    }
    return memo[bit] = ret;
}


int main() {
    cin >> n;
    for(int i=0;i<n;i++){
        double sx,sy,tx,ty;cin>>r[i]>>sx>>sy>>tx>>ty;
        p[0][i] = {sx,sy};
        p[1][i] = {tx,ty};
    }
    memset(memo, -1, sizeof(memo));
    solve(0, 0);
    cout << memo[0] << endl;
    return 0;
}



Measured memory_bytes: 3448
use proconio::input;  // https://docs.rs/proconio/0.4.1/proconio/
use std::cmp::*;

type V = u32;

fn compute_dp(val: &Vec<V>, wgt: &Vec<V>) -> Vec<Vec<V>> {
    let max_l = 100000;
    let n     = val.len();
    let dp_n  = min(n, (1 << 10) - 1);

    let mut dp = Vec::<Vec<V>>::new();
    let row = (0..=max_l)
                  .map(|i| if i < wgt[0] { 0 } else { val[0] })
                  .collect();
    dp.push(row);

    for u in 1..dp_n {
        let p = (u - 1) / 2;
        let row = (0..=max_l)
                      .map(|i| max(dp[p][i as usize],
                                   if i < wgt[u] { 0 } else {
                                       dp[p][(i - wgt[u]) as usize] + val[u]
                                   }))
                      .collect();
        dp.push(row);
    }
    dp
}

fn solve(u: V, l: V, dp: &Vec<Vec<V>>, val: &Vec<V>, wgt: &Vec<V>) -> V
{
    let (uu, ll) = (u as usize, l as usize);
    if uu < dp.len() {
        dp[uu][ll]
    } else {
        let p  = (u - 1) / 2;
        max(solve(p, l,  &dp, &val, &wgt),
            if l < wgt[uu] { 0 } else {
                solve(p, l - wgt[uu], &dp, &val, &wgt) + val[uu]
            })
    }
}

fn main() {
    input! {
        n:       usize,
        val_wgt: [(V, V); n],
        q:       usize,
        query:   [(V, V); q],
    }
    let (val, wgt) = val_wgt.iter().cloned().unzip();

    let dp = compute_dp(&val, &wgt);

    for ul in query.iter() {
        println!("{}", solve(ul.0 - 1, ul.1, &dp, &val, &wgt));
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S[3];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,3) {
		cin>>S[i];
		reverse(ALL(S[i]));
		FORR(c,S[i]) c-='a';
	}
	x=0;
	while(1) {
		if(S[x].empty()) return _P("%c\n",x+'A');
		y = S[x].back();
		S[x].pop_back();
		x=y;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define vi vector<int>
#define umap unordered_map
#define pii pair<int, int>
#define vpii vector<pii>
#define uset unordered_set
#define frw(i, a, b) for(int i = (a); i < (b); i++)
#define bck(i, a, b) for(int i = (a); i > (b); i--)
#define T() int testcases; cin >> testcases; frw(TC, 1, testcases + 1)
#define tez ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define fi first
#define se second
#define pow asdihagsiduh
#define pub push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) (int)(a.size())
#define sq(a) ((a) * (a))

#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> 
void ZZ(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}

//console o/p without variable names
#define trace1(...) ZZZ(__VA_ARGS__)
template<typename Arg1>
void ZZZ(Arg1&& arg1){
    cerr << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZZ(Arg1&& arg1, Args&&... args){
    cerr << arg1 << ' ';
    ZZZ(args...);
}

const int N = 1e5 + 5;

vi adj[N];

signed main(){
    tez
    int n, m; cin >> n >> m;
    frw(i, 0, m){
        int x; string s; cin >> x >> s;
        if(s == "AC")
            adj[x].pub(1);
        else
            adj[x].pub(0);
    }
    int ac = 0, wa = 0;
    frw(i, 1, n + 1){
        bool acc = 0;
        int cnt = 0;
        for(auto j : adj[i]){
            if(j){
                acc = 1;
                break;
            }
            cnt++;
        }
        if(acc){
            ++ac;
            wa += cnt;
        }
    }
    cout << ac << ' ' << wa;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

#define N 50

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n+1];
   rep(n)
        cin>>arr[i+1];
   ll dp[n+1][N];
   rep(n+1)
        repi(j,N)
            dp[i][j] = -inf;
            
   dp[1][0] = arr[1];
   dp[1][1] = 0;
   for(ll i=2;i<=n;i++)
   {
       ll maxi = (i+1)/2;
       ll temp = 1;
       if(maxi-temp<N)
            dp[i][maxi-temp] = arr[i];
       for(ll j=i-2;j>max(-1ll,i-5);j--)
       {
           for(ll off = 0;off<N;off++)
           {
               ll tot = (j+1)/2 - off + 1;
               if(maxi-tot>=N)
                    continue;
               dp[i][maxi-tot] = max(dp[i][maxi-tot],dp[j][off]+arr[i]);
           }
       }
   }
   ll ans = -inf;
   ll req = (n)/2;
   for(ll i=1;i<=n;i++)
   {
       for(ll j=0;j<N;j++)
       {
           ll tot = (i+1)/2 - j;
           //cout<<"at "<<i<<" , "<<j<<" = "<<dp[i][j]<<"\n";
           if(tot == req)
                ans = max(ans,dp[i][j]);
       }
   }
   cout<<ans;
   
   
   return 0;        
}  
   

Measured memory_bytes: 83324
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define rep(i,a,b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

const int INF = 1e8;

using namespace std;

int main(){
	_

	int n;
	cin>>n;

	cout<<(2*n)/__gcd(2,n)<<"\n";

	return 0;
}

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

const int N = 2010;

vector <int> G[N], E[N];
int n, a[N];
bool vis[N], isrt[N];

inline void Dfs(int x) {
  vis[x] = 1;
  sort(G[x].begin(), G[x].end());
  for (auto i : G[x])
    if (!vis[i]) Dfs(i), E[x].push_back(i);
}

inline void Topo() {
  priority_queue <int> Q;
  for (int i = 1; i <= n; i ++)
    if (isrt[i]) Q.push(i);
  for (int i = 1, x; i <= n; i ++) {
    x = Q.top(); Q.pop();
    printf("%d ", a[x]);
    for (auto j : E[x]) Q.push(j);
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i ++)
    for (int j = i + 1; j <= n; j ++)
      if (__gcd(a[i], a[j]) > 1) {
        G[i].push_back(j);
        G[j].push_back(i);
      }
  for (int i = 1; i <= n; i ++)
    if (!vis[i]) Dfs(i), isrt[i] = 1;
  Topo();
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

ll ans;
string s;

void rec(int n,vector<bool> op){
  if(n == op.size()){
    int l = 0, r = 0;
    while(r < op.size()){
      if(op[r] == false){
	r++;
      }else{
	ans += stoll(s.substr(l,r-l+1));
	//cout << ans << endl;
	l = r = r + 1;
      }
    }
    ans += stoll(s.substr(l,r-l+1));
    //cout << "(" << l << "." << r << ")" << endl;
  }else{
    rec(n+1,op);
    op[n] = true;
    rec(n+1,op);
  }
}
  

main(){
  cin >> s;
  vector<bool> op(s.size()-1);
  ans = 0;
  rec(0,op);
  cout << ans << endl;
}


Measured memory_bytes: 256
var lines=[];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', (line) => {
    lines.push(line)
})

reader.on('close', () => {
    var num = lines[0].split(" ")[0]
    var invalid = lines[1].split(" ")

    while (1) {
        if (!invalid.find(v => (num+"").includes(v)))
            break
        num++
    }
    console.log(num)
})


Measured memory_bytes: 13352
def main():
    from math import hypot
    N, D = (int(i) for i in input().split())
    ans = 0
    for _ in range(N):
        x, y = (int(i) for i in input().split())
        if hypot(x, y) <= D:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69908
import bisect
from collections import deque
from collections import defaultdict
#from math import factorial
from math import sqrt
n=int(input())
v=list(map(int,input().split()))

a=[]
b=[]
for i in range(n):
    if i%2==0:
        a.append(v[i])
    else:
        b.append(v[i])

A=defaultdict(int)
B=defaultdict(int)
for i in a:
    A[i]+=1
for i in b:
    B[i]+=1
A[0]=0
B[0]=0
Amax=0
Akey=0
Bmax=0
Bkey=0

for key in A.keys():
    if Amax<A[key]:
        Akey=key
        Amax=A[key]
for key in B.keys():
    if Bmax<B[key]:
        Bkey=key
        Bmax=B[key]
min=10**5
n_=int(n/2)
for i in B.keys():
    min_=(n_-Amax)+(n_-B[i])
    if Akey!=i and min>min_:
        min=min_
for i in A.keys():
    min_=(n_-A[i])+(n_-Bmax)
    if Bkey!=i and min>min_:
        min=min_
print(min)


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

int main() {
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    int curr = 1;
    while (curr < b) {
        curr = curr + a - 1;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int _=305;
const int mod=1e9+7;
inline int read()
{
	char ch='!';int z=1,num=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')z=-1,ch=getchar();
	while(ch<='9'&&ch>='0')num=(num<<3)+(num<<1)+ch-'0',ch=getchar();
	return z*num;
}
int n,m,f[_][_][_];
struct ha{int l,x;};
vector<ha>q[_];
bool check(int p,int p1,int p2)
{
	int len=q[p].size();
	for(int i=0;i<len;++i)
	{
		ha u=q[p][i];int x=1;
		if(p1>=u.l)x++;
		if(p2>=u.l)x++;
		if(x!=u.x)return 0;
	}
	return 1;
}
void add(int &a,int b){a+=b;if(a>=mod)a-=mod;}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
	{
		int l=read(),r=read(),x=read();
		q[r].push_back((ha){l,x});
	}
	f[0][0][0]=1;
	for(int i=0;i<n;++i)
		for(int j=0;j<i||!j;++j)
			for(int k=0;k<j||!k;++k)
			{
				if(!f[i][j][k])continue;
				if(check(i+1,j,k))add(f[i+1][j][k],f[i][j][k]);
				if(check(i+1,i,j))add(f[i+1][i][j],f[i][j][k]);
				if(check(i+1,i,k))add(f[i+1][i][k],f[i][j][k]);
			}
	int ans=0;
	for(int j=0;j<n;++j)
		for(int k=0;k<j||!k;++k)
			add(ans,f[n][j][k]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 108800
from collections import deque


def main():
    process_count, process_time, processes = get_input()
    result = run_roundrobin(processes=processes, time=process_time)
    for r in result:
        print(r.name, r.time)


def run_roundrobin(processes, time, total_time=0, result=[]):
    while processes:
        p = processes.popleft()
        if p.time <= time:
            total_time += p.time
            p.time = total_time
            result.append(p)
        else:
            total_time += time
            p.time -= time
            processes.append(p)

    return result


def get_input():
    count, time = list(map(lambda x: int(x), input().split(' ')))

    processes = deque([])
    for _ in range(count):
        im = input().split(' ')
        p = Process(im[0], int(im[1]))
        processes.append(p)

    return count, time, processes


class Process():

    def __init__(self, name, time):
        self.name = name
        self.time = time


main()

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

int main() {
    string s;
    cin >> s;
    string  acgt = "ACGT";
    int cnt = 0;
    int res = 0;
    
    for (int i=0; i < s.size(); i++) {
        for (int j = 0; j < acgt.size(); j++) {
            if (s[i] == acgt[j]){
                cnt++;
                if (cnt > res) {
                    res = cnt;
                }
                break;
            }
            else if (j == acgt.size()-1) cnt = 0;
        }
    }

    cout << res << endl;

}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int MOD = 1e9 + 7;
 
// thanks pekempey for struct // https://atcoder.jp/contests/abc132/submissions/6188715
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }
 
int N, K;
 
const int SQRTNTIMESTWO = 63246;
 
mint dp[SQRTNTIMESTWO + 5][2];
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> K;
 
    vector <int> stuff;
    for(int i = 1; i * i <= N; i++) {
        stuff.push_back(i);
        stuff.push_back(N / i);
    }
    sort(stuff.begin(), stuff.end());
    stuff.erase(unique(stuff.begin(), stuff.end()), stuff.end());
 
    dp[0][0] = 1;
    for(int i = 1; i <= K; i++) {
        int step = i % 2;
        mint suma = 0;
        int idx = 0;
        for(int j = stuff.size() - 1; j >= 0; j--) {
            while(idx < stuff.size() && stuff[j] * 1LL * stuff[idx] <= N)
                suma += dp[idx++][!step];
 
            dp[j][step] = (stuff[j] - (j == 0 ? 0 : stuff[j - 1])) * suma;
        }
    }
 
    mint ans = 0;
    for(int i = 0; i < stuff.size(); i++)
        ans += dp[i][K % 2];
    cout << ans << endl;
}


Measured memory_bytes: 1152