akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int p[100010];
int w[100010]={0};
ll s[100010];
ll pre=0;
ll n,m;
int find(int a){
    while(p[a]!=a){
        a=p[a];
    }
    return a;
}
ll f(ll x){
    return (x*(x-1))/2;
}
int main() {
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    for(int i=0;i<100000;i++){
        p[i]=i;
        s[i]=1;
    }
    cin>>n>>m;
    pair<int,int> edges[m];
    for(int i=0;i<m;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        edges[i]={a,b};
    }
    vector<ll> v;
    v.push_back(f(n));
    for(int i=m-1;i>=1;i--){
        int x=edges[i].first; int y=edges[i].second;
        int X=find(x); 
        int Y=find(y);
        if(X==Y){
            v.push_back(v[(int)v.size()-1]); continue;
        }
        int z;
        if(w[X] >= w[Y]){
            z=X;
            if(w[X]==w[Y]) w[X]++;
        }
        else z=Y;
        p[x]=z; p[X]=z;
        p[y]=z; p[Y]=z;
        pre=pre-f(s[X])-f(s[Y])+f(s[X]+s[Y]);
        s[z]=s[X]+s[Y];
        v.push_back(f(n)-pre);
    }
    reverse(v.begin(),v.end());
    for(auto x : v) cout<<x<<"\n";
}

Measured memory_bytes: 4596
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[1000005];
ll   dp[1000005][2];

void solve()
{
    scanf("%s", str);
    int n=strlen(str);
    int i;
    for(i=0; i<n; i++) {
        int tmp=str[n-1-i]-'0';
        if(i==0) {
            dp[i][0]=tmp;
            dp[i][1]=10-tmp;
        }
        else {
            dp[i][0]=dp[i-1][0]+tmp;
            dp[i][1]=dp[i-1][0]+(10-tmp);
            
            int tmp2=tmp+1;
            if(tmp2==10) {
                dp[i][1]=MIN(dp[i][1],dp[i-1][1]+(10-tmp2));
            }
            else {
                dp[i][0]=MIN(dp[i][0],dp[i-1][1]+tmp2);
                dp[i][1]=MIN(dp[i][1],dp[i-1][1]+(10-tmp2));
            }
        }
    }
    ll ans=MIN(dp[n-1][0],dp[n-1][1]+1);
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


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

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

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

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

    int n;cin >> n;

    int64_t sum = 0;
    map<int64_t ,int64_t > M;

    rep(i,n){
        int64_t x;cin >> x;
        sum += x;
        M[x]++;
    }

    int q;cin >> q;
    rep(_,q){
        int64_t b,c;cin >> b >> c;
        int64_t cnt = M[b];
        sum -= cnt * b;
        sum += cnt * c;
        M[c] += cnt;
        M[b] = 0;
        cout << sum << '\n';
    }

}


Measured memory_bytes: 9524
n,d= map(int,input().split())
ls = []
for i in range(n):
    ls.append(list(map(int,input().split())))

ans = 0
for l in ls:
    if (l[0] * l[0] + l[1] * l[1] <= d * d):
        ans += 1

print(ans)

Measured memory_bytes: 45384
N, C = map(int, input().split())

sushi = []
for i in range(N):
    x, v = map(int, input().split())
    sushi.append((x, v))

left = [0] * N
left2 = [0] * N
right = [0] * N
right2 = [0] * N

d = 0
d2 = 0
cal = 0
for i in range(N):
    x, v = sushi[i]
    d = x
    d2 = x * 2
    cal += v
    if i == 0:
        right[i] = max(cal - d, 0)
        right2[i] = max(cal - d2, 0)
    else:
        right[i] = max(cal - d, right[i-1])
        right2[i] = max(cal - d2, right2[i-1])

d = 0
d2 = 0
cal = 0
for i in reversed(range(N)):
    x, v = sushi[i]
    d = C - x
    d2 = (C - x) * 2
    cal += v
    if i == 0:
        left[i] = max(cal - d, 0)
        left2[i] = max(cal - d2, 0)
    else:
        left[i] = max(cal - d, left[i-1])
        left2[i] = max(cal - d2, left[i-1])

ans = 0
# 左側を全部試す
for i in range(N):
    if i == 0:
        ans = max(ans, left[i])
    else:
        ans = max(ans, left[i] + right2[i-1])
# 右側を全部試す
for i in range(N):
    if i == N - 1:
        ans = max(ans, right[i])
    else:
        ans = max(ans, right[i] + left2[i+1])

print(ans)

Measured memory_bytes: 30804
using System;
using System.Linq;

class E
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var z = Read();
		var h = z[0];
		var ms = new int[z[1]].Select(_ => Read()).ToArray();

		var dp = Enumerable.Repeat(int.MaxValue, h + 1).ToArray();
		dp[h] = 0;
		for (int j, i = h; i > 0; i--)
			if (dp[i] < int.MaxValue)
				foreach (var m in ms)
				{
					if ((j = i - m[0]) < 0) j = 0;
					dp[j] = Math.Min(dp[j], dp[i] + m[1]);
				}
		Console.WriteLine(dp[0]);
	}
}


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

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

    for (int i = -k+1; i < k; i++) {
        cout << x + i << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	map<int,int> mp;
	rep(i,n) mp[(i+1) - a[i]]++;
	ll ans = 0;
	rep(i,n) {
		ans += mp[a[i] + (i+1)];
	}
	cout << ans << endl;
}

Measured memory_bytes: 21068
#include<bits/stdc++.h>
using namespace std;
#define itn int

itn main(void){
    int n,m;
    cin >> n >> m;
    vector<pair<int,long long int>> P;
    for(int i = 0;i < n;i++){
        int a,b;
        cin >> a >> b;
        P.push_back(pair<int,long long int>(a,b));
    }
    long long itn count = 0,sum = 0;
    sort(P.begin(),P.end());
    for(auto & i : P){
        if(sum + i.second <= m){
            sum += i.second;
            count += (i.second*i.first);
        } else {
            count += (m-sum)*i.first;
            break;
        }
        //cout << i.first << " " << i.second << endl;
    }
    cout << count << endl;
}

Measured memory_bytes: 2420
import math
s = input()+"a"
N = len(s)

#def count(x, y):

L = []
R = [-1]
l = 0
r = 0
while s[l] == "R":
    if s[l+1] == "L":
        r = l + 1
        while s[r+1] == "L":
            r += 1
        #print(l, r)
        L.append(l)
        R.append(r)
        l = r
    l += 1
    
#print("Rの右側: {}".format(L))
#print("Lの右側: {}".format(R))

a = []
b = []
for i in range(len(L)):
    x = L[i] - R[i]
    y = R[i+1] - L[i]
    b.append(x//2 + math.ceil(y/2))
    a.append(math.ceil(x/2) + y//2)

#print(f"Rの個数{a}")
#print(f"Lの個数{b}")
ans = [0]*(N-1)
for i,j in enumerate(L):
    ans[j] = a[i]
    ans[j+1] = b[i]

print(*ans)


Measured memory_bytes: 11036
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		int N = 1000000;

		int ptr = 0;
		int[] prime = new int[N];

		prime[ptr++] = 2;
		prime[ptr++] = 3;

		for (int t = 5; t <= N; t += 2) {
			boolean wflag = false;
			for (int i = 1; prime[i] * prime[i] <= t; i++) {
				if (0 == t % prime[i]) {
					wflag = true;
					break;
				}
			}
			if (!wflag) {
				prime[ptr++] = t;
			}
		}

		while (true) {
			int a = s.nextInt();
			int d = s.nextInt();
			int n = s.nextInt();

			if (a == 0 && d == 0 && n == 0)
				break;

			int index = 0;
			int[] ans = new int[n];

			for (int i = 0; i < N; i++) {
				if (index == n)
					break;
				if (prime[i] >= a && (prime[i] - a) % d == 0)
					ans[index++] = prime[i];
			}

			System.out.println(ans[n - 1]);

		}
		s.close();
	}
}

Measured memory_bytes: 25616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int x, y;

signed main() {
	cin >> x >> y;
	if ((x + y) % 3) {
		cout << 0 << endl;
		return 0;
	}
	if (min(x, y) * 2 < max(x, y)) {
		cout << 0 << endl;
		return 0;
	}
	int b = (x + y) / 3;
	int c = 0;
	for (int i = 0; i <= b; i++) {
		if (1 * i + 2 * (b - i) == x) {
			c = i;
			break;
		}
	}
	cout << comb(b, c) % mod << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SREP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000+7)

int main(void)
{
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B);
    REP(i, A) {
        cin >> s[i];
    }
    REP(j, B) {
        cin >> t[j];
    }
    REP(i, Q) {
        ll x;
        cin >> x;

        auto sub = upper_bound(s.begin(), s.end(), x);
        auto tub = upper_bound(t.begin(), t.end(), x);

        ll d = 1e11;
        if (sub != s.begin() && tub != t.begin())
        {
            d = min(d, max(x - *(sub - 1), x - *(tub - 1)));
        }
        if (sub != s.begin() && tub != t.end())
        {
            d = min(d, min(
                x + *tub - 2*(*(sub - 1)), 
                2*(*tub) - x - *(sub - 1)
            ));
        }
        if (sub != s.end() && tub != t.begin())
        {
            d = min(d, min(
                x + *sub - 2 * (*(tub - 1)),
                2 * (*sub) - x - *(tub - 1)
            ));
        }
        if (sub != s.end() && tub != t.end())
        {
            d = min(d, max(*sub - x, *tub - x));
        }

        cout << d << endl;
    }

    return 0;
}


Measured memory_bytes: 2944
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);

// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(l) read(b) read(x) read(y)
    cout<<setprecision(18)<< (double)l*b/2<<" ";
    if(x*2 == l && y*2==b)cout<<1;
    else
    {
        cout<<0;
    }
    
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


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

void solve(long long N, long long K, std::vector<long long> a, std::vector<long long> b){
    vector<pll> p(N);
    for(ll i=0; i< N; i++){
        p[i].first = a[i];
        p[i].second = b[i];
    }
    sort(p.begin(), p.end());
    for(ll i=0; i< N; i++){
        if(K>p[i].second){
            K -= p[i].second;
        }
        else{
            cout << p[i].first << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 3328
N = int(input())
S = list(input())

alr_1 = []
ans = []
for i in range(N-2):
    if not S[i] in alr_1:
        start_1 = S[i]
        alr_1.append(start_1)
        alr_2 = []
        for j in range(i+1, N-1):
            if not S[j] in alr_2:
                start_2 = S[j]
                alr_2.append(start_2)
                alr_3 = []
                for k in range(j+1, N):
                    if not S[k] in alr_3:
                        goal = S[k]
                        ans.append([start_1, start_2, goal])
                        alr_3.append(goal)
print(len(ans))

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
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; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  double L; cin >> L;
  
  //main
  double ans = (L/3)*(L/3)*(L/3);
  
  // output
  cout << fixed << setprecision(6) << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int main(){
  int n;
  int i;
  int Ans;
  int Max,Min;
  int *A;
  int *R;
  
  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  Max=A[0];
  Min=A[0];
  Ans=A[1]-A[0];
  for(i=1;i<n;i++){
    if(Max < A[i]) Max=A[i];
    if(Min > A[i]){
      Min=A[i];
      if(i+1!=n) Max=A[i+1];
      else Max=-999999999;
    }
    if(Ans < Max-Min) Ans = Max-Min;
  }
  printf("%d\n",Ans);
  return 0;
}


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

typedef long long ll;
typedef long double ld;

const ll INF = 1e+18;

vector<ll> divisors(ll n){
	vector<ll> ret;
	ret.push_back(1);
	for(ll i = 2 ; n > 1 ; i ++){
		if(i*i > n)i = n;
		if(n%i == 0){
			int cnt = 0;
			while(n%i == 0){
				n /= i;
				cnt ++;
			}
			int sz = ret.size();
			for(int j = 0 ; j < sz ; j ++){
				ll x = ret[j];
				for(int k = 0 ; k < cnt ; k ++){
					x *= i;
					ret.push_back(x);
				}
			}
		}
	}
	return ret;
}

ll f(ll n,ll b){
	if(b == 1)return -1;
	if(n == 0)return 0;
	return n%b+f(n/b,b);
}

int main(){
	ll n,s;
	cin >> n >> s;
	
	if(n<s){
		puts("-1");
		return 0;
	}
	if(n == s){
		cout << n+1 << endl;
		return 0;
	}
	
	//puts("DEBUG");
	
	ll ret = INF;
	for(ll i = 1 ; i <= (ll)(sqrt((ld)n)+1e-6) ; i ++){
		if(f(n,i)==s)ret = min( ret , i );
	}
	
	//puts("DEBUG");
	
	vector<ll> d = divisors(n-s);
	for(ll i = 0 ; i < d.size() ; i ++){
		if(f(n,d[i]+1)==s)ret = min( ret , d[i]+1 );
	}
	if(ret == INF)puts("-1");
	else cout << ret << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int s[200005];
int n;
int main()
{
	cin>>n;
	ll ans=0;
	ll sum=0;
	int x;
	int k=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		s[i]=x;
		if((sum^x)==sum+x){
			k++;
			sum+=x;
		}else{
			while((sum^x)!=sum+x){
				sum^=s[i-k];
				k--;
			}
			sum^=x;
			k++;
		}
		ans+=k;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int h = in.nextInt();
        int n = in.nextInt();
        int[] a = in.nextIntArray(n);

        int sum = Arrays.stream(a).sum();
        out.println(h <= sum ? "Yes" : "No");
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 35848
from collections import Counter

n, k, l = map(int, input().split())
pq = [list(map(int, input().split())) for _ in range(k)]
rs = [list(map(int, input().split())) for _ in range(l)]


class UnionFind:
    def __init__(self, x):
        self.p = [e for e in range(x)]
        self.rank = [0] * x

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        self.link(self.find_set(u), self.find_set(v))

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def link(self, u, v):
        if self.rank[u] > self.rank[v]:
            self.p[v] = u
        else:
            self.p[u] = v
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1


road_uf = UnionFind(n)
train_uf = UnionFind(n)

for p, q in pq:
    p -= 1
    q -= 1
    road_uf.unite(p, q)

for r, s in rs:
    r -= 1
    s -= 1
    train_uf.unite(r, s)

group = [(road_uf.find_set(i), train_uf.find_set(i)) for i in range(n)]

c = Counter(group)

ans = []
for e in group:
    ans.append(c[e])

print(*ans)


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

vector<int> c(26);
vector<vector<int>> s(365 ,vector<int>(26));
vector<vector<int>> last(365 ,vector<int>(26));

int culc(int d){
    int ret;
    int maxv=0;
    rep(j,26){
        if(s[d][j]+c[j]*(d+1-last[d][j])>maxv){
            maxv=s[d][j]+c[j]*(d+1-last[d][j]);
            ret=j+1;
        }
    }
    return ret;
}

int main(){
    int D;
    cin>>D;
    rep(i,26){ 
        cin>>c[i];
    }
    rep(d,D) rep(j,26) cin>>s[d][j];
    int t;
    int v=0;
    vector<int> kaisai_bi(26);
    int ans=18398+s[1][16];
    rep(j,26){
        if(j==16)continue;
        else if(j==0)ans-=c[j]*(2-1);
        else ans-=c[j]*(2-0);
    }
    rep(d,D) {
//        cin>>t;
        t=culc(d);
        cout<<t<<endl;
        t--;
        v+=s[d][t];
        kaisai_bi[t]=d+1;
        rep(j,26) last[d][j]=kaisai_bi[j];
        rep(j,26){ 
            v-=c[j]*(d+1-last[d][j]);
            }
    }
//    cout<<v<<endl;

    int m;
//    cin>>m;
m=0;
    rep(i,m){
        int dd,q;
        cin>>dd>>q;
        q--;
        int j=0;
        while(last[dd-1][j]!=dd || j>=26) j++;
        if(j==26){ 
            cout<<"error"<<endl;
            return 0;
        }
        v-=s[dd-1][j];
        for(int d=dd-1;d<D;d++){ 
            if(last[d][j]==dd){
                v+=c[j]*(d+1-last[d][j]);
                last[d][j]=(d==0? 0 : last[d-1][j]);
                v-=c[j]*(d+1-last[d][j]);
            }
            else{ 
                break;
            }
        }
        
        v+=s[dd-1][q];
        int before=last[dd-1][q];
        for(int d=dd-1;d<D;d++){ 
            if(last[d][q]==before){ 
                v+=c[q]*(d+1-last[d][q]);
                last[d][q]=dd;
                v-=c[q]*(d+1-last[d][q]);
            }
            else{ 
                break;
            }
        }
        cout<<v<<endl;
    }
    return 0;
}


Measured memory_bytes: 3732
#include<stdio.h>

int main(){

        char inputchar[7];

        scanf("%c%c%c%c%c%c",&inputchar[0],&inputchar[1],&inputchar[2],&inputchar[3],&inputchar[4],&inputchar[5]);

        if(inputchar[2] == inputchar[3]){
                        if(inputchar[4]==inputchar[5])
                        {
                        printf("Yes");
                        }else{
                                printf("No");
                        }
        }
                        else{
                                printf("No");
                        }
return 0;

}

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

#define MAXN 100005

typedef long long lint;

using namespace std;

const int mod = 1e9 + 7;
int n, a[MAXN], val[MAXN], deg[MAXN];
int sum[MAXN];
lint f[MAXN];
bool oncir[MAXN];
int visit[MAXN];
lint ans = 1;

int read() {
    char c = getchar();
    int x = 0;
    while (!isdigit(c))
        c = getchar();
    while (isdigit(c)) {
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x;
}

void calc(int u) {
    vector<int> g;
    while (oncir[u]) {
        oncir[u] = false;
        g.push_back(u);
        u = a[u];
    }
    reverse(g.begin(), g.end());
    int first = -1, last = -1;
    for (int i = 0; i < (int)g.size(); ++i) {
        int u = g[i];
        if (val[u]) {
            if (!(~first)) {
                last = first = i;
                continue;
            }
            int l1 = val[g[last]], l2 = i - last;
            ans = ans * ((l2 > l1) + (l2 >= l1)) % mod;
            last = i;
        }
    }
    if (~first && first == last) {
        int l1 = val[g[last]], l2 = (int)g.size();
        ans = ans * ((l2 > l1) + (l2 >= l1)) % mod;
    }
    else if (~first) {
        int l1 = val[g[last]], l2 = (int)g.size() - last + first;
        ans = ans * ((l2 > l1) + (l2 >= l1)) % mod;
    }
    else
        ++sum[(int)g.size()];
}

void solve() {
    for (int i = 1; i <= n; ++i)
        if (oncir[i])
            calc(i);
    for (int i = 1; i <= n; ++i) {
        f[0] = 1;
        for (int j = 1; j <= sum[i]; ++j) {
            if ((i & 1) && i != 1)
                f[j] = f[j - 1] * 2 % mod;
            else
                f[j] = f[j - 1];
            if (j > 1)
                f[j] = (f[j] + f[j - 2] * i % mod * (j - 1) % mod) % mod;
        }
        ans = ans * f[sum[i]] % mod;
    }
}

int main() {
//    freopen("1_12.txt", "r",stdin);
    n = read();
    for (int i = 1; i <= n; ++i) {
        a[i] = read();
        ++deg[a[i]];
    }
    for (int i = 1; i <= n; ++i) {
        int u = i;
        if (visit[u])
            continue;
        while (!visit[u]) {
            visit[u] = i;
            u = a[u];
        }
        if (visit[u] != i)
            continue;
        while (!oncir[u]) {
            oncir[u] = true;
            u = a[u];
        }
    }
    for (int i = 1; i <= n; ++i)
        if ((oncir[i] && deg[i] > 2) || (!oncir[i] && deg[i] > 1)) {
            puts("0");
            return 0;
        }
    for (int i = 1; i <= n; ++i) {
        if (deg[i])
            continue;
        int u = i, d = 0;
        while (!oncir[u]) {
            u = a[u];
            ++d;
        }
        val[u] = d;
    }
    solve();
    printf("%lld\n", ans);
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return true;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, m, a[305][305];
bool b[305];
signed main() {
	cin >> n >> m;
	rep(i, n)rep(j, m) {
		cin >> a[i][j]; a[i][j]--;
	}
	rep(i, m)b[i] = true;
	int ans = inf;
	rep(i, m) {
		int cnt[305];
		rep(j, m)cnt[j] = 0;
		rep(j, n) {
			rep(k, m) {
				if (b[a[j][k]]) {
					cnt[a[j][k]]++; break;
				}
			}
		}
		int index, ma = 0;
		rep(j, m) {
			if (ma < cnt[j]) {
				ma = cnt[j]; index = j;
			}
		}
		chmin(ans, ma);
		b[index] = false;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
H,W = map(int, input().split())
S = [["#"] * (W + 2)]
S += [["#"] + list(input()) + ["#"] for _ in range(H)]
S.append(["#"] * (W + 2))

DX = [0,0,-1,1]
DY = [-1,1,0,0]

from collections import deque

def bfs(y,x):
    dist = [[-1] * (W + 2) for _ in range(H + 2)] 
    
    que = deque([(y, x)])
    dist[y][x] = 0
    while que:
        y, x = que.popleft()
        d = dist[y][x]
        for dy,dx in zip(DY,DX):
            ny, nx = y + dy, x + dx
            if S[ny][nx] == "#": continue
            if dist[ny][nx] < 0:
                dist[ny][nx] = d + 1
                que.append((ny,nx))
    
    ans = -1
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            ans = max(ans, dist[i][j])
    return ans

ans = 0
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == "#": continue
        ans = max(ans, bfs(i, j))

print(ans)

Measured memory_bytes: 3444
x, n = map(int, input().split())
try:
  p = list(map(int, input().split()))
except:
  p = []

if n != 0:
  ans = None
  for i in range(n + 1):
    if x - i not in p:
      ans = x - i
      break
    if x + i not in p:
      ans = x + i
      break
  if not ans is None:
    print(ans)
  else:
    print(x - n - 1)
else:
  print(x)

Measured memory_bytes: 9204
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in).useDelimiter("[,\n]");
		
		int map[][] = new int[10][10];
		
		int drop1[][] = {
			{0,1,0},
			{1,1,1},
			{0,1,0},
		};
		int drop2[][] = {
			{1,1,1},
			{1,1,1},
			{1,1,1},
		};
		int drop3[][] = {
			{0,0,1,0,0},
			{0,1,1,1,0},
			{1,1,1,1,1},
			{0,1,1,1,0},
			{0,0,1,0,0}
		};
		
		while (true)
		{
			int x, y, size;
			try
			{
				x = sc.nextInt();
				y = sc.nextInt();
				size = sc.nextInt();
			}
			catch (Exception e)
			{
				break;
			}
			
			if (size == 1)
			{
				for (int i = 0; i < 3; i++)
				{
					for (int j = 0; j < 3; j++)
					{
						try
						{
							map[x-1+i][y-1+j] += drop1[i][j];
						}
						catch (ArrayIndexOutOfBoundsException e){continue;}
					}
				}
			}
			else if (size == 2)
			{
				for (int i = 0; i < 3; i++)
				{
					for (int j = 0; j < 3; j++)
					{
						try
						{
							map[x-1+i][y-1+j] += drop2[i][j];
						}
						catch (ArrayIndexOutOfBoundsException e){continue;}
					}
				}
			}
			else if (size == 3)
			{
				for (int i = 0; i < 5; i++)
				{
					for (int j = 0; j < 5; j++)
					{
						try
						{
							map[x-2+i][y-2+j] += drop3[i][j];
						}
						catch (ArrayIndexOutOfBoundsException e){continue;}
					}
				}
			}
		}
		int count = 0;
		int max = 0;
		for (int i = 0; i < 10; i++)
		{
			for (int j = 0; j < 10; j++)
			{
				if (map[i][j] == 0) count++;
				max = Math.max(max, map[i][j]);
			}
		}
		System.out.println(count);
		System.out.println(max);
	}
}

Measured memory_bytes: 11000
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = [0, 0]
for ea, eb in zip(a, b):
    if ea > eb:
        cnt[1] += ea - eb
    else:
        cnt[0] += (eb - ea) // 2

if cnt[0] >= cnt[1]:
    ans = "Yes"
else:
    ans = "No"
print(ans)


Measured memory_bytes: 4596
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    string res(n * 2, ' ');

    int calls = 0;
    auto ask = [&](const vector<int>& A) -> int  {
        ++calls;
        cout << "?";
        int n = A.size();
        for (int i = 0; i < n; ++i) {
            cout << " " << A[i];
        }
        cout << endl;
        string ans;
        cin >> ans;
        if (ans == "Red") {
            return 0;
        } else if (ans == "Blue") {
            return 1;
        }
        return -1;
    };


    auto answer = [&]() {
        cout << "! ";
        cout << res << endl;
    };

    string S = "RB";

    auto gen = [&](int beg, int n) {
        vector<int> res;
        for (int j = 0; j < n; ++j) {
            res.push_back(beg + j);
        }
        return res;
    };

    int c1 = ask(gen(1, n));
    if (c1 == -1) {
        return 0;
    }
    int mid = 0;
    for (int i = 6; i >= 0; --i) {
        int x = mid + (1 << i);
        if (x <= n) {
            int c2 = ask(gen(x + 1, n));
            if (c2 == c1) {
                mid = x;
            } else if (c2 == -1) {
                return 0;
            }
        }
    }

    res[mid] = S[c1];
    res[mid + n] = S[c1 ^ 1];

    vector<int> A;
    vector<int> B;
    for (int i = 0; i < 2 * n; ++i) {
        if (i > mid && i < mid + n) {
            A.push_back(i + 1);
        } else if (i < mid || i > mid + n) {
            B.push_back(i + 1);
        }
    }

    for (auto x : A) {
        auto arr = B;
        arr.push_back(x);
        int c = ask(arr);
        if (c == -1) {
            return 0;
        }
        res[x - 1] = S[c];
    }
    for (auto x : B) {
        auto arr = A;
        arr.push_back(x);
        int c = ask(arr);
        if (c == -1) {
            return 0;
        }
        res[x - 1] = S[c];
    }

    answer();

    return 0;
}

Measured memory_bytes: 724
def prime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    for i in range(3, int(x**0.5)+1, 2):
        if x % i == 0:
            return False
    return True

n, cnt = int(input()), 0
for i in range(n):
    x = int(input())
    if prime(x):
        cnt += 1
print(cnt)



Measured memory_bytes: 5676
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1359",problemID = "C",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    n = inp()
    a = inlt()
    q = 1
    for i in range(n):
        q = q * a[i]
        if q > 10 ** 18:
            q = -1
            break
    if 0 in a:
        q = 0
    print(q)
                
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
    sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))

#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline  
main()

Measured memory_bytes: 82636
import Control.Monad
calc [] ac wa tle re = [ac, wa, tle, re]
calc (s:ss) ac wa tle re =
    case s of
        "AC" -> calc ss (ac+1) wa tle re
        "WA" -> calc ss ac (wa+1) tle re
        "TLE" -> calc ss ac wa (tle+1) re
        "RE" -> calc ss ac wa tle (re+1)

main = do
    n <- readLn
    ss <- replicateM n getLine
    let [ac, wa, tle, re] = calc ss 0 0 0 0
    putStrLn $ "AC x " ++ show ac
    putStrLn $ "WA x " ++ show wa
    putStrLn $ "TLE x " ++ show tle
    putStrLn $ "RE x " ++ show re

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

typedef pair<int, int> PII;
typedef long long ll;

const int MOD = 1e9+7;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	queue<int> w;
	stack<int> r;
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		if (c=='R') r.push(i);
		else w.push(i);
	}
	int ans = 0;
	while (!w.empty()&&!r.empty()) {
		if (w.front()>r.top()) break;
		w.pop();r.pop();ans++;
	}
	cout << ans << "\n";
}

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

namespace ABC115A
{
    class Program
    {
        static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            if (D == 25)
                Console.WriteLine("Christmas");
            else if (D == 24)
                Console.WriteLine("Christmas Eve");

            else if (D == 23)
                Console.WriteLine("Christmas Eve Eve");
            else if (D == 22)
                Console.WriteLine("Christmas Eve Eve Eve");

            Console.ReadKey();




        }
    }
}


Measured memory_bytes: 11092
K, S = map(int, input().split())
ans = 0

for i in range(K + 1):
    s = i
    if s > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        Z = S - s
        if 0 <= Z <= K:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <set>
#include <vector>

using namespace std;
#define ll long long

int main () {
  ll n;
  cin >> n;
  ll b[n], stand[n];
  for (ll i = 0; i < n; i++) {
    cin >> b[i];
    stand[i] = 0;
  }    
  vector<ll> ans;
  int length = 0;
  int itr = -1;
  for (int i = 0; i < n; i++) {
    // n回操作を行う．
    length = 0;
    itr = -1;
    for (int j = 0; j < n; j++) {
      if (stand[j] == 1) continue;
      length++;
      if (length == b[j]) {
        itr = j;  
      }  
    }   
    if (itr != -1) {
      ans.push_back(b[itr]);
      stand[itr] = 1;    
    }
  }
  for (int i = 0; i < n; i++) {
    if (stand[i] == 0) {
      cout << -1 << endl;
      return 0;  
    }  
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[ans.size() - 1 - i] << endl;  
  }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int know_digit(ll n)
{
    int ans = 0;
    while(n){
        n /= 10;
        ++ans;
    }
    return ans;
}

int main()
{
    ll i;
    ll k;
    cin >> k;
    queue<string> que;
    for(i = 1;i <= 9;++i){
        string tmp;
        tmp.push_back(i + '0');
        que.emplace(tmp);
    }
    vector<string> ans;
    while(ans.size() < k){
        string tmp = que.front();
        ans.push_back(tmp);
        que.pop();
        char c = tmp.back();
        int j = c - '0';
        for(i = -1;i < 2;++i){
            string kari = tmp;
            ll m = j+i;
            if(m < 0 || m > 9) continue;
            kari.push_back(m + '0');
            que.push(kari);
        }
    }
    cout << ans.at(k-1) << endl; 
    return 0;
}

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

int main()
{   
    double comp;
    int N;
    cin>>N;

    vector <double >v(N);
    for(int i=0; i<v.size();i++)
    {
        cin>>v[i];
    }



    do{
        sort(v.begin(),v.end());

        comp=(v[0]+v[1])/2;
        v.push_back(comp);
        comp=0.0;
        v.erase(v.begin()+0);
        v.erase(v.begin()+0);
        N=N-1;
    }while(N>=1);

    cout<<v[0];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	long long a,b,c,k; cin>>a>>b>>c>>k;
	long long answer ;
	if(k%2 == 0)
		answer = a-b;
	else
		answer = -a + b;
	if(abs(answer) > 1e18)
		cout<<"Unfair\n";
	else
		cout<<answer<<endl; 
	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string str;
	cin >> str;
	for(int i=0;i<3;++i)
	{
		if(str[i] == '7')
		{
			cout << "Yes" << "\n";
			return 0;
		}
	}
	cout << "No" << "\n";
}

Measured memory_bytes: 3640
from math import sqrt

N = int(input())
limit = int(sqrt(N))

res = [0] * (N + 1)
for x in range(1, limit+1):
    for y in range(1, limit+1):
        for z in range(1, limit+1):
            val = x * x + y * y + z * z + x * y + y * z + z * x
            if val <= N:
                res[val] += 1
            else:
                break

for i in range(1, N + 1):
    print(res[i])


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
    }
    int s;
    rep(i, n) {
        if (i == 0) s = a[i];
        else s = s xor a[i];
    }
    int ans[n];
    rep(i, n) {
        ans[i] = s xor a[i];
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5112
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  string s;
  in(s);
  long n=s.size(),cnt=0,l=0,r=n-1;
  while(l<r){
    if(s[l]!=s[r]){
      if(s[l]=='x'){
        cnt++;
        l++;
      }
      else if(s[r]=='x'){
        cnt++;
        r--;
      }else{
        out(-1);
        return;
      }
    }else{
      l++;
      r--;
    }
  }
  out(cnt);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 512
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#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 all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int n;
string s;

void solve(int first,int second) {
  vi v;
  v.pb(first);v.pb(second);
  rep(i,1,n-1) v.pb(v[i]^(s[i]=='x')^v[i-1]);
  rep(i,0,n) if((v[i]^(s[i]=='x'))!=(v[(i-1+n)%n]^v[(i+1)%n]))
    return;
  rep(i,0,n) putchar("SW"[v[i]]);
  exit(0);
}

int main(){
  cin >> n >> s;
  rep(i,0,2) rep(j,0,2)
    solve(i , j);
  puts("-1");
  return 0;
}


Measured memory_bytes: 1444
from math import ceil


def main():
    r, g, b, n = map(int, input().split())
    answer = 0
    for i in range(n + 1):
        for j in range(n + 1 - i * r):
            left = n - i * r - j * g
            if left >= 0 and left % b == 0:
                answer += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940