akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  string w;
  cin >> w;
  int ans = 0;
  while (true) {
    string s;
    cin >> s;
    if (s == "END_OF_TEXT") {
      break;
    }
    rep(i, s.size()) {
      if (isupper(s.at(i))) {
        s.at(i) = s.at(i) - 'A' + 'a';
      }
    }
    if (s == w) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3204
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
	double r;cin >> r;
	printf("%lf",r * 2 * 3.141592);
    return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

bool seen[55][55];
int ans = 0;
int c[55][55];

bool dfs (int y, int x, int w, int h) {
    if (seen[y][x] || c[y][x] == 0) return false;
    seen[y][x] = true;
    rep (i, 0, 8) {
        int ny = y + dyy[i], nx = x + dxx[i];
        if (ny >= 0 && ny < h && nx >= 0 && nx < w && !seen[ny][nx] &&
            c[ny][nx] == 1) {
            dfs (ny, nx, w, h);
        }
    }
    return true;
}

int main() {
    int w, h;
    while (1) {
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        rep (i, 0, h) rep (j, 0, w) cin >> c[i][j];
        rep (i, 0, h) rep (j, 0, w) seen[i][j] = 0;
        int ans = 0;
        rep (i, 0, h) {
            rep (j, 0, w) {
                if (dfs (i, j, w, h)) {
                    // cout << i << " " << j << "\n";
                    ans++;
                }
            }
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dl;
#define pb push_back
#define ins insert
#define pll pair<ll,ll>
#define fi first
#define se second
#define mpr make_pair
#define vtr vector
#define itor iterator 
#define N ll(1e9+7)
#define endl '\n'
#define cont continue
using namespace std;
//ll power(ll a,ll b,ll mod)
//{
//	if(b==0)return 1;
//	ll ans=1;
//	while(b>0)
//	{
//		if(b&1)ans=(ans*a)%mod;
//		a=(a*a)%mod;
//		b>>=1;
//	}
//	return ans;
//}

int main()
{
	ios;
	ll n;
	cin>>n;
	map<string,ll> mp;
	string s;ll i;
	mp["AC"]=mp["WA"]=mp["TLE"]=mp["RE"]=0;
	for(i=1;i<=n;i++)
	{
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"];
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 1999999999
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

#ifdef INPUT
stringstream input(R"(
2 3
2 55
2 77
2 99
)");
#define cin input
#endif

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

	vector<int> index(m);
	vector<int> c(n,1);
	map<int,int> p;
	map<int,int> q;

	for (auto& i : index)
	{
		int val;
		cin >> val >> i;
		p[i]=val;
	}

	for (auto& i : p)
	{
		q[i.first]=c[i.second-1]++;
	}

	for (auto& i:index)
	{
		printf("%06d%06d\n", p[i], q[i]);
	}
	return 0;
}

Measured memory_bytes: 11648
n, w = map(int, raw_input().split())
goods = [map(int, raw_input().split()) for i in range(n)]
dp = [0]*(w+1)
for g in goods:
    ndp = [0]*(w+1)
    for i in range(w+1):
        if i - g[1] < 0:
            ndp[i] = dp[i]
        else:
            ndp[i] = max(dp[i-g[1]] + g[0], dp[i])
    dp = ndp
print dp[w]

Measured memory_bytes: 7128
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	if (ans == 1) {
		ans *= 10;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

long long x, y;

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

  cin >> x >> y; 
  
  int ans = 0;
  while(x <= y){
    x = (x << 1ll);
    ans++;
  }

  cout << ans << endl;

  return 0;
}



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

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

    if(a==b && b==c) cout << "No" << endl;
    else if(a!=b && b!=c && a!=c) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


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

#define ll long long 

int main() {
	ll N; cin >> N;
	ll a[N - 1];
	ll hash[N];
	memset(hash, 0, sizeof(hash));
	for(int i = 0; i < N - 1; i++){
		cin >> a[i];
		hash[a[i] - 1]++;
	}
	
	for(int i = 0; i < N; i++) {
		cout << hash[i] << "\n";
	}
}

Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pll, int > a, pair < pll, int > b)//true for a before b
{
	ll val = a.F.F*b.F.S - a.F.S*b.F.F;
	if(val >= 0LL)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 8000;



void solve()
{
	ll n, k, b, r, ans = 0LL;
	cin >> n >> k;
	fo(b,k+1LL,n+1LL)
	{
		ans += ((n/b)*(b-k));
		ans += max((n%b)-k+1LL,0LL);
		if(k == 0LL)
			ans--;
	}
	cout << ans;
	return;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1;
	// cin >> t;
	while(t--)
		solve();
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define all(x) x.begin(), x.end()
#define VI vector<int>
#define VS vector<string>
#define ll long long
#define INF 2e9
#define fir first
#define sec second
using namespace std;

void Main() {
    int n;
    cin >> n;
    map<string, int> S;
    ll ans = 0;
    rep(i, 0, n) {
        string k;
        cin >> k;
        sort(all(k));
        if (S.count(k) == 0) {
            S[k] = 0;
        } else {
            S[k]++;
            ans += S[k];
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << endl;
    Main();
    return 0;
}

Measured memory_bytes: 11264
#include <stdio.h>

int main(void)
{
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if(a+b>c+d)printf("Left\n");
        else if(a+b==c+d)printf("Balanced\n");
        else printf("Right\n");
        return 0;
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));

int main()
{
	cin >> h >> w;
	vector<vector<char>> vc(50, vector<char>(50, 0));
	REP(i, h)
		REP(j, w)
		cin >> vc[i][j];
	ll px = 0, py = 0;
	queue<pair<ll,ll>> q;
	q.emplace(0, 0);
	while(!q.empty())
	{
		px = q.front().second;
		py = q.front().first;
		q.pop();
		if(px&&py)
			if(vc[py][px-1]=='#'&&vc[py - 1][px] == '#')
			{
				cout << "Impossible" << endl;
				return 0;
			}
		if(px==w-1&&py==h-1)
		{
			cout << "Possible" << endl;
			return 0;
		}
		if (vc[py + 1][px] == '#'&&vc[py][px + 1] == '#')
		{
			cout << "Impossible" << endl;
			return 0;
		}
		if (vc[py][px + 1] == '#'&&px + 1 <= w) q.emplace(py, px + 1);
		if (vc[py + 1][px] == '#'&&py + 1 <= h) q.emplace(py + 1, px);
	}
	cout << "Impossible" << endl;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vpi;
typedef vector<bool> vbool;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define forall(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define F0(i,n) for(ll i = 0; i < n; i++)
#define F1(i,n) for(ll i = 1; i <= n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = b-1; i >= a; i--)
#define FIN ios::sync_with_stdio(false);cin.tie(0);
#define db(x) cout<<#x<<" = "<<x<<"\n"
#define all(v) v.begin(),v.end()
#define modulo(a,b) ((a%b)+b)%b
#define F first
#define S second
#define INF 1000000010
#define INFLL 1000000000000000000
#define eps 0.000000000001
#define mod 1000000007
template<class C> void mini(C&a, C b){ a=min(a, b);}
template<class C> void maxi(C&a, C b){a=max(a,b);}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//=======================//

const int maxn = 10010, maxd = 101;
char K[maxn];
vector<vector<ll>> dp;
int D;

/*
dp[sum][all] = Cantidad de maneras (hasta ahora) de elegir digitos tal que
su suma modulo D es sum. 'all' dice si vale elegir cualquier digito de 0 a 9 (esto pasa cuando
en algun paso anterior podia elegir digitos por ejemplo entre 0 y 5, y elegi un numero estrictamente menor
que 5. Si siempre vengo eligiendo el digito mas grande posible, entonces ahora no puedo elegir un numero
mayor al correspondiente en K).
*/

void sumar(ll& a, ll b) {
	a += b;
	if (a > mod) a-=mod;
}

int main () {
	//FIN
	string s; cin >> s;
	cin >> D;
	int size = 0;
	for(char c : s) {
		K[size++] = c - '0';
	}
	dp = vector<vector<ll>>(maxd, vll(2,0));
	F0(i,maxd) F0(j,2) dp[i][j] = 0;
	dp[0][0] = 1; // Despues de 0 pasos, puedo sumar 0 (de una sola manera).
	for (int i = 0; i < size; i++) {
		char actual = K[i];
		vector<vector<ll>> dp_new(maxd, vll(2,0));
		//El caso donde ya mire i digitos ya lo tengo en el vector dp. Itero por cada estado de dp y me muevo.
		for (int sum = 0; sum < D; sum++) {
			for (bool all : {false, true}) {
				for (int digit = 0; digit < 10; digit++) {
					if (!all && digit > actual) break;
					bool all_new = all || digit < actual;
					sumar(dp_new[(sum+digit)%D][all_new], dp[sum][all]);
				}
			}
		}
		dp = dp_new;
	}
	//La respuesta considera todos los numeros entre 0 y K, por lo que hay que restar 1 (El enunciado pide no contar 0).
	ll res = dp[0][true] + dp[0][false] - 1;
	res = modulo(res,mod);
	cout << res << "\n";




	return 0;
}










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

using namespace std;
const int N = 200200;
#include <iostream>
#include <map>
using namespace std;

#define N 500500

int t[N * 25];
int L[N * 25];
int R[N * 25];
int f[N];
#define next jklsjgklsjg
#define prev kfjgls
int prev[N];
int next[N];
int a[N];
int next_free = 1;
int n = N;

void build(int v, int tl, int tr) {
        if (tl == tr) {
                t[v] = prev[tl] == 0;
        } else {
                int tm = (tl + tr) >> 1;
                L[v] = ++next_free;
                R[v] = ++next_free;
                build(L[v], tl, tm);
                build(R[v], tm + 1, tr);
                t[v] = t[L[v]] + t[R[v]];
        }
}

void update(int v,int orig_v,int pos, int tl, int tr) {
        if (tl == tr) {
                t[v] = 1;
        } else {
                int tm = (tl + tr) >> 1;
                if (pos <= tm) {
                        L[v] = ++next_free;
                        R[v] = R[orig_v];
                        update(L[v],L[orig_v],pos,tl,tm);
                } else {
                        L[v] = L[orig_v];
                        R[v] = ++next_free;
                        update(R[v],R[orig_v],pos,tm+1,tr);
                }
                t[v] = t[L[v]] + t[R[v]];
        }
}
int getsum(int l, int r, int v,int tl, int tr) {
        if (l > tr || r < tl) return 0;
        if (l <= tl && tr<=r) return t[v];
        int tm = (tl + tr) >> 1;
        return getsum(l,r,L[v],tl,tm)+getsum(l,r,R[v],tm+1,tr);
}
int distinct(int l, int r) {
        return getsum(l,r,f[l],1,n);
}



void solve(){
        cin >> n;
        int q;
        cin >> q;
        map<int,int> last;
        for (int i = 1; i <= n; i++) {
                cin >> a[i];
                if (last[a[i]] == 0) {
                        last[a[i]] = i;
                } else {
                        prev[i] = last[a[i]];
                        next[prev[i]] = i;
                        last[a[i]]=i;
                }
        }

        build(0,1,n);

        for (int i = 2; i <= n; i++ ){
                if (next[i - 1] != 0) {
                        f[i] = ++next_free;
                        update(f[i],f[i-1],next[i-1],1,n);
                } else f[i] = f[i-1];
        }
        int l, r;
        while (q--) {
                cin >> l >> r;
                cout << distinct(l,r) << endl;
        }

}




int main() {
#ifdef QWERTY
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
#endif
        ios_base::sync_with_stdio(false);


        int t = 1;
//        cin >> t;

        for (int i = 1; i <= t; i++) {
//                cout << "Case #" << i << ':' << endl;
                solve();
        }


        return 0;
}

Measured memory_bytes: 139772
//I love Nanami Chiaki
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fst first
#define snd second
const int inf=1e9+7;
const int mod=1e9+7;
//const int maxn=;
int c[17],a[17][17],sum[17];
int main(){
	int n,m,x;cin>>n>>m>>x;
	for (int i=0;i<n;i++){
		cin>>c[i];for (int j=0;j<m;j++) cin>>a[i][j];
	}
	int ans=inf;
	for (int i=0;i<(1<<n);i++){
		memset(sum,0,sizeof(sum));int cnt=0;
		for (int j=0;j<n;j++){
			if (!((i>>j)&1)) continue;
			cnt+=c[j];for (int k=0;k<m;k++) sum[k]+=a[j][k];
		}
		bool f=true;
		for (int j=0;j<m;j++) if (sum[j]<x){f=false;break;}
		if (f) ans=min(ans,cnt); 
	}
	if (ans==inf) puts("-1");
	else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	  public static void main(String args[]) {
		  //入力値取得
		    Scanner sc = new Scanner(System.in);
		    int n = sc.nextInt();
		    int cost[] = new int[n];
		    int value[] = new int[n];
		    for (int i = 0; i < n; i++)
		      cost[i] = sc.nextInt();
		    for (int i = 0; i < n; i++)
		      value[i] = sc.nextInt();

		    //COST-VALUE 積み上げて最大化させる
		    int ans = 0;
		      for (int i = 0; i < n; i++)
		        if (cost[i] > value[i]) {
		          ans += cost[i] - value[i];
		        }

		    System.out.println(ans);
		    sc.close();
		  }

}

Measured memory_bytes: 23764
N = 0
a = 0

try:
    N = int(input())
    for i in range(N + 1):
        a += i * (i + 1) // 2
    for i in range(N - 1):
        line = input().split()
        u = min(int(line[0]), int(line[1])) - 1
        v = max(int(line[0]), int(line[1])) - 1
        a -= (u + 1) * (N - v)        
except:
  pass

print(a)

Measured memory_bytes: 9124
#include <stdio.h>
int main(void)
{
    char s[6];
    scanf("%s",s);
    int ans=0;
    int p=0;
    while(ans==0 && p<6)
    {
        if(s[p]==0x41 && s[p+1]==0x43)
        {
            printf("Yes");
            ans=1;
        }
        p++;
    }
    if(ans==0)printf("No");
}


Measured memory_bytes: 128
import queue as qu

k = int(input())

q = qu.Queue()

for i in range(1,10):
    q.put(i)

for i in range(k-1):
    x = q.get(i)
    if x%10 != 0:
        q.put(10*x +x%10 -1)
    q.put(10*x +x%10)
    if x%10 != 9:
        q.put(10*x +x%10 +1)

print(q.get())

Measured memory_bytes: 12452
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
#define CEIL(A,B) ((A)+(B)-1)/(B)
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, K, C;
string S;
vector<ll> L, R;


int main() {
    fastio();
    cin >> N >> K >> C;
    cin >> S;
    L.resize(K, -1);
    R.resize(K, -2);
    ll cnt = 0, i = 0;
    while(cnt < K && i < N) {
        while(S[i] == 'x' and i < N) i++;
        L[cnt++] = i;
        i += C + 1;
    }
    // priv(L);
    cnt = K - 1, i = N - 1;
    while(cnt >= 0 && i >= 0) {
        while(S[i] == 'x' and i >= 0) i--;
        R[cnt--] = i;
        i -= C + 1;
    }
    // priv(R);
    REP(i, K) {
        if(L[i] == R[i]) cout << L[i] + 1 << "\n";
    }
	return 0;
}

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

using namespace std;

typedef long long ll;

const int inf = 1e9 + 7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, max_w;
    cin >> n >> max_w;
    vector <ll> dp(max_w + 1, 0);
    vector <vector <int> > a(n, vector <int> (2));
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1];
    }
    for (int i = 0; i < n; i++) {
        for (int j = max_w; j >= 0; j--) {
            if (j + a[i][0] <= max_w) {
                dp[j + a[i][0]] = max(dp[j + a[i][0]], dp[j] + a[i][1]);
            }
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << '\n';
    return 0;
}


Measured memory_bytes: 1024
import itertools
import math
import collections

def main():
    n = int(input())

    s = int(math.sqrt(n))
    a = list(itertools.product(range(1,s),repeat=3))

    ans = []
    for i in range(len(a)):
        t = a[i][0] ** 2 + a[i][1] ** 2 + a[i][2] ** 2 + a[i][0] * a[i][1] + a[i][1] * a[i][2] + a[i][2] * a[i][0]
        ans.append(t)
        # print(ans)

    c = collections.Counter(ans)
    for i in range(1,n+1):
        print(c[i])
        
        
main()
        
        


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repab(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define pb push_back
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
#define endl "\n"

typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

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

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

  int ans = 0;
  int a = 1;
  int b = n;
  rep(i, n){
    bool found = false;
    while(!found){
      if(a * b < n){
        ans += b;
        found = true;
        a++;
      }
      else{
        b--;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::map<std::string, int> ma;

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

  std::cin >> N;

  for(int i=0;i<N;++i){
      std::string S;
      std::cin >> S;
      
      ma[S] += 1;
  }

  int mx = 0;

  for(auto it : ma){
      if(it.second > mx){
          mx = it.second;
      }
  }

  for(auto it : ma){
      if(it.second == mx){
          std::cout << it.first << std::endl;
      }
  }
}


Measured memory_bytes: 25536
X=[1,3,5,7,8,10,12]
Y=[4,6,9,11]
Z=[2]
x,y=map(int,input().split())
if (x in X and y in X) or (x in Y and y in Y) or  (x in Z and y in Z):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int n;
cin>>n;
string s;
cin>>s;
if(n%2!=0)cout<<"No"<<endl;
else{
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[i+n/2]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
        if (e - a <= k) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}

Measured memory_bytes: 23764
//  Shopping in JOI Kingdom.cpp
//  2013/01/06.

#if 1

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int INF = 1<<30;

int N, M, K;
int D[3000];
int C[3000][3000];
int used[3000];

int dfs(int pnt)
{
	rep(next, N) if(D[next] > D[pnt] + C[pnt][next])
	{
		D[next] = D[pnt] + C[pnt][next];
		dfs(next);
	}
}

void dijkstra(int pnt)
{
	memset(used, 0, sizeof used);
	
	while(true)
	{
		int v = -1;
		
		rep(u, N) if(!used[u] && (v == -1 || D[u] < D[v])) v = u;
		
		if(v == -1) break;
		
		used[v] = true;
		
		rep(u, N) chmin(D[u], D[v] + C[v][u]);
	}
}

int calc(int a, int b, int l)
{
	return round(min(a, b) + (l + max(a, b) - min(a, b)) / 2.0);
}

int main()
{
	rep(i, 3000) rep(j, 3000) D[i] = C[i][j] = INF;
	
	cin >> N >> M >> K;

	rep(m, M)
	{
		int a, b, c;
		cin >> a >> b >> c;
		
		C[a-1][b-1] = C[b-1][a-1] = c;
	}
	
	int s;
	rep(k, K)
	{
		cin >> s;
		
		D[s-1] = 0;
	}
	
	dijkstra(s-1);	

	int ans = 0;
	
	rep(a, N) REP(b, a+1, N) if(C[a][b] < INF) chmax(ans, calc(D[a], D[b], C[a][b]));
	
	cout << ans << endl;
}

#endif

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if((e - a) <= k){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}

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

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

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

int w,h,ans;
int map[59][59];
int reached[59][59];
queue<int> nx,ny,cnt;

void search(int cnt,int x,int y){
  if(cnt>=ans||reached[y][x]) return;
  if(x==2*(w-1)&&y==2*(h-1)){
    if(cnt<ans) ans=cnt;
    return;
  }
  reached[y][x]=1;
  if(x<2*(w-1)&&map[y][x+1]==0) search(cnt+1,x+2,y);
  if(y<2*(h-1)&&map[y+1][x]==0) search(cnt+1,x,y+2);
  if(x>0&&map[y][x-1]==0) search(cnt+1,x-2,y);
  if(y>0&&map[y-1][x]==0) search(cnt+1,x,y-2);
  reached[y][x]=0;
}

void v_search(){
  nx.push(0); ny.push(0); cnt.push(1);
  while(!nx.empty()&&!ny.empty()){
    int x=nx.front(); int y=ny.front(); int c=cnt.front();
    nx.pop(); ny.pop(); cnt.pop();
    if(c>=ans||reached[y][x]) continue;
    if(x==2*(w-1)&&y==2*(h-1)&&c<ans){
      ans=c; continue;
    }
    reached[y][x]=1;
    if(x<2*(w-1)&&map[y][x+1]==0&&reached[y][x+1]==0){
      nx.push(x+2); ny.push(y); cnt.push(c+1);
    }
    if(y<2*(h-1)&&map[y+1][x]==0&&reached[y+1][x]==0){
      nx.push(x); ny.push(y+2); cnt.push(c+1);
    }
    if(x>0&&map[y][x-1]==0&&reached[y][x-1]==0){
      nx.push(x-2); ny.push(y); cnt.push(c+1);
    }
    if(y>0&&map[y-1][x]==0&&reached[y-1][x]==0){
      nx.push(x); ny.push(y-2); cnt.push(c+1);
    }
  }
}

int main(){
  while(cin>>w>>h,w){
    for(int i=0;i<h*2-1;i++){
      if(i%2==0){
	for(int j=0;j<w*2-1;j++){
	  if(j%2==0) map[i][j]=reached[i][j]=0;
	  else cin>>map[i][j];
	}
      } else{
	for(int j=0;j<w*2-1;j++){
	  if(j%2==0) cin>>map[i][j];
	  else map[i][j]=reached[i][j]=0;
	}
      }
    }
    /*for(int i=0;i<h*2-1;i++){
      for(int j=0;j<w*2-1;j++)
	cout<<map[i][j]<<" ";
      cout<<endl;
      }*/
    ans=10000;
    v_search();
    if(ans==10000) ans=0;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int m, k;
    cin >> m >> k;
    int n = 1 << m;
    if (k == 0) {
        for (int i = 0; i < n; i++) {
            if (i) cout << " ";
            cout << i << " " << i;
        }
        cout << endl;
        return 0;
    }
    if (n <= k) {
        cout << -1 << endl;
        return 0;
    }
    int ans[n * 2];
    ans[0] = k;
    ans[n] = k;
    int cur = 0;
    for (int i = 1; i < n; i++) {
        if (cur == k) cur++;
        ans[n - i] = cur;
        ans[n + i] = cur;
        cur++;
    }
    int sum[n * 2 + 1] = {};
    for (int i = 0; i < n * 2; i++) {
        sum[i + 1] = sum[i] ^ ans[i];
    }
    int pre[n];
    fill(pre, pre + n, -1);
    for (int i = 0; i < n * 2; i++) {
        if (pre[ans[i]] == -1) {
            pre[ans[i]] = i;
        } else if ((sum[pre[ans[i]]] ^ sum[i + 1]) != k) {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i = 0; i < n * 2; i++) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 6164
#include <stdio.h>
int main(void)
{
    int numBook;
    scanf("%d", &numBook);
    switch(numBook % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            printf("hon");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            printf("pon");
            break;
        case 3:
            printf("bon");
            break;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  VI dp(n+1, 0);
  dp[1] = 1;
  if(n > 1) {
    if(s[0] == s[1]) dp[2] = 1;
    else dp[2] = 2;
  }
  rep(i, n) {
    if(i + 3 > n) break;
    if(s[i+2] == s[i+1]) {
      dp[i+3] = max(dp[i] + 1, dp[i+1]) + 1;
    }
    else {
      dp[i+3] = dp[i+2] + 1;
    }
  }
  out(dp[n]);

  return 0;
}


Measured memory_bytes: 1428
package main

import (
	"fmt"
	"strconv"
	"strings"
)

var bomb = "#"

func main() {
	var H, W int
	fmt.Scan(&H)
	fmt.Scan(&W)

	inputs := scanStrings(H)

	// fmt.Println(inputs)
	res := createMap(inputs, H, W)
	// fmt.Println(res)

	for _, s := range res {
		fmt.Println(strings.Join(s, ""))
	}

}

func createMap(inputs [][]string, H int, W int) (res [][]string) {
	for i := 0; i < H; i++ {
		line := make([]string, 0)
		for j := 0; j < W; j++ {
			if inputs[i][j] == bomb {
				line = append(line, bomb)
				continue
			}
			point := 0
			// fmt.Println(i, j)
			if i-1 >= 0 {
				if j-1 >= 0 {
					if inputs[i-1][j-1] == bomb {
						// fmt.Println("a")
						point++
					}
				}
				if inputs[i-1][j] == bomb {
					// fmt.Println("b")
					point++
				}
				if j+1 <= W-1 {
					if inputs[i-1][j+1] == bomb {
						// fmt.Println("c")
						point++
					}
				}
			}
			if j-1 >= 0 {
				if inputs[i][j-1] == bomb {
					// fmt.Println("d")
					point++
				}
			}
			if j+1 <= W-1 {
				if inputs[i][j+1] == bomb {
					// fmt.Println("e")
					point++
				}
			}
			if i+1 <= H-1 {
				if j-1 >= 0 {
					if inputs[i+1][j-1] == bomb {
						// fmt.Println("f")
						point++
					}
				}
				if inputs[i+1][j] == bomb {
					// fmt.Println("g")
					point++
				}
				if j+1 <= W-1 {
					if inputs[i+1][j+1] == bomb {
						// fmt.Println("h")
						point++
					}
				}
			}
			// fmt.Println(point)
			line = append(line, strconv.Itoa(point))
		}

		// fmt.Println(line)
		res = append(res, line)
	}
	return
}

func scanStrings(len int) (inputs [][]string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		line := make([]string, 0)
		for _, s := range str {
			line = append(line, string(s))
		}

		inputs = append(inputs, line)
	}
	return
}


Measured memory_bytes: 896
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N, K = [int(a) for a in input().split()]
    A = [int(a) for a in input().split()]
    # T = int(input())
    # A = [int(a) for a in input().split()]
    # T1, T2, T3 = [int(a) for a in input().split()]

    for _ in range(K):
        AA = [0] * len(A)
        for i, ai in enumerate(A):
            l = max(0, i - ai)
            r = min(N - 1, i + ai)
            AA[l] += 1
            if r != N - 1:
                AA[r + 1] -= 1
        for i in range(len(AA) - 1):
            AA[i + 1] += AA[i]

        A = AA
        flag = True
        for a in AA:
            if a != len(A):
                flag = False
                break
        if flag:
            break
    print(' '.join([str(a) for a in A]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 138336
#define _GLIBCXX_DEBUG
#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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,k; cin >> n >> k;
  string s; cin >> s;
  int cnt=0;
  int ans;
  bool f=0;
  for(int i=1;i<n;i++){
    if(cnt<k){
      if(s[i]!=s[0]) f=1;
      if(f&&s[i]==s[0]){
        cnt++;
        f=0;
      }
      ans=i;
    }
    if(cnt>=k){
      if(s[i]==s[i-1]) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
int n, x[1009], y[1009], dp[1009][1009];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 2; i <= n; i++) {
		for (int l = 0; l <= n - i; l++) {
			int r = l + i; dp[l][r] = 999999999;
			for (int k = l + 1; k < r; k++) {
				dp[l][r] = std::min(dp[l][r], dp[l][k] + dp[k][r] + x[k] - x[l] + y[k - 1] - y[r - 1]);
			}
		}
	}
	printf("%d\n", dp[0][n]);
	return 0;
}

Measured memory_bytes: 6660
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<String> s = nextCharArray();
      int output = 0;
      for(int i = 0; i < s.size(); i++){
        output += (s.get(i).equals("1")) ? 1 : 0;
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33076
def minimumOpt1(seq):
    dest = {}
    b = sorted(seq)
    for i in xrange(len(b)):
        dest[b[i]] = i
    foo = 0
    for i in xrange(0, len(seq), 2):
        if dest[seq[i]]%2==1:
            foo += 1
    return foo

def main():
    n = int(raw_input().strip())
    seq = []
    for i in xrange(n):
        seq.append(int(raw_input().strip()))
    print minimumOpt1(seq)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17852
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;

const int mod = (int)1e9 + 7;
const int MAXN = 1e5+12;
//indexed_set s;

int n;
double d;

int main() {

    cin >> n;

    cin >> d;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        double x,y;
        cin >> x >> y;
        double dist = sqrt(x*x+y*y);
        if (dist <= d) ans++;
    }

    cout << ans;

return 0;
}


Measured memory_bytes: 3824
n = int(input())
def int_or_st(i):
  if str.isnumeric(i):
    return int(i)
  else:
    return i
res = [list(map(int_or_st,input().split())) for _ in range(n)]
sorted_res = sorted(res,reverse=True,key=lambda x:x[1])
sorted_res.sort(key=lambda x:x[0])
for i in sorted_res:
  print(res.index(i)+1)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, int64_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, int64_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr int64_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

// UnionFind {{{
struct UnionFind {
    vector<int> tree;
    explicit UnionFind(int n) : tree(n + 5, -1) {}

    int size(int i) { return (-tree[root(i)]); }

    int root(int x) { return (tree[x] < 0) ? x : tree[x] = root(tree[x]); }

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

    bool unite(int x, int y) {
        return (x = root(x)) == (y = root(y)) ? false : (tree[x] += tree[y], tree[y] = x, true);
    }
};
// }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, M;
    cin >> N >> M;

    UnionFind uf(N);

    for (size_t i = 0; i < M; ++i) {
        size_t s, t; cin >> s >> t;
        uf.unite(s, t);
    }

    size_t Q; cin >> Q;
    while (Q--) {
        size_t s, t; cin >> s >> t;
        cout << (uf.same(s, t) ? "yes" : "no") << "\n";
    }

    return 0;
}



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

long long N;
int M, X, rows;
vector<int> V;
int dir[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
bool b[200005][7], avail[100005], vis[200005][7];

bool cv(int x, int y) {
	if (x < 0 || x >= rows) return false;
	if (y < 0 || y >= 7) return false;
	if (!b[x][y]) return false;
	if (vis[x][y]) return false;
	return true;
}

void dfs(int x, int y) {
	vis[x][y] = 1;
	for (int i = 0; i < 4; i++) {
		int newx = x + dir[i][0], newy = y + dir[i][1];
		if (cv(newx, newy)) dfs(newx, newy);
	}
}

int cc(long long x, long long y) { // count CCs from row x to y
	memset(b, 0, sizeof(b));
	memset(vis, 0, sizeof(vis));
	for (long long r = x; r <= y; r++) {
		for (int c = 0; c < 7; c++) {
			long long idx = r * 7 + c;
			b[r-x][c] = avail[idx % M];
		}
	}
	int ans = 0;
	rows = y - x + 1;
	for (int r = 0; r < y - x + 1; r++) {
		for (int c = 0; c < 7; c++) {
			if (b[r][c] && !vis[r][c]) {
				dfs(r, c);
				ans++;
			}
		}
	}
	return ans;
}

int main() {
	scanf("%lld%d%d", &N, &M, &X);
	for (int i = 0; i < M; i++) avail[i] = 1;
	for (int i = 0; i < X; i++) {
		int a;
		scanf("%d", &a);
		V.push_back(a);
		avail[a] = 0;
	}
	if (N <= 2 * M) {
		printf("%d\n", cc(0, N - 1));
		return 0;
	}
	int one = cc(0, M - 1);
	int two = cc(0, 2 * M - 1);
	int subtract = one * 2 - two;
	int rows = N / M;
	printf("%lld\n", (long long)one * (rows - 1) - (long long)subtract * (rows - 1) + cc((long long)(rows - 1) * M, N - 1));
}


Measured memory_bytes: 25472
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<cmath>
#include<tuple>
#include<utility>
#include<vector>
namespace pcl{template<typename T>constexpr T gcd(T a,T b){return b==0?a:gcd(b,a%b);}template<typename T>constexpr T lcm(T a,T b){return a/gcd(a,b)*b;}template<typename T>constexpr std::tuple<T,T,T>extgcd(T a,T b){if(b==0){return std::make_tuple(a,1,0);}else{T gcd,xd,yd;std::tie(gcd,xd,yd)=extgcd(b,a%b);return std::make_tuple(gcd,yd,xd-(a/b)*yd);}}template<typename T>std::vector<T>sieve(T N){std::vector<T>res;std::vector<bool>is_not_prime(N);for(T i=2;i<=N;i++){if(is_not_prime[i])continue;res.push_back(i);for(T j=i+i;j<=N;j+=i)is_not_prime[j]=true;}return res;}template<typename T>constexpr T pow(T x,int n){T res=1;while(n>0){if(n&1)res*=x;x*=x;n>>=1;}return res;}template<typename T>constexpr bool is_prime(T val){for(T i=2;i<val;i++){if(val%i==0)return false;}return true;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){ll A,B,C,D;cin>>A>>B>>C>>D;ll L=lcm(C,D);auto d=[&](ll x){return(B/x)-((A-1)/x);};cout<<d(1)-(d(C)+d(D)-d(L))<<endl;}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
	int N, K;
	cin >> N >> K;
	double probability = 0.0;
	for (int i = 1; i <= N; i++)
	{
		int cnt = 0, j = i;
		while (j < K)
		{
			j = j*2;
			cnt++;
			if (j >= K)
				break;
		}
		probability += (1.0 / N) / (1 << cnt);
	}
	cout << setprecision(12);
	cout << probability << endl;
	//system("pause");
	return 0;
}

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


def solve(K: int, A: int, B: int):
    k = B // K
    if A <= k * K:
        print("OK")
    else:
        print("NG")
    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()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61736