akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;

template<typename T>
void max_self(T& a, T b)
{
	a = max(a, b);
}
int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	cin >> n;
	vd p(n);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	vvd dp(n + 1, vd(n + 1));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			if (j == 0)
				dp[i][j] = (1 - p[i - 1]) * dp[i - 1][j];
			else
				dp[i][j] = p[i - 1] * dp[i - 1][j - 1] + (1 - p[i - 1]) * dp[i - 1][j];
		}
	}
	double res = 0;
	for (int i = n / 2 + 1; i <= n; i++)
		res += dp[n][i];
	cout << res;
	return 0;
}

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

using namespace std;

int main() {
    int n, k;

    cin >> n >> k;

    vector<int> d(k);
    vector<vector<int>> a(k, vector<int>(n));

    for(int i = 0; i < k; ++i) {
        cin >> d.at(i);
        for(int j = 0; j < d.at(i); ++j) {
            cin >> a.at(i).at(j);
        }
    }

    set<int> s;

    for(int i = 0; i < k; ++i) {
        for(int j = 0; j < d.at(i); ++j) {
            s.insert(a.at(i).at(j));
        }
    }    

    printf("%d\n", n - s.size());

    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10, MAXN = 6e3 + 20;
int mod, n, ans, add2[N], add3[N], fc[MAXN], ifc[MAXN];
int power(int a, int b) {
	int rtr = 1;
	for (; b > 0; b /= 2) {
		if (b & 1)
			rtr = 1ll * rtr * a % mod;
		a = 1ll * a * a % mod;
	}
	return rtr;
}
int ch(int x, int y) {
	if (x > y)
		return 0;
	return 1ll * fc[y] * ifc[x] % mod * ifc[y - x] % mod;
}
void Pre() {
	fc[0] = ifc[0] = 1;
	for (int i = 1; i < MAXN - 4; i++)
		fc[i] = 1ll * fc[i - 1] * i % mod, ifc[i] = power(fc[i], mod - 2);
	add3[0] = 1;
	add2[0] = 1;
	for (int i = 1; i < N - 7; i++) {
		add2[i] = 1ll * add2[i - 1] * ch(2, 2 * i) % mod * power(i, mod - 2) % mod;
		add3[i] = 1ll * add3[i - 1] * ch(3, 3 * i) % mod * 2 % mod * power(i, mod - 2) % mod;;
	}
	return;
}
int main() {
	cin >> n >> mod;
	Pre();
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int k = 3 * n - 3 * i - 2 * j;
			if (k < j)
				continue;
			int rtr = (1ll * ch(i * 3, 3 * n) * add3[i] % mod * ch(j * 2, 3 * n - i * 3) % mod * add2[j] % mod) % mod;
//			cout << "i = " << i << " j = " << j << " : " << rtr << endl;
			ans = (ans + rtr) % mod;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import math
H,W,K=map(int,input().split())

A=[]
S=[0,0]
for i in range(H):
    a=list(input())
    for j in range(W):
        if a[j]=="S":
            S=[i,j]
    A.append(a)

#print(A)
#print(S)
import sys
input=sys.stdin.readline
B=[[1000 for j in range(W)]for i in range(H)]

B[S[0]][S[1]]=0
ans=min(S[0],S[1],W-1-S[1],H-1-S[0])
#print(ans)
Q=[[0,S[0],S[1]]]


for i in range(10**6):
    if i==len(Q):
        break
    else:
        for j in range(1):
            if Q[i][1]>0 and B[Q[i][1]-1][Q[i][2]]==1000 and B[Q[i][1]][Q[i][2]]<K and A[Q[i][1]-1][Q[i][2]]==".":
                Q.append([Q[i][0]+1,Q[i][1]-1,Q[i][2]])
                B[Q[i][1]-1][Q[i][2]]=B[Q[i][1]][Q[i][2]]+1
                if ans>min(Q[i][1]-1,Q[i][2],H-1-(Q[i][1]-1),W-1-(Q[i][2])):
                    ans=min(Q[i][1]-1,Q[i][2],H-1-(Q[i][1]-1),W-1-(Q[i][2]))
                    
            if Q[i][2]>0 and B[Q[i][1]][Q[i][2]-1]==1000 and B[Q[i][1]][Q[i][2]]<K and A[Q[i][1]][Q[i][2]-1]==".":
                Q.append([Q[i][0]+1,Q[i][1],Q[i][2]-1])
                B[Q[i][1]][Q[i][2]-1]=B[Q[i][1]][Q[i][2]]+1
                if ans>min(Q[i][1],Q[i][2]-1,H-1-(Q[i][1]),W-1-(Q[i][2]-1)):
                    ans=min(Q[i][1],Q[i][2]-1,H-1-(Q[i][1]),W-1-(Q[i][2]-1))
                    
            if Q[i][1]<H-1 and B[Q[i][1]+1][Q[i][2]]==1000 and B[Q[i][1]][Q[i][2]]<K and A[Q[i][1]+1][Q[i][2]]==".":
                Q.append([Q[i][0]+1,Q[i][1]+1,Q[i][2]])
                B[Q[i][1]+1][Q[i][2]]=B[Q[i][1]][Q[i][2]]+1
                if ans>min(Q[i][1]+1,Q[i][2],H-1-(Q[i][1]+1),W-1-(Q[i][2])):
                    ans=min(Q[i][1]+1,Q[i][2],H-1-(Q[i][1]+1),W-1-(Q[i][2]))
                    
            if Q[i][2]<W-1 and B[Q[i][1]][Q[i][2]+1]==1000 and B[Q[i][1]][Q[i][2]]<K and A[Q[i][1]][Q[i][2]+1]==".":
                Q.append([Q[i][0]+1,Q[i][1],Q[i][2]+1])
                B[Q[i][1]][Q[i][2]+1]=B[Q[i][1]][Q[i][2]]+1
                if ans>min(Q[i][1],Q[i][2]+1,H-1-(Q[i][1]),W-1-(Q[i][2]+1)):
                    ans=min(Q[i][1],Q[i][2]+1,H-1-(Q[i][1]),W-1-(Q[i][2]+1))
#print(B)
#print(ans)
print(math.ceil(ans/K)+1)

Measured memory_bytes: 148468
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
 	int n, m, mini = MOD, maxi = 0;
 	cin >> n >> m;
 	for (int i = 0; i < m; i++){
 		int l, r;
 		cin >> l >> r;
 		maxi = max(maxi, l);
 		mini = min(mini, r);
 	}
 	if (maxi > mini) cout << 0 << endl;
 	else cout << mini - maxi + 1 << endl;
 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define cast static_cast
#define vi vector<int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n,k;
	cin>>n>>k;
	vi a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vi dp(k+1);
	for(int i=0;i<=k;i++){
		if(i==0){
			dp[i]=2;
		}
		else{
			int pos=0;
			for(int j=0;j<n && a[j]<=i;j++){
				if(dp[i-a[j]]==2){
					pos=1;
					break;
				}
			}
			if(pos){
				dp[i]=1;
			}
			else{
				dp[i]=2;
			}
		}
	}
	if(dp[k]==1){
		cout<<"First\n";
	}
	else{
		cout<<"Second\n";
	}
}	

int main(){
	boost_io;
	cout<<setprecision(10);
	solve();
	return 0;
}


Measured memory_bytes: 3720
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#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 REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	string o,e;
	cin >> o >> e;

	rep(i,o.size()){
		cout << o[i];
		if(i < e.size())cout << e[i];
	}
	cout << endl;
	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc058.contest.atcoder.jp/tasks/abc058_b

Measured memory_bytes: 3612
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int gcd(int a,int b){
	int tmp;
	if (b<a) tmp=a,a=b,b=tmp;
	if (a==0) return b;
	else return gcd(a,b%a);
}
int main(){
	int n,chi;
	cin>>n>>chi;
	vector<int>x(n);
	int tmp;
	rep(i,n){
		cin>>tmp;
		x[i]=abs(tmp-chi);
	}
	//rep(i,n) cout<<x[i]<<" ";
	int ans=x[0];
	//cout<<ans<<" ";
	rep(i,n-1) ans=gcd(ans,x[i+1]);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
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 read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n : String = read();
    let v: Vec<i32> =n.chars().map(|x| x as i32).collect();
    if v[0] == v[1] && v[1] == v[2] {
        println!("Yes");
    } else if v[1] == v[2] && v[2] == v[3] {
        println!("Yes");
    } else{
        println!("No");
    }
}   

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
vector <long long> v;
long long a=1,b; 
int main()
{
	int n,i,j=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin >> b;
		v.push_back(b);
	}
	sort(v.begin(),v.end(),greater<int>());
	
	for(i=0;i<v.size();i++)
	{
		if(v[i]==v[i-1])
		{
			++j;
		a*=v[i];
		if(j==2) break;
		++i;
}
	}
	if(j==2) 
	cout << a;
	else
	cout << 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	string s; cin >> s;
	if (s == "AAA" || s == "BBB") cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define gcd __gcd
ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


struct hash_pair {
   template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};

ll rec(ll a[],ll first,ll last,int n)
{
  if(first>last)
    return 0;

  ll temp=1000000000;
  ll ind=0;
  for(ll i=first;i<=last;i++)
   {
    if(temp>a[i])
    {
      temp=a[i];
      ind=i;
    }
   }
   for(ll i=first;i<=last;i++)
    a[i]-=temp;


return min(last-first+1,(rec(a,first,ind-1,n)+rec(a,ind+1,last,n)+temp));

}
int temp[1000002]={0};

void sieve()
{
  temp[1]=1;
  for(int i=2;i<1000002;i++)
  {
    if(temp[i]==0)
    { temp[i]=i;
      for(int j=i*2;j<1000002;j+=i)
      { 
        if(temp[j]==0)
        temp[j]=i;
      }
    }
  }

}


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

if(n%1000==0)
  cout<<0;
else
  cout<<1000-n%1000;



return 0;
}


Measured memory_bytes: 3496
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
int maxL[20][200005], maxR[20][200005];
int p_L, p_R;
int dpL[(1<<20)], dpR[(1<<20)]; // dpL prefix, dpR suffix
int N, V;
ll x[200005];
int BIT[200005]; // indexes are reversed
int parts[200005];
vector <pii> dp_range;

int calc_dpL(int mask) {
	if (mask == 0) return 0;
	int &ret = dpL[mask];
	int tmp;
	if (ret != -1) return ret;
	ret = 0;
	for (int i=0;i<20;++i) {
		if (mask&(1<<i)) {
			if (calc_dpL(mask - (1<<i)) == N) ret = N;
			else {
				tmp = calc_dpL(mask-(1<<i));
				tmp = maxR[i][tmp] - tmp + 1;
				ret = max(ret,tmp + calc_dpL(mask-(1<<i)));
			}
		}
	}
	return ret;
}

int calc_dpR(int mask) {
	//cout << mask << endl;
	if (mask == 0) return 0;
	int &ret = dpR[mask];
	int tmp;
	if (ret != -1) return ret;
	ret = 0;
	for (int i=0;i<20;++i) {
		if (mask&(1<<i)) {
			if (calc_dpR(mask - (1<<i)) == N) ret = N;
			else {
				tmp = (N-1) - calc_dpR(mask-(1<<i));
				tmp = tmp - maxL[i][tmp] + 1;
				ret = max(ret,tmp + calc_dpR(mask-(1<<i)));
			}
		}
	}
	return ret;
}

bool cmp(pii a, pii b) {
	return a.se < b.se;
}

int BIT_q(int u) {
	++u;
	int ret = -1;
	while (u) {
		ret=max(ret,BIT[u]);
		u-=u&(-u);
	}
	return ret;
}

void BIT_u(int u,int val) {
	++u;
	for (;u<200005;u+=u&(-u)) BIT[u]=max(BIT[u],val);
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	memset(dpL,-1,sizeof(dpL));
	memset(dpR,-1,sizeof(dpR));
	memset(BIT,-1,sizeof(BIT));
	parts[0]=1;
	for (int i=1;i<200005;++i) {
		parts[i] = 1+parts[i>>1];
	}
	cin >> N >> V;
	for (int i=0;i<N;++i)
		cin >> x[i];
	for (int i=0;i<20;++i) {
		for (int j=N;j>=0;--j) {
			maxR[i][j]=j;
			if ( j+1 < N && x[j+1]-x[j] <= (V>>i) ) maxR[i][j] = maxR[i][j+1];
		}
	}
	for (int i=0;i<20;++i) {
		for (int j=0;j<=N;++j) {
			maxL[i][j]=j;
			if ( j-1 >= 0 && x[j]-x[j-1] <= (V>>i) ) maxL[i][j] = maxL[i][j-1];
		}
	}
	int mask_r;
	for (int mask_l=0;mask_l<(1<<parts[V]);mask_l+=2) {
		mask_r = ((1<<parts[V]) - 1) - mask_l - 1;
		dp_range.push_back(make_pair(calc_dpL(mask_l),calc_dpR(mask_r)));
	}
	sort(dp_range.begin(), dp_range.end(), cmp);
	for (int i=0;i<(int)dp_range.size();++i) {
		BIT_u(N - dp_range[i].fi,dp_range[i].se);
	}
	for (int i=0;i<N;++i) {
		p_L = maxL[0][i];
		p_R = maxR[0][i];
		if (BIT_q(N - p_L) >= N-(p_R+1)) cout << "Possible\n";
		else cout << "Impossible\n";
	}
	return 0;
}

Measured memory_bytes: 47216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

int main() {
  int X,Y;
  cin >> X >> Y;

  cout << X+Y/2 << endl;

  return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 998244353ll;
const ll MAXN = (ll) 1e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

ll h[MAXN];
ll dp[MAXN];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for(int i = 2;i<n;i++){
		dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
	}
	cout << dp[n-1];

	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] nums = new int[N];
		long sum = 0;
		int max =0;
		for (int i = 0; i < N; i++) {
			nums[i] = sc.nextInt();
			max = Math.max(max, nums[i]);
		}

		int[] nums2 = Arrays.copyOf(nums, N);;
		Arrays.sort(nums2);
		int max2 = nums2[N-2];

		for (int i = 0; i < N; i++) {
			if (nums[i] != max) {
				System.out.println(max);
			} else {
				System.out.println(max2);
			}
		}


	}
}




Measured memory_bytes: 61388
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


int main(){
    int N;
    cin >> N;
    string S[N];
    map<string, int> mp;
    for(int i=0;i<N;i++){
        cin >> S[i];
        mp[S[i]]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}


Measured memory_bytes: 6720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		String s = kb.next();
		int count = 0;
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - i - 1))
				count += 1;
		}

		System.out.println(count);
		kb.close();
	}

}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if (s=="Rainy") cout<<"Sunny"<<endl;
    else cout<<"Rainy"<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = []
for i in range(n):
    a, b = map(int, input().split())
    a_list.append([a,b])

new_list = sorted(a_list, key = lambda x: x[1])

def detect(alist):
  time = 0
  for item in alist:
      time += item[0]
      if time > item[1]:
        return "No"
  return "Yes"

print(detect(new_list))


Measured memory_bytes: 39688
#include<stdio.h>

int main(){
  int n = 0;
  int k = 0;
  int h[100000] = {};
  int i = 0;
  int cnt = 0;
  scanf("%d",&n);
  scanf("%d",&k);
  for(i = 0;i < n;i++){
    scanf("%d",&h[i]);
  }
  for(i = 0;i < n;i++){
    if(h[i] >= k){
      cnt++;
    }
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn = 300010;
const int maxm = 800010;
const int inf  = 0x3f3f3f3f;
 
int n,m,tol,head[maxn];
struct edge
{
    int to,cost,next;
}es[maxm];
 
void addedge( int u , int v , int w )
{
    es[tol].to = v;
    es[tol].cost = w;
    es[tol].next = head[u];
    head[u] = tol++;
}
 
struct mess
{
    int from,to,cost;
    friend bool operator<( const mess&a , const mess&b )
    {
        return a.cost<b.cost;
    }
}data[maxm>>2];
 
int dis[maxn],vis[maxn],used[maxm>>3],pre[maxm>>3],id[maxm>>3],sizes;
 
int Find( int x )
{
    if ( x!=pre[x] )
        pre[x] = Find( pre[x] );
    return pre[x];
}
 
void Build( int l , int r )
{
    for ( int i=l ; i<=r ; i++ )
    {
        int u = data[i].from;
        int v = data[i].to;
        used[u] = used[v] = 0;
        pre[u] = u,pre[v] = v;
        id[u] = id[v] = -1;
    }
    for ( int i=l ; i<=r ; i++ )
    {
        int u = data[i].from;
        int v = data[i].to;
        int fx = Find(u);
        int fy = Find(v);
        if ( fx!=fy )
            pre[fy] = fx;
    }
    for ( int i=l ; i<=r ; i++ )
    {
        int u = data[i].from;
        int v = data[i].to;
        int fx = Find( u );
        int fy = Find( v );
        if ( !used[u] )
        {
            if ( id[fx]==-1 )
                id[fx] = ++sizes;
            addedge( u , id[fx] , 1 );
            addedge( id[fx] , u , 1 );
        }
        if ( !used[v] )
        {
            if ( id[fy]==-1 )
                id[fy] = ++sizes;
            addedge( v , id[fy] , 1 );
            addedge( id[fy] , v , 1 );
        }
    }
}
 
struct node
{
    int pos,dis;
    friend bool operator<( const node&a , const node&b )
    {
        return a.dis>b.dis;
    }
};
 
void dijkstra()
{
    priority_queue<node>Q;
    node p;
    p.pos = 1;
    p.dis = 0;
    Q.push(p);
    for ( int i=1 ; i<=sizes ; i++ )
        dis[i] = inf,vis[i] = 0;
    dis[1] = 0;
    while ( !Q.empty() )
    {
        p = Q.top();
        Q.pop();
        int u = p.pos;
        if ( vis[u] )
            continue;
        vis[u] = 1;
        for ( int i=head[u] ; i!=-1 ; i=es[i].next )
        {
            int v = es[i].to,w = es[i].cost;
            if ( dis[v]>dis[u]+w )
            {
                dis[v] = dis[u]+w;
                p.pos = v;
                p.dis = dis[v];
                Q.push(p);
            }
        }
    }
}
 
int main()
{
    for ( ; scanf ( "%d%d" , &n , &m )==2 ; )
    {
        for ( int i=1 ; i<=m ; i++ )
            scanf ( "%d%d%d" , &data[i].from , &data[i].to , &data[i].cost );
        sort ( data+1 , data+m+1 );
        tol = 0;
        sizes = n;
        memset ( head , -1 , sizeof(head) );
        for ( int i=1 ; i<=m ; i++ )
        {
            int l=i,r=i;
            while ( r+1<=m&&data[r+1].cost==data[l].cost )
                r++;
            Build( l , r );
            i = r;
        }
        dijkstra();
        if ( dis[n]==inf )
            dis[n] = -2;
        printf ( "%d\n" , dis[n]>>1 );
    }
    return 0;
}


Measured memory_bytes: 17784
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int lli;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n, k, d, dk, i, j, x, z, cnt=0;
    cin >> n >> k;
    lli ara[n+7]={0};
    for(i=1; i<=k; i++){
        cin >> x;
        while(x--){
            cin >> z;
            if(ara[z]!=1) ara[z] = 1;
        }
    }
    for(i=1; i<=n; i++){
        if(ara[i]!=1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a,int b) {return a < b ? a : b; }

int main() {
  int elaps = 0,c;
  int i,q;
  P u;
 
  scanf("%d%d",&n,&q);

  for(i = 1;i <= n;i++) {
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1; tail = n + 1;

  while (head != tail) {
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }

  return 0;

}



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

const int limit = 100010;
vector<int> graph[2][limit];

void add_edge(int from, int to) {
	graph[0][from].push_back(to);
	graph[1][to].push_back(from);
}


auto scc(int n) {
	vector<int> order(n);
	iota(begin(order), end(order), 0);
	vector<int> comp;

	rep(type, 2) {
		stack<int> stk;
		vector<int> norder;
		vector<int> itr(n, 0);

		comp.assign(n, -1);
		int idx = 0;

		/*
		rep(i, n) cerr << order[i] << " ";
		cerr << endl;
		*/

		for (auto &it : order) {
			if (comp[it] != -1) continue; 
			stk.push(it);
	
			while (!stk.empty()) {
				const int v = stk.top(); 				
				comp[v] = idx;
						
				for(int &i = itr[v]; i < graph[type][v].size();++i){
					const int v2 = graph[type][v][i];
					if (comp[v2] == -1){
						stk.push(v2);
						break;
					}
				}

				if(itr[v] == graph[type][v].size()){
					norder.push_back(v);
					stk.pop();
				}
			}
			idx++;
		}

		if (type == 1) break;
		reverse(begin(norder), end(norder));
		order = norder;
	}

	return make_tuple(order, comp);
}

vector<int> order, comp;

int main(void) {
	int n, m;
	cin >> n >> m;

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		add_edge(a, b);
	}

	tie(order, comp) = scc(n);

	
	int q;
	cin >> q;
	rep(loop,q){
		int u,v;
		cin >> u >> v;
		if(comp[u]==comp[v])
			puts("1");
		else
			puts("0");
	}

	return 0;
}

Measured memory_bytes: 8560
from collections import deque
 
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9 + 7
 
P = [a for a in A if a >= 0]
N = [a for a in A if a < 0]
 
def canPositive():
    for i in range(0, len(N) + 1, 2):
        p = K - i
        if p < 0:
            break
        if len(P) >= p:
            return True
    return False

if not canPositive():
    A.sort(key=lambda a: abs(a))
    ans = 1
    for a in A[:K]:
        ans *= a
        ans %= MOD
    print(ans)
    exit()

if not P or not N or len(A) == K:
    A.sort(key=lambda a: abs(a), reverse=True)
    ans = 1
    for a in A[:K]:
        ans *= a
        ans %= MOD
    print(ans)
    exit()

P.sort(key=lambda a: abs(a))
N.sort(key=lambda a: abs(a))
P = deque(P)
N = deque(N)
 
ans = 1
sign = 1
while K > 0:
    ans %= MOD
    if ans == 0:
        break
    if K == 1:
        if sign < 0:
            ans *= N.pop()
        else:
            ans *= P.pop()
        break
 
    if len(P) >= 2 and len(N) >= 2:
        p = P[-1] * P[-2]
        n = N[-1] * N[-2]
        if p > n:
            ans *= P.pop()
            K -= 1
        else:
            ans *= N.pop() * N.pop()
            K -= 2
        continue
    if len(P) <= 1 or len(N) <= 1:
        if len(N) == 0:
            ans *= P.pop()
            K -= 1
            continue
 
        if len(P) == 0:
            ans *= N.pop()
            K -= 1
            sign *= -1
            continue
 
        if len(N) == 1:
            n = N.pop()
            if sign < 0:
                ans *= n
                K -= 1
                sign *= -1
            continue
 
        if len(P) == 1:
            p = P.pop()
            if K % 2 == 1 and sign > 0 or K % 2 == 0 and sign < 0:
                ans *= p
                K -= 1
            continue

print(ans % MOD)

Measured memory_bytes: 32440
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	long long sum = 0;
	cin >> n; 
	for(int i = 1; i <= n; i++){
		if(i % 3 == 0 || i % 5 == 0)continue;
		sum += i;
	}
	cout << sum << '\n';
}

Measured memory_bytes: 3656
//
//  main.cpp
//  ALDS1_6
//
//  Created by ptyuan on 2018/10/31.
//  Copyright © 2018 YY. All rights reserved.
//

#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
int n = 0;

void CountingSort(int *A, int *B, int k) {
    int *C = (int *)malloc(sizeof(int) * k + 1);
    for (int i = 0; i <= k; i++) {
        C[i] = 0;
    }
    
    for (int i = 1; i <= n; i++) {
        C[A[i]]++;
    }
    
    for (int i = 1; i <= k; i++) {
        C[i] += C[i - 1];
    }
    
    for (int j = n; j >= 1; j--) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    free(C);
}

int main(int argc, const char * argv[]) {
    scanf("%d", &n);
    int *A = (int *)malloc(sizeof(int) * n + 1);
    int *B = (int *)malloc(sizeof(int) * n + 1);
    int _max = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", A + i);
        _max = max(_max, A[i]);
    }
    CountingSort(A, B, _max);
    for (int i = 1; i <= n; ++i) {
        if (i > 1) {
            printf(" ");
        }
        printf("%d", *(B + i));
    }
    printf("\n");
    free(A);
    free(B);
    return 0;
}



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

int main(){
	ll n;
	cin>>n;
	ll f=0;
	for(int i=(n+104)/105;i<=(n+99)/100;i++){
		if(n>=i*100&&n<=i*105)f=1;
	}
	cout<<f;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(H: int, A: int):
    print(-(-H//A))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(H, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
/* KEYENCE string */

#include <iostream>
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
    if(s.find("keyence") != string::npos){
    	if(s.find("keyence") == 0 || s.size() - s.find("keyence") == 7){
    	    cout << "YES" << endl;
    	}else{
   		    cout << "NO" << endl;
    	}

    }else if(s.find("k") != string::npos && s.rfind("eyence") != string::npos){
    	if(s.find("k") == 0 && s.size() - s.rfind("eyence") == 6){
    	    cout << "YES" << endl;
    	}else{
   		    cout << "NO" << endl;
    	}

    }else if(s.find("ke") != string::npos && s.rfind("yence") != string::npos){
    	if(s.find("ke") == 0 && s.size() - s.rfind("yence") == 5){
    	    cout << "YES" << endl;
    	}else{
   		    cout << "NO" << endl;
    	}
    }else if(s.find("key") != string::npos && s.rfind("ence") != string::npos){
    	if(s.find("key") == 0 && s.size() - s.rfind("ence") == 4){
    	    cout << "YES" << endl;
    	}else{
   		    cout << "NO" << endl;
    	}
    }else if(s.find("keye") != string::npos && s.rfind("nce") != string::npos){
    	if(s.find("keye") == 0 && s.size() - s.rfind("nce") == 3){
    	    cout << "YES" << endl;
    	}else{
   		    cout << "NO" << endl;
    	}
    }else if(s.find("keyen") != string::npos && s.rfind("ce") != string::npos){
    	if(s.find("keyen") == 0 && s.size() - s.rfind("ce") == 2){
    	    cout << "YES" << endl;
    	}else{
   		    cout << "NO" << endl;
    	}
    }else if(s.find("keyenc") != string::npos && s.rfind("e") != string::npos){
    	if(s.find("keyenc") == 0 && s.size() - s.rfind("e") == 1){
    	    cout << "YES" << endl;
    	}else{
   		    cout << "NO" << endl;
    	}
    }else{
    	cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    int p[a], q[b], ary[x + y + c];

    repi(i, a, 0) cin >> p[i];
    repi(i, b, 0) cin >> q[i];
    repi(i, c, 0) cin >> ary[i];

    sort(p, p + a, greater<int>());
    sort(q, q + b, greater<int>());
    repi(i, x, 0) ary[c + i] = p[i];
    repi(i, y, 0) ary[c + x + i] = q[i];
    sort(ary, ary + x + y + c, greater<int>());

    // repi(i,x+y+c,0){
    //     cout << ary[i] << " ";
    // }
    // cout << endl;
    ll sum = 0;
    repi(i, x + y, 0)
    {
        sum += ary[i];
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

struct Graph {
    struct Edge {
        int u, v;
        int cost;
        Edge(int _u, int _v, int _cost) : u(_u), v(_v), cost(_cost) {}
    };
    int n, m;
    bool is_digraph;
    vector<vector<int>> g;
    vector<Edge> e;

    Graph(int _n) : n(_n), m(0) {
        assert(n >= 1);
        g.resize(n);
        set_di(false);
    }
    Graph(int _n, int _m, bool _di=false) : n(_n) {
        assert(n >= 1);
        g.resize(n);
        e.reserve(_m);
        m = 0;
        set_di(_di);
        input(_m);
    }
    void set_di(bool _di) {
        is_digraph = _di;
    }
    inline void add(int u, int v, int cost=1) {
        assert(0 <= u && u < n);
        assert(0 <= v && v < n);
        if (is_digraph) {
            //outdeg[u]++; indeg[v]++;
            g[u].emplace_back(m);

        } else {
            //deg[u]++; deg[v]++;
            g[u].emplace_back(m);
            g[v].emplace_back(m);
        }
        e.emplace_back(u, v, cost);
        m++;
    }
    void input(int _m) {
        int u, v, c;
        for (int i = 0; i < _m; i++) {
            cin >> u >> v >> c;
            u--; v--; // input 1-based
            add(u, v, c);
        }
    }
    template <typename T=int>
    vector<T> _01bfs(int s);
};

// work when cost only 0 or c
template <typename T>
vector<T> Graph::_01bfs(int s) {
    const int INF = 0x3f3f3f3f;
    vector<T> d(n, INF);
    d[s] = 0;
    deque<int> q;
    q.push_front(s);
    while (!q.empty()) {
        int u = q.front();
        q.pop_front();
        for (int i: g[u]) {
            int v = e[i].u ^ e[i].v ^ u;
            if (d[v] > d[u] + e[i].cost) {
                d[v] = d[u] + e[i].cost;
                if (e[i].cost)
                    q.push_back(v);
                else
                    q.push_front(v);
            }
        }
    }
    return d;
}
map<int, int> id[100005];
int nd_cnt = 0;
int get_id(int x, int c) {
    if (id[x].count(c)) return id[x][c];
    else return id[x][c]=nd_cnt++;
}
void solve() {
    int n,m;
    cin >> n >> m;
    Graph g(n+2*m);
    for (int i = 0; i < n; i++) {
        get_id(i, 0);
    }
    for (int _ = 0; _ < m; _++) {
        int x,y,c;
        cin >> x >> y >> c;
        x--;y--;
        int x0 = get_id(x,0);
        int y0 = get_id(y,0);
        int xc = get_id(x,c);
        int yc = get_id(y,c);
        g.add(xc, yc, 0);
        g.add(x0, yc, 1);
        g.add(xc, y0, 1);
    }
    int res = g._01bfs<>(0)[n-1];
    if (res > 3000000) res = -1;
    else res >>= 1;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 66220
#25
import itertools
N = int(input())
n = [i for i in range(1,N+1)]
p = list(map(int,input().split()))
q = list(map(int,input().split()))
cou = 0
a,b = 0,0

for i in itertools.permutations(n,N):
    cou += 1
    if p == list(i) :
        a = cou 
    if q == list(i):
        b = cou

print(abs(a-b))
        


    


Measured memory_bytes: 9168
from itertools import groupby

n,k = map(int,input().split())
s = input()

grouped = groupby(s)

res = []

if s[0] == '0':
	res.append((1,0))

for l,v in grouped:
	res.append( (l,len(list(v))) )

if s[len(s)-1] == '0':
	res.append((1,0))

now = 0
ans = 0
for i in range(min(len(res),2*k+1)):
	now += res[i][1]

ans = max(ans,now)

for i in range(2*k+1,len(res),2):
	now -= res[i-2*k-1][1]
	now -= res[i-2*k][1]

	now += res[i][1]
	now += res[i+1][1]

	ans = max(ans,now)

print(ans)



Measured memory_bytes: 16208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
int cc;
struct DSU
{
	int S;
	
	struct node
	{
		int p; ll sum;
	};
	vector<node> dsu;
	
	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	void reset(int n)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}
	
	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(rand()&1) swap(u, v);
		cc--;
		dsu[v].p = u;
		dsu[u].sum += dsu[v].sum;
	}
	
	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}
	
	ll getstat(int u)
	{
		return dsu[rt(u)].sum;
	}
};

int c[111111];
vector<pair<ll,ii> > edges;
bool used[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m,k; cin>>n>>m>>k;
	DSU dsu(k+n);
	for(int i=0;i<n;i++) {cin>>c[i]; c[i]--;}
	for(int i=0;i<m;i++)
	{
		int u,v,w; cin>>u>>v>>w; u--; v--;
		edges.pb(mp(w,mp(u,v)));
	}
	sort(edges.begin(),edges.end());
	cc=k; int U=1;
	ll ans=0;
	for(int i=0;i<edges.size();i++)
	{
		int u=edges[i].se.fi; int v=edges[i].se.se; ll w=edges[i].fi;
		if(c[u]>c[v]) swap(u,v);
		//cerr<<"EDGE : "<<u<<' '<<v<<'\n';
		if(c[u]>=0)
		{
			if(dsu.sameset(c[u],c[v])) continue;
			dsu.merge(c[u],c[v]); ans+=w;
			if(cc<=U) break;
		}
		else if(c[v]>=0) //c[u]< 
		{
			//if(used[u]) continue;
			if(dsu.sameset(k+u,c[v])) continue;
			//cerr<<u<<' '<<v<<' '<<cc<<' '<<k<<' '<<"HERE\n";
			ans+=w;
			//U++;
			dsu.merge(k+u,c[v]);
			used[u]=1;
			if(cc<=U) break;
		}
		else
		{
			//if(used[u]&&used[v]) continue;
			if(dsu.sameset(k+u,k+v)) continue;
			ans+=w;
			//U++;
			dsu.merge(k+u,k+v);
			used[u]=used[v]=1;
			if(cc<=U) break;
		}
	}
	if(cc<=U) cout<<ans<<'\n';
	else cout<<-1<<'\n';
}	


Measured memory_bytes: 10988
import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
MOD = int(1e9) + 7


if N % 2 == 0:
    ans = 1
    for i in range(N//2):
        if A[2*i] == A[2*i+1] == 2*i+1:
            ans *= 2
            ans %= MOD
        else:
            print(0)
            sys.exit()
            
else:
    if A[0] == 0:
        ans = 1
    else:
        print(0)
        sys.exit()

    for i in range(N//2):
        if A[2*i+1] == A[2*i+2] == 2*(i+1):
            ans *= 2
            ans %= MOD
        else:
            print(0)
            sys.exit()
print(ans)

    

Measured memory_bytes: 13880
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let q: usize = sc.cin();
    let h: usize = sc.cin();
    let s: usize = sc.cin();
    let d: usize = sc.cin();
    let n: usize = sc.cin();

    let mut dp = vec![1000000000; 20];
    dp[0] = 0;
    for i in 0..4 {
        dp[i + 1] = min!(dp[i + 1], dp[i] + q);
        dp[i + 2] = min!(dp[i + 2], dp[i] + h);
        dp[i + 4] = min!(dp[i + 4], dp[i] + s);
        dp[i + 8] = min!(dp[i + 8], dp[i] + d);
    }
    trace!(dp[4]);

    put!(min!(
        4 * n * q,
        2 * n * h,
        n * s,
        (n / 2) * d + dp[4 * (n % 2)]
    ));

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var ans = true
    var word = readLine()!!
    val set = mutableSetOf(word)

    repeat(n - 1) {
        val w = readLine()!!
        if (set.contains(w)) {
            ans = false
        }
        if (word.last() != w.first()) {
            ans = false
        }
        word = w
        set.add(word)
    }

    println(if (ans) "Yes" else "No")
}


Measured memory_bytes: 38064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define ll long long


int N, M, Q;
int L[200001], R[200001];
int m[502][502];

int main(){

	cin >> N >> M >> Q;

	for (int i = 0; i < M; i++){
		cin >> L[i] >> R[i];
		m[L[i]][R[i]] ++;
	}

	for (int i = 1; i <= N; i++){
		for (int j = 1; j <= N; j++){
			m[i][j] += m[i-1][j];
		}
	}

	for (int i = 1; i <= N; i++){
		for (int j = 1; j <= N; j++){
			m[i][j] += m[i][j-1];
		}
	}

	int p[100001], q[100001];
	for (int i = 0; i < Q; i++)
		cin >> p[i] >> q[i];

	for (int i = 0; i < Q; i++)
		cout << m[q[i]][q[i]] + m[p[i] - 1][p[i]-1] - m[p[i] - 1][q[i]] - m[q[i]][p[i]-1] << endl;

	return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<math.h>

int main(){
    long long S;
    long long x1, x2, x3, y1, y2, y3;
    long long i, j, k;

    scanf("%lld", &S);
    x1=0;
    y1=0;
    x2=1000000000;
    y2=1;
    x3=(x2-S%x2)%x2;
    y3=(S+x3)/x2;

    printf("%lld %lld %lld %lld %lld %lld", x1, y1, x2, y2, x3, y3);

    return 0;
}


Measured memory_bytes: 128
import math
LI = lambda: list(map(int,input().split()) )
MI = lambda: map(int,input().split())
SI = lambda: input()
II = lambda: int(input())
a,b,d = MI()
x = b//d
if int(a/d) == a/d:
    x -=a//d-1
else:
    x-=a//d
print(x)

Measured memory_bytes: 61872
import java.util.Scanner;

/**
 * http://code-festival-2017-quala.contest.atcoder.jp/tasks/code_festival_2017_quala_c
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int H = sc.nextInt();
		final int W = sc.nextInt();
		int[] alp = new int[26];
		for(int i=0; i<H; i++){
			for(char c: sc.next().toCharArray())
				alp[c-'a']++;
		}
		sc.close();
		
		int d = 0;
		int o = 0;
		for(int a:alp){
			if(a%4==1){
				o++;
			}else if(a%4==2){
				d++;
			}else if(a%4==3){
				d++;
				o++;
			}
		}
		
		boolean ans = false;
		if(W%2==0 && H%2==0){
			ans = d==0 && o==0;
		}else if(W%2==0){
			ans = d<=W/2 && o==0;
		}else if(H%2==0){
			ans = d<=H/2 && o==0;
		}else{
			ans = o<=1 && d<=(H-1)/2+(W-1)/2;
		}
		
		System.out.println(ans ? "Yes" : "No");

	}

}


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

int main() {
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3 = x2 - y2 + y1;
    y3 = y2 + x2 - x1;
    x4 = x3 - y3 + y2;
    y4 = y3 + x3 - x2;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	int a,b,c;
	cin>>a>>b;
	if(b%a==0){
		cout<<-1<<endl;
		return 0;
	}
	c=((b-1)/a+1)*a;
	if(c/b+c%b>c/a+c%a)cout<<c<<endl;
	else cout<<-1<<endl;
}



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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> x(N);
  REP(i, N){
    cin >> x[i];
  }
  ll ans = INF;
  REP(i, N-K+1){
    ll time;
    if(x[i] >= 0 || x[i+K-1] <= 0){
      time = max(abs(x[i]), abs(x[i+K-1]));
    }
    else{
      time = min(abs(x[i]), abs(x[i+K-1]))*2 + max(abs(x[i]), abs(x[i+K-1]));
    }
    ans = min(ans, time);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    int m;
    cin >> m;
    LL d,c;
    LL sum = 0, csum = 0;
    REP(i,0,m) {
        cin >> d >> c;
        csum += c;
        sum += d * c;
    }
    cout << (sum-1) / 9 + csum - 1 << endl;
}

int main() {
    solve();
    
    return 0;
}


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

const int N = 200000;
int a[N];

int main() 
{
	int n;
	scanf("%d", &n);
	int x = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", a + i);
		x ^= a[i];
	}
	for (int i = 0; i < n; ++i) printf("%d ", x ^ a[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 3200