akhauriyash/Code-Regression huggingface dataset:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



class UnionFindTree:
    def __init__(self, n):
        self.n = n
        self.parent = list(range(n))
        self.size = [1] * n

    def root(self, i):
        inter = set()
        while self.parent[i]!=i:
            inter.add(i)
            i = self.parent[i]
        r = i
        for i in inter:
            self.parent[i] = r
        return r

    def connect(self, i, j):
        if i==j:
            return
        ri = self.root(i)
        rj = self.root(j)
        if ri==rj:
            return
        if self.size[ri]<self.size[rj]:
            self.parent[ri] = rj
            self.size[rj] += self.size[ri]
        else:
            self.parent[rj] = ri
            self.size[ri] += self.size[rj]

n,m = map(int, input().split())
d = {i: [] for i in range(m)}
for i in range(n):
    l = list(map(lambda x: int(x)-1, input().split()))
    for j in l[1:]:
        d[j].append(i)
uf = UnionFindTree(n)
for item in d.values():
    if len(item)>=2:
        for u in item:
            uf.connect(item[0], u)
for i in range(n):
    uf.root(i)
if all(uf.parent[0] == item for item in uf.parent):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 91196
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        while (s.contains("0B") || s.contains("1B")) {

            s = s.replaceAll("0B", "");
            s = s.replaceAll("1B", "");


        }
        s = s.replaceAll("B", "");
        System.out.println(s);


    }
}


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

int n,m;
int a[100010];

int now;char ch;
inline int get_num()
{
    now=0;ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')
    {
        now=(now<<1)+(now<<3)+ch-'0';
        ch=getchar();
    }
    return now;
}

int main()
{
	n=get_num();m=get_num();
	for(int i=1;i<=m;i++)
	{
		a[get_num()]++;
		a[get_num()]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2==1)
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll getinv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 500005
int n; ll m,l[N],r[N],ls[N],rs[N],ans;
struct node{ ll x,val; }a[N];
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	n=read(),m=read();
	rep (i,1,n){
		a[i].x=read(),a[i].val=read(); a[i+n]=a[i];
	}
	ll now=0;
	per (i,n,1){
		now+=a[i].val; l[i]=now-2ll*(m-a[i].x); ls[i]=now-(m-a[i].x);
	}
	//rep (i,1,n) cerr<<l[i]<<' '; cerr<<endl;
	now=0;
	rep (i,n+1,2*n){
		now+=a[i].val; r[i]=now-2ll*a[i].x; rs[i]=now-a[i].x;
	}
	//rep (i,n+1,2*n) cerr<<r[i]<<' '; cerr<<endl;
	rs[n]=0; rep (i,n+1,2*n) rs[i]=max(rs[i-1],rs[i]);
	ls[n+1]=0; per (i,n,1) ls[i]=max(ls[i+1],ls[i]);
	ans=0;
	rep (i,1,n+1) ans=max(ans,l[i]+rs[n-(n-i+1)+n]);
	rep (i,n,2*n) ans=max(ans,r[i]+ls[i-n+1]);
	cout<<ans<<endl;
	return 0;
}
// sample data:
/*
3 20
2 80
9 120
16 1

191

*/

// rest:
/*

*/

Measured memory_bytes: 16640
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
dp = [1] * (M+1)
dpleft = [0] * (M)
MOD = 10 ** 9 + 7
ndp = [1] * (M+1)
for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            ndp[m+1] = (ndp[m] + dp[m+1]) % MOD
            dpleft[m] = dp[m+1]
        else:
            ndp[m+1] = (ndp[m] + dpleft[m]) % MOD
        dp[m] = ndp[m]
    dp[-1] = ndp[-1]
print(dp[-1])

Measured memory_bytes: 42348
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;

using namespace std;

int main() {
	i64 n, a, b;
	cin >> n >> a >> b;
	vector<i64> data(n);
	ff(i, 0, n) {
		cin >> data.at(i);
	}
	i64 ans = 0;
	ff(i, 0, n-1) {
		i64 c = (data.at(i + 1) - data.at(i)) * a;
		if (c > b) {
			ans += b;
		}
		else ans += c;
	}
	cout << ans << endl;
	return 0;
}

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

struct coef{
    int r,c,s,i;
    coef(int R=0,int C=0,int S=0,int I=0):r(R),c(C),s(S),i(I){}
};

void countState(coef &d, string s){
    for(auto c:s){
        switch(c){
            case '(': d.r++; break;
            case '{': d.c++; break;
            case '[': d.s++; break;
            case ')': d.r--; break;
            case '}': d.c--; break;
            case ']': d.s--; break;
        }
    }
}

int main(void){
    int p,q;
    while(cin>>p>>q,p){
        vector<coef> data(p+1);
        for(int i=1;i<=p;i++){
            string s;
            cin>>s;
            data[i]=data[i-1];
            countState(data[i],s);
            for(auto c:s){
                if(c=='.'){
                    data[i-1].i++;
                }else break;
            }
        }

        vector<coef> ansset;
        for(int r=1;r<=20;r++){
            for(int c=1;c<=20;c++){
                for(int s=1;s<=20;s++){
                    bool ok=true;
                    for(int i=1;i<=p;i++){
                        ok &= (r*data[i].r + c*data[i].c + s*data[i].s == data[i].i);
                    }
                    if(ok){
                        ansset.emplace_back(r,c,s);
                    }
                }
            }
        }
        
        coef state;
        for(int i=0;i<q;i++){
            string s;
            cin>>s;
            state.i=0;
            set<int> ans;
            for(auto a:ansset){
                ans.insert(a.r*state.r + a.c*state.c + a.s*state.s);
                if(ans.size()>1){
                    break;
                }
            }
            if(ans.size()==1){
                cout<<*ans.begin();
            }else{
                cout<<-1;
            }
            if(i+1==q){
                cout<<endl;
            }else{
                cout<<" ";
            }
            countState(state,s);
        }
    }
}



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 998244353;
string S;
LL dp[200010][3][3];

int solve(){
	set<string> ans{S};
	queue<string> Q; Q.push(S);
	while(!Q.empty()){
		string x = Q.front(); Q.pop();
		repp(i,1,S.size()) if(x[i-1] != x[i]){
			string y = x;
			if(x[i-1] != 'a' && x[i] != 'a') y[i-1] = y[i] = 'a'; 
			else if(x[i-1] != 'b' && x[i] != 'b') y[i-1] = y[i] = 'b';
			else if(x[i-1] != 'c' && x[i] != 'c') y[i-1] = y[i] = 'c';
			if(ans.find(y) == ans.end()){
				Q.push(y);
				ans.insert(y);
			}
		}
	}
	return ans.size();
}

int main(){
	cin >> S;
	int n = S.size();
	if(n < 4){
		cout << solve() << endl;
		return 0;
	}
	int d = 0 , m = S[0] - 'a';
	repp(i,1,n){
		if(S[i-1] != S[i]) ++d;
		m += S[i] - 'a';
	}
	if(d == 0){
		cout << 1 << endl;
		return 0;
	}
	dp[1][0][0] = dp[1][1][1] = dp[1][2][2] = 1;
	repp(i,1,n) repp(j,0,3) repp(k,0,3) repp(l,0,3) if(k != l)
		(dp[i+1][(j+l)%3][l] += dp[i][j][k]) %= mod;
	LL ans = 1 , ans2 = 0 , t = 1;
	repp(i,1,n) (ans *= 3) %= mod;
	repp(k,0,3) (ans2 += dp[n][m%3][k]) %= mod;
	cout << (ans - ans2 + mod + (d==n-1?1:0)) % mod << endl;
	return 0;
}


Measured memory_bytes: 14596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  string N;
  cin >> N;
  if (N[0]=='7'||N[1]=='7'||N[2]=='7') {
    cout << "Yes" << endl;
  } else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AtCoder_Project_CSharp
{
    class Program
    {

        static void Main(string[] args)
        {
            var s = (Console.ReadLine());

            var alphabet = new HashSet<int>(Enumerable.Range('a', 26));

            if (s[0] == 'A')
            {
                for (int i = 2; i < s.Length - 1; i++)
                {
                    if(s[i]=='C')
                    {
                        bool flag = false;
                        for (int j = 1; j < s.Length; j++)
                        {
                            if (i == j) continue;
                            if(!alphabet.Contains(s[j]))
                            {
                                flag = true;
                                break;   
                            }
                        }
                        if(!flag)
                        {
                            Console.WriteLine("AC");
                            return;
                        }
                    }
                }
            }
            Console.WriteLine("WA");
            
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i)%2==0){
      if(!((A.at(i)%3==0)||(A.at(i)%5==0))){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
a,b = map(int,input().split())
s = list(input())
ans ='No'

if s.count('-') == 1:
     ind = s.index('-')
     alen = ind
     blen = len(s)-(ind+1)

     if alen == a and blen == b:
         ans = 'Yes'

print(ans)

Measured memory_bytes: 9072
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn =  new Scanner(System.in);
		int N = scn.nextInt();
		long[] A = new long[N];
		long[] B = new long[N];
		long[] C = new long[N];
		long gap = 0;
		long sum = 0;
		int n = 0;
		for(int i = 0; i < N;i++) {
			long Ai = scn.nextLong();
			A[i] = Ai;
			sum += Ai;
		}
		for(int i = 0;i < N;i++) {
			long Bi = scn.nextLong();
			B[i] = Bi;
			sum -= Bi;
			if(Bi > A[i]) {
				gap += Bi - A[i];
				n++;
			}
			C[i] = A[i] - B[i];
		}
		if(sum >= 0) {
			Arrays.sort(C);
			for(int i = C.length-1;i >=0;i--) {
				if(gap <= 0) {
					break;
				}
				gap -= C[i];
				n++;
			}
		}else {
			n = -1;
		}

		System.out.println(n);
	}
}


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

/*int main(void)
{
    int a, b;
    cin >> a >> b;
    
    vector<int> n(5);
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            n[j] = i % 10;
            i /= 10;
        }
        if (n[0] == n[4])
        {
            if (n[1] == n[3])
            {
                ans++;
            }
        }
    }

    cout << ans << endl;
}*/

int main(void)
{
    int a, b;
    cin >> a >> b;

    string s;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        s = to_string(i);
        if (s[0] == s[4])
        {
            if (s[1] == s[3])
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int H, W, K;
	cin >> H >> W >> K;

	vector<vector<char>> field(H + 2, vector<char>(W + 2));


	int countBlack = 0;
	for (int j = 0; j < H; ++j) {
		for (int i = 0; i < W; ++i) {
			cin >> field[j][i];
			if (field[j][i] == '#') {
				countBlack++;
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < (1 << W); ++i) {
		vector<int> w;
		for (int k = 0; k < W; ++k) {
			if (i & (1 << k)) {
				w.push_back(k);
			}
		}

		for (int j = 0; j < (1 << H); ++j) {
			vector<int> h;
			for (int k = 0; k < H; ++k) {
				if (j & (1 << k)) {
					h.push_back(k);
				}
			}

			int count = 0;
			for (auto itr1 = w.begin(); itr1 != w.end(); ++itr1) {
				for (int k = 0; k < H; ++k) {
					if (field[k][*itr1] == '#') {
						count++;
					}
				}
			}
			for (auto itr2 = h.begin(); itr2 != h.end(); ++itr2) {
				for (int k = 0; k < W; ++k) {
					if (field[*itr2][k] == '#') {
						count++;
					}
				}
			}

			for (auto itr2 = h.begin(); itr2 != h.end(); ++itr2) {
				for (auto itr1 = w.begin(); itr1 != w.end(); ++itr1) {
					if (field[*itr2][*itr1] == '#') {
						count--;
					}
				}
			}

			if (countBlack - count == K) {
				++ans;
			}
		}
	}

	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 3632
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
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; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;
int main() {
    int n;
    cin>>n;
    V dp(1e7,INF);
    dp[0]=0;
    rep(i,n+1){
        for(int j=1;j<=n;j*=6){
            dp[i+j]=min(dp[i+j],dp[i]+1);
        }
        for(int j=1;j<=n;j*=9){
            dp[i+j]=min(dp[i+j],dp[i]+1);
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define l(x) (x&-x)
const int N=1e6+5;
using namespace std;
int a[N],book[N],ans[N];
int n,m;
template<typename tp>inline void r(tp &n){
	n=0;char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0') n=(n<<1)+(n<<3)+c-48,c=getchar();
}
template<typename tp>inline void w(tp  n){
	if(n<0) putchar('-'),n=-n;
	if(n/10) w(n/10);
	putchar(n%10+48);
}
struct Section{
	int x,y,id;
}sec[N];
struct TA{
	int c[N];
	void A(int p,int v){
		while(p<=n)
			c[p]+=v,p+=l(p);
	}
	int  G(int p){
		int ret=0;
		while(p)
			ret+=c[p],p-=l(p);
		return ret;
	}
}t;
bool Cmp(Section a,Section b){
	if(a.y==b.y) return a.x<b.x;
	return a.y<b.y;
}
int main(){
	
	r(n);r(m);
	register int i,R=0;
	for(i=1;i<=n;++i)
		r(a[i]);
	for(i=1;i<=m;++i)
		r(sec[i].x),r(sec[i].y),sec[i].id=i;
	sort(sec+1,sec+m+1,Cmp);
	for(i=1;i<=m;++i){
		while(R<sec[i].y){ 
			++R;
			if(!book[a[R]]) book[a[R]]=R,t.A(R,1);
			else t.A(book[a[R]],-1),book[a[R]]=R,t.A(R,1);
		}
		ans[sec[i].id]=t.G(sec[i].y)-t.G(sec[i].x-1);
	}
	for(i=1;i<=m;++i)
		w(ans[i]),putchar('\n');
	return 0;
}

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

int main(int,char**){
	int i,j,temp,digits;
	while(std::cin >> i){
		std::cin >>j;
		temp = i+j;
		digits=1;
		while(temp/=10) ++digits;
		std::cout << digits <<std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
# include <bits/stdc++.h>
# define rep(i,n) for (int i = 0; i < n; i++)
# define sort(v) sort(v.begin(),v.end())
# define rsort(v) reverse(v.begin(),v.end())
# define all(v) v.begin() ,v.end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const long long INF = 1LL << 60;
// I should have prepared two vectors
int main()
{
  int N;
  int M;
  cin >> N >> M;
  int ac_counter = 0;
  int wa_counter = 0;
  vector<int> WA(105000);
  vector<bool> AC(105000);
  for(int i = 1; i < N; i++ ){
    WA.at(i) = 0;
    AC.at(i) = false;
  }
  while(M--){
    int p; string r;
    cin >> p >> r;
    if(AC.at(p)) continue;
    if(r == "AC"){
      ac_counter++;
      AC.at(p) = true;
      wa_counter += WA.at(p);
    }else{
      //wa_counter += 1;
      WA.at(p)++;
    }
  }
  cout << ac_counter << " " << wa_counter << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {

            int N = in.nextInt();
            int K = in.nextInt();

            long[] x = new long[N];
            long[] y = new long[N];
            for (int i = 0; i < N; i++) {
                x[i] = in.nextInt();
                y[i] = in.nextInt();
            }

            long area = Long.MAX_VALUE;
            for (int i = 0; i < N; i++) {
                for (int i2 = 0; i2 < N; i2++) {
                    if (x[i] > x[i2]) {
                        continue;
                    }
                    for (int j = 0; j < N; j++) {
                        for (int j2 = 0; j2 < N; j2++) {
                            if (y[j] > y[j2]) {
                                continue;
                            }

                            int count = 0;
                            for (int k = 0; k < N; k++) {
                                if (x[k] < x[i] || x[k] > x[i2] || y[k] < y[j] || y[k] > y[j2]) {
                                    continue;
                                }
                                count++;
                            }
                            if (count >= K) {
                                area = Math.min(area, (x[i2] - x[i]) * (y[j2] - y[j]));
                            }
                        }
                    }
                }
            }

            System.out.println(area);
        }
    }

}


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

typedef long long ll;

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

    int a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    while(1){
        if(a%2==1 || b%2==1 || c%2==1) break;
        if(a==b && b==c){
            cout << -1 << endl;
            return 0;
        }
        int now_a=a,now_b=b,now_c=c;
        a = (now_b+now_c)/2;
        b = (now_c+now_a)/2;
        c = (now_a+now_b)/2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;

int a[100010] = {0};
int b[100010] = {0};

signed main(){
    
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;

    int x = abs(a-b);

    REP(i,n){
        if((n-1-i)*d - i*c >= x && x >= (n-1-i)*c - i*d){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}
//g++ -std=c++14 code1.cpp



Measured memory_bytes: 256
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=2e5+5;
int n,k,a[maxn];

int main()
{
    n=read(),k=read();
    REP(i,1,n) a[i]=read();
    REP(i,k+1,n) puts(a[i]>a[i-k]?"Yes":"No");

    return 0;
}


Measured memory_bytes: 4404
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3652
import sys
input = sys.stdin.readline

N = int(input())
a_list = list(map(int, input().split()))

ans_list = [0] * N
ans_text = ''
for i in range(N):
  # j の倍数が何個あるか
  j = N - i
  sum_j = sum(ans_list[j-1::j])
  if sum_j%2 != a_list[j-1]:
    ans_list[j-1] = 1
    ans_text += str(j) + ' '
    
    
print(sum(ans_list))
print(ans_text)


Measured memory_bytes: 9116
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;

std::vector<int> div(int n){
	std::vector<int> v;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			v.push_back(i);
			if(i*i!=n){
				v.push_back(n/i);
			}
		}
	}
	return v;
}

signed main(){
	cin>>N;
	int ans=0;
	vector<int> v=div(N-1);
	ans+=v.size()-1;
	v=div(N);
	REP(i,v.size()){
		int s=N,t=v[i];
		if(v[i]==1)continue;
		while(s%t==0){
			s/=t;
		}
		if(s%t==1){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	int i, p=0,a=0;
	cin >> s;
	for (auto x : s) {
		if (x == 'S')
			p++;
		if (x == 'T') {
			if (p > 0)
				p--;
			else
				a++;
		}
	}
	cout << a*2 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <limits.h>

int main(){

int n;
int num;
char dummy;
int max = INT_MIN, min = INT_MAX;
long sum = 0;

scanf("%d\n", &n);

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

scanf("%d%c", &num, &dummy);

if (max < num) max  = num;
if (min > num) min = num;
sum += num;

}

printf("%d %d %ld\n", min, max, sum);

}


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

int main() {
  int N,M;cin>>N>>M;
  vector<int> A(N+1,0);
  for(int i=0;i<M;i++){
    int S,T;cin>>S>>T;
    A.at(S)++;
    A.at(T)++;
  }
  for(int i=1;i<=N;i++) cout<<A.at(i)<<endl;
}
  


Measured memory_bytes: 3472
#include <stdio.h>

int main()
{
    int n;
    int i;
    int num;
    int manzoku=0;
    int prev=100;
    scanf("%d",&n);

    int a[n];
    int b[n];
    int c[n-1];

    for(i=0;i<n;i++)
    {
        scanf("%d",&num);
        a[i]=num;
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&num);
        b[i]=num;
    }
    for(i=0;i<n-1;i++)
    {
        scanf("%d",&num);
        c[i]=num;
    }

    for(i=0;i<n;i++)
    {
        manzoku+=b[a[i]-1];
        if(a[i]-prev==1)
        {
            manzoku+=c[a[i]-2];
        }
        prev=a[i];

    }

    printf("%d\n",manzoku);

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int R, C; cin >> R >> C;
    char ans[R+2][C+2];
    rep(i, R+2) rep(j, C+2) ans[i][j] = '#';
    rep(i, R){
        string S; cin >> S;
        rep(j, C) ans[i+1][j+1] = S[j];
    }
    rep(i, R+2){
        rep(j, C+2) cout << ans[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
//
// Created by 10034 on 2020/7/29.
//

#include <iostream>
#include <vector>
using namespace std;
vector<int> v;
int main(){

    long long n;
    cin>>n;
    while(n){
        v.push_back((n-1)%26);
        n--;
        n/=26;
    }
    for(int i=v.size()-1;i>=0;--i){
        printf("%c",v[i]+'a');
    }



    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    ll cnt[(ll)1e6+5];
    rep(0,i,(ll)1e6+5)cnt[i]=0;
    rep(0,i,n){
        cin>>a[i];
        ++cnt[a[i]];
    }
    ll g=a[0];
    rep(1,i,n)g=gcd(a[i],g);
    if(g!=1){
        cout<<"not coprime";
        return 0;
    }
    rep(2,i,1e6+5){
        ll tmp=0;
        for(ll j=i;j<1e6+5;j+=i){
            tmp+=cnt[j];
        }
        if(tmp>1){
            cout<<"setwise coprime";
            return 0;
        }
    }
    cout<<"pairwise coprime";
    return 0;
}


Measured memory_bytes: 18812
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()

a = l()

tw = [0 for i in range(n+1)]

tw[0] = 1
no = 1
for i in range(1,n+1):
	tw[i] = no*2
	no = no*2 - a[i]


ans = 0

if n == 0:
	if a[0] == 1:
		print(1)
	else:
		print(-1)
else:
	if a[0] != 0:
		print(-1)
		exit()
	ans = 0
	co = 0
	for i in range(n,0,-1):
		if i == n:
			if tw[i] < a[i]:
				print(-1)
				exit()
			else:
				co = a[i]
				ans += a[i]
		else:
			if a[i] + co <= tw[i]:
				ans += a[i] + co
				co = a[i] + co
			else:
				if -(-co//2) + a[i] <= tw[i]:
					ans += tw[i]
					co = tw[i]
				else:
					print(-1)
					exit()

	print(ans+1)

		



Measured memory_bytes: 701444
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;
 
#define MAXN 305 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

lli dp[100 + 5][100000 + 5];
lli pre[100 + 5][100000 + 5];

int main()
{

    lli n,k;
    cin>>n>>k;

    lli a[n+1];
    loopl(i,1,n+1) cin>>a[i];

    pre[1][0] = 1;
    dp[1][0] = 1;
    loopl(i,1,k+1)
    {
        if(i<=a[1])
            dp[1][i] = 1;

        pre[1][i] = pre[1][i-1] + dp[1][i] ;
    }


    loopl(i,2,n+1)
    {
        loopl(j,0,k+1)
        {
            if(j-a[i] > 0)
                dp[i][j] = (pre[i-1][j]%mod - pre[i-1][j-a[i]-1]%mod + mod)%mod;

            else
                dp[i][j] = pre[i-1][j];

            if(j-1>=0) pre[i][j] = pre[i][j-1];
            pre[i][j] += dp[i][j];
            pre[i][j] %= mod;
        }
    }

    cout<<dp[n][k]<<endl;

}

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

int main(){
	string s; cin >> s;
	ll h[s.size()] = {1 << (s[0] - 'a')};
	for(ll i = 1; i < s.size(); ++i) h[i] = (h[i - 1] ^ (1 << (s[i] - 'a')));
	map<ll, ll> M;
	M.insert(pair<ll, ll>(0, 0));
	M.insert(pair<ll, ll>(1 << (s[0] - 'a'), 1));
	for(ll i = 1; i < s.size(); ++i){
		ll mindp = 1145148931919810;
		for(ll j = 0; j <= 26; ++j){
			auto ite = M.find(h[i] ^ (j == 26 ? 0 : (1 << j)));
			if(ite != M.end()){
				mindp = min<ll>(mindp, ite->second);
			}
		}
		auto ite = M.find(h[i]);
		if(ite == M.end()) M.insert(pair<ll, ll>(h[i], mindp + 1));
		else ite->second = min<ll>(ite->second, mindp + 1);
	}
	cout << (h[s.size() - 1] ? M.find(h[s.size() - 1])->second : 1) << endl;
	return 0;
}

Measured memory_bytes: 14468
n = int(input())
lis = list(map(int, input().split()))
lis2 = sorted(lis)
m1 = lis2[n//2-1]
m2 = lis2[n//2]

c = 0
for i in range((m1+1), (m2+1)):
    c += 1
print(c)


Measured memory_bytes: 13992
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{int n,a,b;
 cin >> n >> a >> b;
 int c = n * a;
if (c > b) cout << b << endl;
 if (b >= c) cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
//ALLAH HU AKABR
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n,m;
  cin>>n>>m;
  int ans=m*(m-1)/2+n*(n-1)/2;
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct E {
    int a;
    int b;
    int c;
    int d;
};
int main () {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<E> v;
    for (int i = 0; i < Q; i++) {
        E e;
        cin >> e.a >> e.b >> e.c >> e.d;
        e.a--; e.b--;
        v.push_back(e);
    }
    vector<int> A(N, 1);
    int ans = 0;
    while (1) {
        int res = 0;
        for (auto e: v) {
            if (A[e.b]-A[e.a] == e.c) {
                res += e.d;
            }
        }
        ans = max(ans, res);
        bool flag = 0;
        for (int i = N-1; i >= 0; i--) {
            if (A[i] < M) {
                A[i]++;
                for (int j = i+1; j < N; j++) {
                    A[j] = A[i];
                }
                flag = 1;
                break;
            }
        }
        if (!flag) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int points[] = new int[w + 1];
		for (int i = 1; i <= w; ++i)
			points[i] = i;
		int n = sc.nextInt();
		sc.useDelimiter(",|\n");
		for (int i = 0; i < n; ++i) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int tmp = points[a];
			points[a] = points[b];
			points[b] = tmp;
		}
		for (int i = 1; i <= w; ++i)
			System.out.println(points[i]);
	}
}


Measured memory_bytes: 26216
n=int(input())
l=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(l[1]-l[0])
for i in range(2,n):dp[i]=min(dp[i-2]+abs(l[i]-l[i-2]),dp[i-1]+abs(l[i]-l[i-1]))
print(dp[-1])

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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=1e5+3;

int n,a[MAXN],f[MAXN];

int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	f[1]=abs(a[1]-a[0]);
	for (int i=2;i<n;i++){
		f[i]=min(f[i-2]+abs(a[i]-a[i-2]),f[i-1]+abs(a[i]-a[i-1]));
	}
	cout<<f[n-1]<<endl;
	re 0;
}

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

using namespace std;

int main(){

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

  for(int i=1; i<=n; i++){
    if(i%2!=0 and a[i-1]%2!=0){
      cnt++;
    }
  }

  cout<<cnt<<endl;
}


Measured memory_bytes: 3620
/**
*    author:  yuya1234
*    created: 25.06.2020 14:12:14
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

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

    int a[50],tmp1,tmp2;
    MEMSET(a,0);
    REP(i,m)
    {
        cin>>tmp1>>tmp2;
        a[tmp1-1]++;
        a[tmp2-1]++;
    }

    REP(i,n)cout<<a[i]<<endl;

    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,x;cin>>n>>x;
    int gc;
    for(int i=0,y;i<n;++i){
        cin>>y;
        if(i==0)gc=abs(x-y);
        else
            gc=__gcd(gc,abs(x-y));
    }
    cout<<gc;

    
}

Measured memory_bytes: 3620
#include<stdio.h>
//！！快给我上！
int main()
{
   // int n,k;
    // 0~9 :48~57
    char s[4];
    //scanf("%d %d",&n,&k);
    scanf("%s",s);
    //s[k-1]+=32;
    int front,end;
    front = (s[0]-48)*10+s[1]-48;
    end = (s[2]-48)*10+s[3]-48;
   if(end>0&&end<=12)
   {
       if(front>0&&front<=12)
       {
           printf("AMBIGUOUS");
           return 0;
       }
       printf("YYMM");
       return 0;
   }
    else if(end==0||end>12)
    {
        if(front>0&&front<=12)
        {
            printf("MMYY");
            return 0;
        }
        else
        {
            printf("NA");
            return 0;
        }
    }
    else
    {
        printf("NA");
        return 0;
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

double DP[302][302][302];
double Nd = 0.0;

double solve(int i, int j, int k) {
	if (DP[i][j][k] >= 0.0) return DP[i][j][k];
	if (i+j+k == 0) return 0.0;
	double res = 0.0;
	if (i > 0) res += solve(i-1, j, k) * i;
	if (j > 0) res += solve(i+1, j-1, k) * j;
	if (k > 0) res += solve(i, j+1, k-1) * k;
	res += Nd;
	res /= ((double)(i+j+k));
	DP[i][j][k] = res;
	return res;
}

int main() {
	int N = 0, i = 0, j, k, l, d1 = 0, d2 = 0, d3 = 0, num;
	scanf("%d", &N);
	Nd = (double)N;
	double cnt = 1.0, mean = 0.0, N_inv;

	for (i = 0; i < N; i++) {
		scanf("%d", &num);
		if (num == 1) d1++;
		if (num == 2) d2++;
		if (num == 3) d3++;
	}
	for (i = 0; i < N+2; i++) {
		for (j = 0; j < N+2; j++) {
			for (k = 0; k < N+2; k++) {
				DP[i][j][k] = -1.0;
			}
		}
	}

	printf("%.12lf\n", solve(d1,d2,d3));
	return 0;
}

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

int main() {
    string s;
    cin>>s;
    char ans;
    vector<int> a(26,0);
    rep(i,s.size()) {
        int temp=s[i]-'a';
        a[temp]++;
    }
    rep(i,26) {
        if (a[i]==0) {
            ans='a'+i;
            cout<<ans<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}


Measured memory_bytes: 512
import Control.Monad                                                                                                       
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [n,x] <- map read . words <$> getLine                                                                                    
  ms <- map read <$> replicateM n getLine                                                                                  
  print $ n + (x - sum ms) `div` minimum ms

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a - b >= c) {
		cout << 0 << endl;
	}
	else {
		cout << c - (a - b) << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int m[20],l[20],i,j,t,s,n;
int main()
{
	for(;scanf("%d",&n)*n;)
	{
		memset(m,-1,sizeof(m));
		memset(l,-1,sizeof(l));
		for(i=0;i<n;i++)
			scanf("%d",&m[i]);
		for(s=0;memcmp(l,m,sizeof(m));s++)
		{
			memcpy(l,m,sizeof(m));
			for(i=0;i<n;m[i]=t,i++)
				for(j=t=0;j<n;j++)
					if(l[i]==l[j])
						t++;
		}

		printf("%d\n",s-1);
		for(i=0;i<n;i++)
			printf("%d%s",l[i],i==n-1?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 616
s = gets.chomp

cache = {}
s.split('').each do |s_one|
  if cache[s_one].nil?
    cache[s_one] = 1
    next
  end
  cache[s_one] += 1
end

count = 0
flg = true
cache.each do |c|
  count += 1
  if c[1] != 2
    flg = false
  end
end

if count == 2 && flg
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

int main() {
	ll n;
	cin >> n;
	vector<int> aList;
	aList.resize(n + 1);
	vector<int> ballList;
	ballList.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> aList[i];
	}
	ll ansM = 0;
	vector<ll> ansList;
	for (ll i = n; i >= 1; i--) {
		ll tmpSum = 0;
		ll now = i;
		while (now <= n) {
			tmpSum += ballList[now];
			now += i;
		}
		if ((tmpSum - aList[i]) % 2 != 0) {
			ansM++;
			ballList[i]++;
			ansList.push_back(i);
		}
	}
	cout << ansM << endl;
	for (ll i = 0; i < ansM; i++) {
		if (i) {
			cout << " ";
		}
		cout << ansList[i];
	}
	cout << endl;
	
} 

Measured memory_bytes: 3572
n=int(input())
a=list(map(int,input().split()))
temp=[0]*(10**6+1)
for i in a:
    temp[i]+=1
if temp[1]==n:
    print("pairwise coprime")
    exit()
ans=[]
for i in range(2,10**6+1):
    count=0
    j=1
    while True:
        count+=temp[i*j]
        j+=1
        if i*j>=10**6:
            break
    ans.append(count)
if max(ans)==1:
    print("pairwise coprime")
elif max(ans)==n:
    print("not coprime")
else:
    print("setwise coprime")


Measured memory_bytes: 227972
//2018.09.14 4.5min

#include <iostream>
using namespace std;

int main() {

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int at, ab;

    if(a>=b) at = b;
    else at = a;

    if(c>=d) ab = d;
    else ab = c;

    cout << at+ab << endl;

    return 0;
}

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

typedef long long ll;
const int maxn = 200010;
int n;
ll ans = 1e18, s[maxn], a[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]), s[i] = s[i - 1] + a[i];
    }
    int j = 1, k = 3;
    for (int i = 2; i < n; i++) {
        ll b = s[j], c = s[i] - s[j];
        ll d = s[k] - s[i], e = s[n] - s[k];
        auto chk = [&](ll x, ll y, int pos) {
            return abs((x + a[pos]) - (y - a[pos])) < abs(x - y);
        };
        while (j + 1 < i && chk(b, c, j + 1)) {
            j++, b = s[j], c = s[i] - s[j];
        }
        while (k + 1 < n && chk(d, e, k + 1)) {
            k++, d = s[k] - s[i], e = s[n] - s[k];
        }
        ans = min(ans, max({b, c, d, e}) - min({b, c, d, e}));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
using namespace std;
typedef long long ll;
//find_by_order, order_of_key
#define forn(i, n) for (ll i=0;i<ll(n);++i)

void solve()
{
    int a; scanf("%d", &a);
    a=a%10;
    if(a==2||a==4||a==5||a==7||a==9) puts("hon");
    else if(a==0||a==1||a==6||a==8) puts("pon");
    else puts("bon");
}
int main()
{
    ll T=1;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <vector>
#include <cstring>

using namespace std;

struct Move
{
    int start_x, start_y, end_x, end_y;

    Move(){}

    Move(int x1, int y1, int x2, int y2)
    {
        start_x = x1, start_y = y1, end_x = x2, end_y = y2;
    }

    void display()
    {
        printf("%d %d %d %d\n", start_x, start_y, end_x, end_y);
    }
};

const int MAX_N = 505;

int grid[MAX_N][MAX_N];

int main()
{
    int rows, columns;
    scanf("%d %d", &rows, &columns);

    memset(grid, 0, sizeof(grid));

    for(int i = 1; i <= rows; i++)
    {
        for(int j = 1; j <= columns; j++)
        {
            scanf("%d", &grid[i][j]);
        }
    }

    vector <Move> moves;
    for(int i = 1; i <= rows; i++)
    {
        for(int j = 1; j < columns; j++)
        {
            if(grid[i][j]%2 == 0) continue;

            moves.push_back(Move(i, j, i, j + 1));

            grid[i][j]--;
            grid[i][j + 1]++;

        }
    }

    for(int i = 1; i < rows; i++)
    {
        int j = columns;

        if(grid[i][j]%2 == 0) continue;

        moves.push_back(Move(i, j, i + 1, j));

        grid[i][j]++;
        grid[i + 1][j]--;
    }

    printf("%d\n", moves.size());
    for(int i = 0; i < moves.size(); i++)
        moves[i].display();

    return 0;
}


Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	string s;
	cin>>s;
	string t=s;
	reverse(t.begin(),t.end());
	int d=0;
	for(int i=0;i<s.size();i++)
	{
		char ss=s.at(i);
		char tt=t.at(i);
		if(ss!=tt)
		d++;
	}
	d=d/2;
	cout<<d<<endl;
}

Measured memory_bytes: 256
program hihi;
var a, b, c, d : integer;
begin
	readln(a, b, c, d);
    while (a>0) and (c>0) do begin
    	c:= c - b;
        if c>0 then a:= a - d;
    end;
    if c<=0 then writeln('Yes')
    else writeln('No');
end.

Measured memory_bytes: 1328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll S(ll n)
{
	ll a = 0;
	while (n > 0)
	{
		a += n % 10;
		n /= 10;
	}
	return a;
}

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

	ll s = S(N);
	string a = "Yes";
	if (N%s != 0)a = "No";
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print('-1 -1 -1')

Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void){
  int a,s=0;
  FOR(10){
    scanf("%d",&a);
    s+=a;
  }
  PRN(s);
  return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int h,n,sum=0,c=0;
	cin>>h;
	if(h==1)
        cout<<1;
    else
    {
        while(h!=0)
        {
            h=h/2;
            sum++;

         }c=pow(2,sum);
        cout<<c-1;

    }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int ans = 0;

		for (int i = 1; i <= N; i = i + 2) {
			int divisor = 0;

			for (int j = 1; j <= Math.sqrt(i); j++) {

				if (i % j == 0) {
					divisor++;
				}

			}

			if (divisor*2 == 8) {
				ans++;
			}
		}
		System.out.println(ans);
		scan.close();
	}
}


Measured memory_bytes: 21844