akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);

	int k;
	cin >> k;
	int res = 0;
	FOR(i,1,k) FOR(j,1,k) FOR(q,1,k) {
		int x = gcd(gcd(i,j), q);
		res += x;
	}
	cout << res << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

vb table(50002, false);
vi prime;

void sieve();
i_i calc(int n);
 
signed main()
{
    sieve();
    Int(m);
    Int(a);
    Int(b);
    while (m) {
        for (int num = m; num >= 0; num--) {
            i_i p = calc(num);
            if (p.first) {
                if (b * p.first - a * p.second >= 0) {
                    cout << p.first << " " << p.second << endl;
                    break;
                }
            }
        }
        cin >> m >> a >> b;
    }

    return 0;
}


i_i calc(int n)
{
    int ret = 0, a, b;
    bool state = false;
    for (int p : prime) {
        if (!(n % p) && ret < 3) {
            if (state) {
                b = p;
            } else {
                state = true;
                a = p;
            }
            ret++;
        } else if (ret >= 3) {
            return i_i(0, 0);
        }
    }
    if (ret == 2 && a * b == n) {
        return i_i(a, b);
    } else if (ret == 1 && a * a == n) {
        return i_i(a, a);
    } else {
        return i_i(0, 0);
    }
}

void sieve()
{
    for (int i = 2; i < 50001; i++) {
        if (!table[i]) {
            prime.pb(i);
            for (int j = 2; i * j < 50001; j++) {
                table[i*j] = true;
            }
        }
    }
}

Measured memory_bytes: 3292
#include <stdio.h>

/*
.0
3124
,5
*/

/* {top, front, right} */
int minase_inori[8][3] = {
	{0, 1, 2}, {0, 2, 4}, {0, 4, 3}, {0, 3, 1},
	{5, 1, 3}, {5, 3, 4}, {5, 4, 2}, {5, 2, 1}
};

int main(void) {
	int hayami_saori[6];
	int uesaka_sumire;
	int iguti_yuka, tamura_yukari, horie_yui;
	for (iguti_yuka = 0; iguti_yuka < 6; iguti_yuka++) {
		if (scanf("%d", &hayami_saori[iguti_yuka]) != 1) return 1;
	}
	for (iguti_yuka = 0; iguti_yuka < 8; iguti_yuka++) {
		for (tamura_yukari = 0; tamura_yukari < 3; tamura_yukari++) {
			minase_inori[iguti_yuka][tamura_yukari] = hayami_saori[minase_inori[iguti_yuka][tamura_yukari]];
		}
	}
	if (scanf("%d", &uesaka_sumire) != 1) return 1;
	for (iguti_yuka = 0; iguti_yuka < uesaka_sumire; iguti_yuka++) {
		int igarasi_hiromi, murakawa_rie;
		if (scanf("%d%d", &igarasi_hiromi, &murakawa_rie) != 2) return 1;
		for (tamura_yukari = 0; tamura_yukari < 8; tamura_yukari++) {
			for (horie_yui = 0; horie_yui < 3; horie_yui++) {
				if (minase_inori[tamura_yukari][horie_yui] == igarasi_hiromi &&
				minase_inori[tamura_yukari][(horie_yui + 1) % 3] == murakawa_rie) {
					printf("%d\n", minase_inori[tamura_yukari][(horie_yui + 2) % 3]);
					tamura_yukari = 334;
					break;
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 2140
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<cmath>
#define fi first
#define se second
#define ll long long
using namespace std;
ll n,s,ans,v[3000],pri[3000],tot;
map<ll,ll> Map,D,vis;
int main()
{
///dsfafdafdasfdasf
	scanf("%lld",&n);
	for(ll i=2;i<=2500;i++)
	{
		if(!v[i]) pri[++tot]=i;
		for(ll j=i*2;j<=2500;j+=i) v[j]=1;
	}
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",&s);ll nw=1,de=1;
		for(ll j=1,p=0;j<=tot;j++,p=0)
		{
			while(s%pri[j]==0) s/=pri[j],p++;p%=3;
			if(p==1) nw*=pri[j],de*=pri[j]*pri[j];
			if(p==2) nw*=pri[j]*pri[j],de*=pri[j];
		}
		if(((int)sqrt(s))*((int)sqrt(s))==s) de*=sqrt(s);
		else de*=s*s;nw*=s;
		D[de]=nw,D[nw]=de,Map[nw]++;
	}
	for(auto x:Map) if(!vis[x.fi]&&x.fi!=1)
					{
						ans+=max(x.se,Map[D[x.fi]]);
						vis[x.fi]=vis[D[x.fi]]=1;
					}
	cout<<ans+(Map[1]>0)<<endl;return 0;
}


Measured memory_bytes: 37760
#include <iostream>

using namespace std;

 

int main() 
{
    int a, b, c, i, ans;
    cin >> a >> b >> c;
    ans = 0;
    for(i=a; i<=b; i++)
    {
        if(c % i == 0)
            ans++;
    }
    
    {
    cout << ans << endl;
    }
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;

int main(void){
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i = 0;i < n;i++)
		cin >> v[i];
	// dp[i] - TRUE if current player wins 
	vector<bool> dp(k+1, false);
	for(int i = 0;i <= k;i++){
		for(int a : v){
			if(i >= a && !dp[i-a]){
				dp[i] = true;
			}
		}
	}
	puts(dp[k] ? "First" : "Second");
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	while(1){
		int a,m;
		double n,mm;
		int ans[9],sans[5];
		cin >> n;
		if(n<0)break;
		m=n;
		mm=(double)n-m;
		if(m>255)cout << "NA" << endl;
		else{
			int rank=8,nn=128;
			while(rank>0){
				ans[8-rank]=m/nn;
				m=m%nn;
				nn=nn/2;
				rank--;
			}
			rank=0;
			double nk=0.5;
			while(rank<4){
				if(mm>=nk){
					sans[rank]=1;
					mm-=nk;
				}else sans[rank]=0;
				nk=(double)nk/2;
				rank++;
			}
		}
		if(mm>0)cout << "NA" << endl;
		else{
			for(a=0;a<8;a++)printf("%d",ans[a]);
			printf(".");
			for(a=0;a<4;a++)printf("%d",sans[a]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    A = tuple(map(int, input().split()))

    sum_A = sum(A)
    if sum_A > N:
        print(-1)
    else:
        print(N - sum_A)

if __name__ == '__main__':
    main()


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

void solve(long long N, std::vector<long long> V, std::vector<long long> C){
    ll ans = 0;
    for (int i = 0; i < (int)N; ++i){
        if(V[i] - C[i] > 0) ans += V[i] - C[i];
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> V(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&V[i]);
    }
    std::vector<long long> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(V), std::move(C));
    return 0;
}


Measured memory_bytes: 256
import sys
#sys.exit()
#sorted( ,reverse=True)
N = int(input())
#S,T = map(int, input().split())
#A = list(map(int, input().split()))
#print(N)
#print(S,T)
#print(A)
S = list(str(input()) for i in range(N))
S2 = sorted(S)
ans = N
#if S2[0] ==S2[1]:
    #ans -= 1
for i in range(1,N):
    if S2[i-1] == S2[i]:
        ans -= 1
print(ans)

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

int main()
{
  string S, T;

  cin >> S >> T;

  int dist = 1024;

  for(size_t i=0; i<S.size()-T.size()+1; ++i){
    auto sub = S.substr(i, T.size());

    int tmp = 0;

    for(size_t j=0; j<T.size(); ++j){
      if(sub[j] != T[j]) ++tmp;
    }

    dist = min(dist, tmp);
  }

  cout << dist << endl;

  return 0;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;
int main() {
	vector<int>c(26);
	while (true) {
		string x;
		getline(cin, x);
		if (x == "")break;
		for (int i = 0; i < x.size(); i++) {
			if ('a' <= x[i] && x[i] <= 'z')c[x[i] - 'a']++;
			if ('A' <= x[i] && x[i] <= 'Z')c[x[i] - 'A']++;
		}
	}
	for (int i = 'a'; i <= 'z'; i++) {
		cout << (char)i << " : " << c[i - 'a'] << endl;
	}
	return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3) {
		if (s[i] == t[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revloop(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define s second
#define ll long long int
#define vi vector<int>
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ll a,b,c;
   cin>>a>>b>>c;
   if(2*b==a+c)
    cout<<"YES";
   else
    cout<<"NO";
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s=sc.next();
    int count=0;
    for(int i=0;i<s.length();i++)if(s.substring(i, i+1).equals("o"))count++;
    if(count+(15-s.length())>=8) {
    	System.out.println("YES");
    }else {
    	System.out.println("NO");
    }
  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, n, k, x,l,r;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Good";

    cin  >> n >> k >> s;

    k--;
    if(s[k] == 'A') s[k] = 'a';
    else if(s[k] == 'B') s[k] = 'b';
    else if(s[k] == 'C') s[k] = 'c';


    sans = s;
    // std::cout << ans << endl; 
    std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq
import random
def main():
    sys.setrecursionlimit(10**7)
    INF = float('inf')
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    T = NI()
    for _ in range(T):
        N = NI()
        A = LI()
        S = SI()

        base = [0] * 60
        for i in range(N-1,-1,-1):
            x = A[i]
            if S[i] == '0':
                for j in range(60):
                    if base[j] > 0 and x & (1 << j):
                        x ^= base[j]

                for j in range(60):
                    if base[j] == 0 and x & (1<<j):
                        for k in range(60):
                            if base[k] & (1<<j):
                                base[k] ^= x
                        base[j] = x
                        break
            else:
                for j in range(60):
                    if base[j] > 0 and x & (1<<j):
                        x ^= base[j]
                if x > 0:
                    print(1)
                    break
        else:
            print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10252
#include <stdio.h>
int main(){
 int a,b,c,x,i,j,k,count=0;
  scanf("%d%d%d%d",&a,&b,&c,&x);
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      for(k=0;k<=c;k++){
        if(500*i+100*j+k*50==x)
        count++;
      }
    }
  }
 printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[0] <<" "<< a[1] <<" "<< a[2]<<endl;
}


Measured memory_bytes: 3128
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int bit = 0;
		for (int i = 0; i < N; i++){
			bit |= scan.nextInt();
		}
		System.out.println(Integer.numberOfTrailingZeros(bit));
	}
}

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

using namespace std;

int main(){
    int N,a,four=0,two=0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a;
        if(a%4 == 0){
            four++;
        }else if(a%2 == 0){
            two++;
        }
    }

    if(two==0){
        if(N-four<=four+1){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(N-two-four<=four){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,f[111][10],p[111][11],b[111]={},ans=-1e9;

void dfs(int now=0,int num=0){
  if(now==10){
    if(num){
    int a=0;
    for(int i=0;i<n;i++)a+=p[i][b[i]];
    ans=max(ans,a);
    }
    return;
  }
  for(int i=0;i<n;i++)b[i]+=f[i][now];
  dfs(now+1,num+1);
  for(int i=0;i<n;i++)b[i]-=f[i][now];
  dfs(now+1,num);
}

main(){
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<10;j++)
      cin>>f[i][j];

  for(int i=0;i<n;i++)
    for(int j=0;j<11;j++)
      cin>>p[i][j];

  dfs();

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
	if(n<=1)return false;
	if(n<=3)return true;
	if(n%2==0||n%3==0)return false;
	for(ll i=5;i*i<=n;i+=6)
	{
		if(n%i==0||n%(i+2)==0)return false;
	}
	return true;
}

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)r=(r*a)%m;
		b = b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

ll addmod(ll a,ll b)
{
    if(a+b<mod)return a+b;
    else return a+b-mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll modinv(ll a)
{
    return modexp(a,mod-2,mod);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s; cin>>s;
	if(s[2]==s[3]&&(s[4]==s[5]))cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}
/*
6
1 2 3 4 5 -6
*/


Measured memory_bytes: 256
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

ans = 0
A = [int(i) for i in readline().split()]

print("%d %d %.10f" % (A[0] // A[1], A[0] % A[1], A[0] / A[1]))



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

ll N, K;
ll p[3];
string T;
vector<ll> t, ans;

int main(){
    cin >> N >> K >> p[0] >> p[1] >> p[2] >> T;
    t.resize(N);
    ans.resize(N);
    rep(i, N){
        switch (T[i]){
        case 'r': t[i] = 0; break;
        case 's': t[i] = 1; break;
        case 'p': t[i] = 2; break; 
        }
    
        if (i < K){
            //win
            ans[i] = (t[i]+2)%3;
        }
        else if (ans[i-K] != (t[i]+2)%3)
        {
            //win
            ans[i] = (t[i]+2)%3;
        }
        else
        {
            //lose
            ans[i] = -1;
        }
        
    }

    ll score = 0;
    rep(i,N){
        if (ans[i] != -1)
        {
            score += p[ans[i]];
        }
        
    }

    cout << score << endl;
}

Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 998244353;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll N, v[101010], w[101010];

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

ll solve(){
    if(v[1] != 0)return 0;
    if(w[0] > 1)return 0;
    for(ll i = 1; i <= N; i++){
        if(w[i] && w[i - 1] == 0)return 0;
    }
    ll res = 1;
    for(ll i = 1; w[i]; i++){
        ll tmp = mod_pow(w[i - 1], w[i], MOD);
        res = res * tmp % MOD;
    }
    return res;
}

int main(){

    cin >> N;
    rep1(i, N){
        cin >> v[i];
        w[v[i]]++;
    }
    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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 vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll N,ans=0;
ll A[202020];
ll B[202020];
ll C[606060];

int main(){
  cin>>N;
  REP(i,N) cin>>A[i];
  REP(i,N) cin>>B[i];
  
  REP(i,29){
    REP(j,N) C[j]=B[j]&((1<<(i+1))-1);
    sort(C,C+N);
    REP(j,2*N) C[N+j]=C[j]+(1<<(i+1));
    
    ll cnt=0;
    REP(j,N){
      ll k=A[j]&((1<<(i+1))-1);
      cnt+=lower_bound(C,C+3*N,(4<<i)-k)-lower_bound(C,C+3*N,(3<<i)-k);
    }
    if(cnt%2) ans+=(1<<i);
  }
  
  cout<<ans<<endl;
  return 0;
}

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

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int N_MAX = 100010;
vector<int> DP(N_MAX, INF);

int main() {
    DP[0] = 0;
    DP[1] = 1;
    int N;
    cin >> N;
    FOR(i, 1, N + 1) {
        DP[i] = min(DP[i], DP[i - 1] + 1);
        // div6
        int div6x = 6;
        while ((i-div6x)>=0) DP[i]=min(DP[i],DP[i-div6x]+1),div6x*=6;
        // div6
        int div9x = 9;
        while ((i-div9x)>=0) DP[i]=min(DP[i],DP[i-div9x]+1),div9x*=9;
        // cout << "i: " << i << "DP: " << DP[i] << endl;
    }
    cout << DP[N] << endl;
    return 0;
}


Measured memory_bytes: 640
require 'matrix'

$<.readlines.map {|l| l.split(",").map(&:to_f)}.each do |x1, y1, x2, y2, xq, yq|
  p1 = Vector[x1, y1]
  n  = Vector[y2 - y1, x1 - x2].normalize
  q  = Vector[xq, yq]
  d = (p1 - q).dot(n)
  r = q + (2 * d) * n
  printf "%.6f %.6f\n", r[0], r[1]
end


Measured memory_bytes: 7176
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(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--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

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

  vector<int> ans;
  while(true) {
      int w, h;
      cin >> w >> h;
      if(w == 0 && h == 0) break;

      int c[h][w];
      bool reached[h][w];
      rep(i, 0, h) rep(j, 0, w) {
          cin >> c[i][j];
          reached[i][j] = false;
      }

      int rsl = 0;
      rep(y, 0, h) {
          rep(x, 0, w) {
              if(c[y][x] == 0) continue;
              if(reached[y][x]) continue;

              rsl++;
              stack<pair<int, int> > s;
              s.push(make_pair(x, y));
              reached[y][x] = true;
              while(!s.empty()) {
                  pair<int, int> p = s.top();
                  s.pop();
                  rep(i, 0, 8) {
                      int nx = p.first + dx[i], ny = p.second + dy[i];
                      if(!(0 <= nx && nx < w && 0 <= ny && ny < h)) continue;
                      if(c[ny][nx] == 0) continue;
                      if(reached[ny][nx]) continue;

                      reached[ny][nx] = true;
                      s.push(make_pair(nx, ny));
                  }
              }
          }
      }
      ans.push_back(rsl);
  }
  rep(i, 0, ans.size()) cout << ans[i] << endl;

}



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

int d[5555];
int main() {
    int k, q;
    cin >> k >> q;
    for(int i = 0; i < k; i++)
        cin >> d[i];
    for(int i = 0; i < q; i++) {
        long n, x, m, y = 0;
        cin >> n >> x >> m;
        x %= m;
        for(int j = 0; j < k; j++) {
            int t = d[j] % m;
            y += t ? t : m;
        }
        x += (n - 1) / k * y;
        for(int j = 0; j < (n - 1) % k; j++) {
            int t = d[j] % m;
            x += t ? t : m;
        }
        cout << n - 1 - x / m << '\n';
    }
    cout << flush;
    return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n,c=1,ans=0,a[1<<19];
  	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i*3];
		a[i*3+1]=a[i*3]+1;
		a[i*3+2]=a[i*3]-1;
	}
	sort(a,a+n*3);
	for(int i=1;i<n*3;i++)
	{
		if(a[i]==a[i-1])c++;
		else
		{
			ans=max(c,ans);
			c=1;
		}
	}
	cout<<max(c,ans)<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        rep(i, n) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) return x;
        int r = root(par[x]);
        diff_weight[x] += diff_weight[par[x]];
        return par[x] = r;
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

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

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    int n, k, l; cin >> n >> k >> l;
    UnionFind<int> r(n), t(n);
    rep(i, k) {
        int p, q; cin >> p >> q; p--; q--;
        r.merge(p, q, 0);
    }
    rep(i, l) {
        int r, s; cin >> r >> s; r--; s--;
        t.merge(r, s, 0);
    }
    map<pair<int, int>, int> mp;
    vector<pair<int, int>> v(n);
    rep(i, n) {
        pair<int, int> p = make_pair(r.root(i), t.root(i));
        mp[p]++;
        v[i] = p;
    }
    rep(i, n) cout << mp[v[i]] << ' ';
    cout << endl;
}


Measured memory_bytes: 20376
/* author   : mpily :-()
title : Competing.cpp
time :Sat Nov 23 11:34:34 2019

*/
#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
long long inverses[1000003];
long long power(long long a,long long ex){
	if(ex == 0)return 1;
	else{
		long long pw = (power(a,ex/2))%mod;
		pw = (pw*pw)%mod;
		if(ex%2)pw*=a;
		pw %=mod;
		return pw;
	}
}
void init(){
	for (int i = 1; i < 1000001; i++){
		inverses[i] = power(i,mod-2);
	}
}
void findposs(int s, int x){
	long long ans1 = 1;
	long long ans2 = 1;
	long long ans3 = 1;
	long long ans = 1;
	for(int i = s; i > 1; i--){
		ans1*=i;
		ans1%=mod;
	}
	for(int i = x; i > 0; i--){
		ans2*=i;
		ans2%=mod;
	}
	for(int i = 1; i <= s-x; i++){
		ans3*=i;
		ans3%=mod;
	}
	ans*=ans1;
	ans*=(power(ans2,mod-2));
	ans%=mod;
	ans*=(power(ans3,mod-2));
	ans%=mod;
	cout<<ans<<"\n";
}
int main(){
	
	int X,Y;
	cin>>X>>Y;
	if((X+Y)%3)cout<<0<<"\n";
	else{
		int r = (2*X-Y)/3;
		int m = (2*Y-X)/3;
		//cout<<s<<" "<<r<<"\n";
		if(m < 0){
			cout<<0<<"\n";
		}
		else if(r < 0){
			cout<<0<<"\n";
		}
	
		else findposs(m+r,r);
	}	
	return 0;
}


Measured memory_bytes: 256
-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU
 
-- 解説読後
-- http://agc004.contest.atcoder.jp/data/agc/004/editorial.pdf

import qualified Data.ByteString.Char8 as C
import Data.Array (listArray, accumArray, (!))
 
main = print . solve .map red . C.words =<< C.getContents
    where
        red x = case C.readInteger x of Just v -> fst v

solve (n:x:a) = ans where
    ans = f (n - 1) (sum a) a x
    f 0 r _ _ = r
    f c r ar xx = f (c - 1) r2 ar2 (xx + x) where
        ar2 = zipWith min a $ [last ar] ++ ar
        r2 = min r (xx + sum ar2)


Measured memory_bytes: 1276
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int k;
	cin >> k;
	int k2 = 0, k3 = 0;
	rep(i, k)
		if(i%2 == 0)
			k2++;
		else
			k3++;
	cout << k2 * k3 << endl;
}

Measured memory_bytes: 256
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

constexpr int MAX_V = 100000;
constexpr int MAX_N = 50000;

typedef pair<int, int> D; // dist, change
typedef tuple<D, int, int> P; // D, rail, pos
typedef pair<int, int> edge; // to, cost
#define to first
#define cost second

vector<int> p[MAX_N];
vector<int> t[MAX_N];
vector<D> dist[MAX_N];

bool visited[MAX_V];
set<pair<int, int>> S[MAX_V];
unordered_map<string, int> converter;

inline int input_station() {
	string station_name;
	cin >> station_name;

	if(!converter.count(station_name)) {
		converter.insert({station_name, converter.size()});
	}

	return converter[station_name];
}

string dijkstra(int s, int g, int T) {
	memset(visited, false, sizeof(visited));
	priority_queue<P, vector<P>, greater<P>> que;

	for(const auto &e : S[s]) {
		dist[e.first][e.second] = {0, 0};
		que.push(make_tuple(D(0, 0), e.first, e.second));
	}

	while(!que.empty()) {
		D d;
		int r, q;
		tie(d, r, q) = que.top();
		que.pop();

		if(dist[r][q] < d) continue;

		const int v = p[r][q];

		if(v == g) return to_string(d.first) + " " + to_string(d.second);

		if(!visited[v]) {
			for(const auto &e : S[v]) {
				const D next_dist(d.first + T, d.second + 1);

				if(dist[e.first][e.second] > next_dist) {
					dist[e.first][e.second] = next_dist;
					que.push(make_tuple(next_dist, e.first, e.second));
				}
			}
		}

		visited[v] = true;

		if(0 < q) {
			const D next_dist(d.first + t[r][q - 1], d.second);

			if(dist[r][q - 1] > next_dist) {
				dist[r][q - 1] = next_dist;
				que.push(make_tuple(next_dist, r, q - 1));
			}
		}

		if(q < static_cast<int>(p[r].size()) - 1) {
			const D next_dist(d.first + t[r][q], d.second);

			if(dist[r][q + 1] > next_dist) {
				dist[r][q + 1] = next_dist;
				que.push(make_tuple(next_dist, r, q + 1));
			}
		}
	}

	return "-1";
}

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

	int N, T;
	cin >> N >> T;

	const int A = input_station();
	const int B = input_station();

	for(int i = 0; i < N; ++i) {
		int a;
		cin >> a;

		p[i].resize(a);
		t[i].resize(a - 1);
		dist[i].resize(a, D(INT_MAX, INT_MAX));

		for(int j = 0; j < a; ++j) {
			p[i][j] = input_station();
			S[p[i][j]].insert({i, j});
		}

		for(auto &e : t[i]) cin >> e;
	}

	cout << dijkstra(A, B, T) << endl;
}

Measured memory_bytes: 23956
#include"bits/stdc++.h"
using namespace std;
int main(){
	string s;
	cin>>s;
	bool ch=((s.substr(0,1)==s.substr(1,1) && s.substr(1,1)==s.substr(2,1))||(s.substr(2,1)==s.substr(1,1) && s.substr(3,1)==s.substr(2,1)));
	cout<<(ch ? "Yes":"No");
}

Measured memory_bytes: 256
n = int(input())

S = [1]*13
H = [1]*13
C = [1]*13
D = [1]*13

mark = [""]*n
num = [""]*n

for i in range(n):
    mark[i], num[i] = input().split()

for i in range(n):
    if mark[i] == "S":
        S[int(num[i])-1] = 0
    if mark[i] == "H":
        H[int(num[i])-1] = 0
    if mark[i] == "C":
        C[int(num[i])-1] = 0
    if mark[i] == "D":
        D[int(num[i])-1] = 0

for i in range(13):
    if S[i]:
        print("S " + str(i+1))
for i in range(13):
    if H[i]:
        print("H " + str(i+1))
for i in range(13):
    if C[i]:
        print("C " + str(i+1))
for i in range(13):
    if D[i]:
        print("D " + str(i+1))

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

 
int main(){
  ll maxx,ansx=10000000000000;
  int n;
  //double keta;
  cin>>n;
  vector<int> x(n);
  rep(i,n)cin>>x.at(i);
  for(int i=1;i<=100;i++){
      maxx=0;
      rep(j,n){
          maxx+=(x.at(j)-i)*(x.at(j)-i);
      }
      if(maxx<ansx)ansx=maxx;
  }
  cout<<ansx<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n,cnt=0;
  cin>>n;
  for (int i = 1; i <= n; ++i)
  {
    if(i%2==1){
      cnt++;
    }
  }
  cout<<(double)cnt/n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define repb(i, n) for(int i = n;i >= 0;i--)
#define reps(i, m, n) for(int i = m;i < n;i++)
#define repsb(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;

#define N 1000000

int fa[N];
int sa[N];
void cal(void){
 int cl;
 fa[0]=0;
 sa[0]=0;
 reps(i,1,N){
   fa[i]=sa[i]=i;
   reps(j,1,INF){
     cl=j*(j+1)*(j+2)/6;
     if(cl>i) break;
     fa[i]=min(fa[i],fa[i-cl]+1);
     if(cl&1)  sa[i]=min(sa[i],sa[i-cl]+1);
   }
 }
}
int main(int argc, char const *argv[]) {
 cal();
 int t;
 while (true) {
   cin>>t;
   if(t==0)  break;
   printf("%d %d\n",fa[t],sa[t] );
 }
 return 0;
}



Measured memory_bytes: 10804
fn read() -> i32 {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let n = input.trim().parse().unwrap();
    n
}

fn main() {
    let n = read();
    let a = read();
    if (n % 500) <= a {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll mod = 1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll ans = 1;
	for(int i = 1; i <= n; i++){
		ans = (ans * i) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    string s = ReadStr();
    int year = int.Parse(s.Substring(0, 4));
    int month = int.Parse(s.Substring(5, 2));
    int day = int.Parse(s.Substring(8, 2));
    if (year >= 2019 && month > 4) {
      Console.WriteLine("TBD");
    } else {
      Console.WriteLine("Heisei");
    }
  }

  private static string ReadStr() { return Console.ReadLine(); }
  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  private static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13140
import sys
from heapq import heappop, heappush
#input = sys.stdin.readline

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def graphm():
    n=inp()
    g=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b,w=inpm()
        a-=1
        b-=1
        g[a].append((b,w))
        g[b].append((a,w))
    return n,g


def main():
    s=input()
    n=len(s)
    i_l = 0
    i_r = n-1
    cnt = 0
    flag = False
    while True:
        if i_l >= i_r:
            if i_l == i_r:
                flag = True
            if flag:
                print(cnt)
                return
            else:
                print(-1)
                return
        if s[i_l] == s[i_r]:
            i_l += 1
            i_r -= 1
            flag = True
        elif s[i_l] == 'x' and s[i_r] != 'x':
            cnt += 1
            i_l +=1
            flag = False
        elif s[i_l] != 'x' and s[i_r] == 'x':
            cnt += 1
            i_r -=1
            flag = False
        elif s[i_l] != 'x' and s[i_r] != 'x' and s[i_l] != s[i_r]:
            print(-1)
            return

if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
	int n, q; cin >> n >> q;
	vector<double> x(n), y(n), z(n), r(n);
	vector<long long> l(n);
	for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
	for (int i = 0; i < q; ++i) {
		long long ans = 0;
		double sx, sy, sz, dx, dy, dz;
		cin >> sx >> sy >> sz >> dx >> dy >> dz;
		double sdx = dx - sx, sdy = dy - sy, sdz = dz - sz;
		for (int j = 0; j < n; ++j) {
			double tmp = sdx * (x[j] - sx) + sdy * (y[j] - sy) + sdz * (z[j] - sz);
			tmp = tmp / (sdx * sdx + sdy * sdy + sdz * sdz);
			if (tmp > 1 || tmp < 0) continue;
			double ohx = sx + tmp * sdx, ohy = sy + tmp * sdy, ohz = sz + tmp * sdz;
			double ahx = x[j] - ohx, ahy = y[j] - ohy, ahz = z[j] - ohz;
			double dis2 = ahx * ahx + ahy * ahy + ahz * ahz;
			if (dis2 < r[j] * r[j] + 1e-9) ans += l[j];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
#define N 2005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, k, c[N][N];
int main()
{
	ll i, j;
	cin >> n >> k;
	n -= k;
	for (i = 0; i < N; i++) {
		c[i][0] = 1;
		for (j = 1; j <= i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % M;
	}
	for (i = 1; i <= k; i++) {
		printf("%lld\n", c[k - 1][i - 1] * c[n + 1][i] % M);
	}
    return 0;
}

Measured memory_bytes: 30208
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn get_min(a_num: u64, target: u64) -> u64 {
    target
}

fn get_max(a_num: u64, target: u64) -> u64 {
    target + a_num - 1
}

fn main() {
    let _: usize = read();
    let mut a = read_vec::<u64>();
    a.reverse();
    let mut target_min = 2u64;
    let mut target_max = 2u64;

    for a_num in a {
        target_max = (target_max / a_num) * a_num;
        if target_min % a_num == 0 {
            target_min = (target_min / a_num) * a_num;
        } else {
            target_min = (target_min / a_num + 1) * a_num;
        }
        if target_max < a_num || target_max < target_min {
            println!("-1");
            return;
        }
        target_min = get_min(a_num, target_min);
        target_max = get_max(a_num, target_max);
        // println!("{:?}", (target_min, target_max));
    }
    println!("{0} {1}", target_min, target_max);
}


Measured memory_bytes: 8444
#include <iostream>

using namespace std;

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

    int res = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;

        if (h >= k) {
            res++;
        }
    }

    cout << res << endl;
}


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

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(){}
    Segtree(int n_input, Func f_input, T e_input){
        initialize(n_input, f_input, e_input);
    }
    void initialize(int n_input, Func f_input, T e_input){
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k){
        return dat[k+n-1];
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int N, E, T, X[100001];
    cin >> N >> E >> T;
    X[0] = 0;
    for(int i=1; i<=N; i++) cin >> X[i];

    const int64_t INF = 1e18;
    Segtree<int64_t> dp(N+1, [](int64_t a, int64_t b){ return min(a, b);}, INF);
    Segtree<int64_t> sub(N+1, [](int64_t a, int64_t b){ return min(a, b);}, INF);
    dp.update(0, 0);
    sub.update(0, -2*X[1]);

    int pt = 0;
    for(int i=1; i<=N; i++){
        while(T < 2*(X[i] - X[pt+1])) pt++;
        int64_t result = INF;
        if(pt < i) chmin(result, dp.between(pt, i-1) + T);
        if(pt > 0) chmin(result, sub.between(0, pt-1) + 2*X[i]);
        dp.update(i, result);
        if(i < N) sub.update(i, result - 2*X[i+1]);
    }
    int64_t ans = dp.get(N) + E;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string b[n];
	for(int i=0;i<n;i++) cin>>b[i];
	
	int m;
	cin>>m;
	string r[m];
	for(int i=0;i<m;i++) cin>>r[i];
	
	int ans=0;
	for(int i=0;i<n;i++)
    {
    	string word=b[i];
    	int count=0;
    	for(int j=0;j<n;j++)
           if(word==b[j]) count++;
           
        for(int j=0;j<m;j++)
           if(word==r[j]) count--;
           
        ans=max(ans,count);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
typedef long long int ll;
const double pi = 3.14159265358979323846;

int main() {
    fast
    //test
    {
        int i,j,n,l;
        cin >> n;
        cin >> l;
      	vector<string>s;
      for(i=0;i<n;i++)
      {
        string x;
        cin>>x;
        s.push_back(x);
      }
      sort(s.begin(),s.end());
      for(i=0;i<n;i++)
      {
        cout<<s[i];
      }
    }
	return 0;
}


Measured memory_bytes: 256
#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);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0){
            Alice += a.at(i);
        }else{
            Bob += a.at(i);
        }
    }
    int dif = Alice - Bob;
    cout << dif << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-10;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int n;
vector<int> a;
double dp[400][400][400];

double dfs(int i, int j, int k) {
    if(dp[i][j][k] >= 0) {
        return dp[i][j][k];
    }
    double res = n;
    if(i >= 1) {
        res += dfs(i - 1, j, k) * i;
    }
    if(j >= 1) {
        res += dfs(i + 1, j - 1, k) * j;
    }
    if(k >= 1) {
        res += dfs(i, j + 1, k - 1) * k;
    }
    res /= (double)(i + j + k);
    return dp[i][j][k] = res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(dp, -1, sizeof(dp));
    cin >> n;
    a.resize(n);
    int p = 0, q = 0, r = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] == 1) {
            p++;
        } else if(a[i] == 2) {
            q++;
        } else {
            r++;
        }
    }
    dp[0][0][0] = 0;
    cout << fixed << setprecision(15);
    cout << dfs(p, q, r) << endl;
}

Measured memory_bytes: 500352
N = int(input())
for i in range(N):
    a = [int(n) for n in input().split()]
    b = []
    c = []
    jurge = "YES"
    for n in a:
        if len(b) == 0\
        or b[len(b)-1] < n:
            b.append(n)
        elif len(c) == 0\
        or c[len(c)-1] < n:
            c.append(n)
        else:
            print("NO")
            jurge = "NO"
            break
    if jurge == "YES":
        print("YES")

Measured memory_bytes: 7624