akhauriyash/Code-Regression huggingface dataset:
import math
X = int(input())

def qprime(n):
    if n<2:return False
    elif n==2:return True
    elif n%2==0:return False
    for i in range(3,math.floor(math.sqrt(n))+1,2):
                   if n % i == 0:return False
    return True


for i in range(X,10000000):
    if qprime(i):
        print(i)
        break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    ll a,b;
    cin >> a >> b;
    ll k = (a + b) / 2;
    if(2 * k == (a + b))
        cout << k << endl;
    else
        cout << "IMPOSSIBLE" << endl;

    return 0;
}



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

int tax(int percent, int price) { // x:税率 i:税抜きの値段
  price = price * (100+percent) / 100;
  return price;
}

int x, y, s;
int main() {
  while (cin >> x >> y >> s && x > 0) {
    int maximum = 0;
    for (int i = 1; i < s; i++) {
      for (int j = i; j < s; j++) {
        if (tax(x, i) + tax(x, j) == s) {
          maximum = max(maximum, tax(y, i) + tax(y, j));
        }
      }
    }

    cout << maximum << endl;

  }

}


Measured memory_bytes: 3120
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

import numpy as np
import time
import random
start = time.time()
D = int(input())
Cs = np.array(list(mapint()))
Ss = np.array([list(mapint()) for _ in range(D)], dtype=np.float64)
last = np.zeros(26, dtype=np.float64)

lis = []
for i in range(D):
    last_2 = i-last
    last_2.astype(np.float64)
    arr = Ss[i] + Cs*last_2
    idx = np.argmax(arr)
    last[idx] = i+1
    lis.append(idx+1)

def check(Ts):
    last_day = np.zeros(26)
    sati = 0
    for i in range(D):
        t = Ts[i]-1
        sati += Ss[i][t]
        last_day[t] = i+1
        sati += sum((last_day-(i+1))*Cs)
    return sati

now = check(lis)
while time.time()-start<1.5:
    num = random.randint(1, 26)
    num2 = random.randint(0, 364)
    if num==num2:
        continue
    lis_2 = lis[:]
    lis_2[num2] = num
    nx = check(lis_2)
    if nx>now:
        lis = lis_2
        now = nx

for d in lis:
    print(d)

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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define TC ll tt; cin>>tt; while(tt--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ size()
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpl vector< pll >

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

    // TC
    {
        // ll ar[5];
        ll c=0;
        loop(i,0,5) {
            ll t;
            cin>>t;
            if(t==0)
                c=i;
        }
        cout<<c+1<<'\n';
    }
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Combination{
	constexpr static int atcoder_mod = 1000000007;
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if (n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}
	ll GetFInv(ll i){
		return finv[i];
	}
};

ll powermod(ll a,ll b,ll m){
	if(b==0){
		return 1LL;
	}
	if(b%2){
		return (a*powermod(a,b-1LL,m))%m;
	}
	return powermod((a*a)%m,b/2LL,m);
}

ll StirlingNumber(ll n,ll k){
	ll sum = 0;
	Combination comb(k);
	for(ll i=1;i<=k;i++){
		ll C = comb.Caluclation(k,i)%atcoder_mod;
		ll P = powermod(i,n,atcoder_mod)%atcoder_mod;
		ll V = (C*P)%atcoder_mod;
		if((k-i)%2){
			sum = (sum-V+atcoder_mod)%atcoder_mod;
		}
		else sum = (sum+V)%atcoder_mod;
	}
	return sum*comb.GetFInv(k)%atcoder_mod;
}

ll BallBoxCombination4(ll n,ll k){
	Combination comb(n+k-1);
	return comb.Caluclation(n+k-1,n);
}

ll BallBoxCombination6(ll n,ll k){
	Combination comb(n-1);
	return comb.Caluclation(n-1,k-1);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),B=in();
	int R=N-B;

	REP(i,B){
		ll NB = BallBoxCombination6(B,i+1);
		ll NR1 = BallBoxCombination4(R-i,i+2);
		out((NB*NR1)%atcoder_mod);
	}
	
	return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
vector<ll>v[3];
ll n, m, ans = INF, dif[33][33], c[550][550],difs[3][33];
int main() {
	cin >> n >> m;
	rep(i, m)rep(j, m) { cin >> dif[i][j]; }
	rep(i, n)rep(j, n)cin >> c[i][j],v[(i+j+2)%3].pb(c[i][j]-1);
	rep(i, m) {
		rep(j, 3) {
			ll a=0;
			rep(k, v[j].size()) {
				a += dif[v[j][k]][i];
			}
			difs[j][i] = a;
		}
	}
	rep(i, m)rep(j, m)rep(k, m) {
		if (i == j || j == k || i == k)continue;
		ll a = 0;
		rep(l, 3) {
			a += difs[l][(l == 0 ? i : (l == 1 ? j : k))];
		}
		ans = min(a, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4516
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k, n, a[200020], c[200020] = {};
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		c[a[i]]++;
	}
	sort(c, c + 200020);
	ll ans = 0, yojo;
	for (int i = 0; i < 200020; i++)if (c[i]) {
		yojo = 200020-i;
		break;
	}
	for (int i = 0; i < 200020; i++) {
		if (!c[i])continue;
		if (yojo <= k)break;
		yojo--;
		ans += c[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n ;
  cin >> n ;
  
  double SUM = 0 ;
  
  for(int i=0;i<n;i++){
    double x ; cin >> x ;
    string u ; cin >> u ;
    
    if(u=="JPY"){
      SUM += x ;
    }else{
      SUM += x*380000 ;
    }
  }

    cout << SUM << endl ;

  return 0 ;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void){
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a + b == 15) {
        cout << '+' << endl;
    } else if (a * b == 15) {
        cout << '*' << endl;
    } else { 
        cout << 'x' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 int n = sc.nextInt();
		 int[][][] heya = new int[4][3][10];
		  for(int i = 0; i < n; i++) {
		 int b = sc.nextInt();
		 int f = sc.nextInt();
		 int r = sc.nextInt();
		 int v = sc.nextInt();
		 heya[b-1][f-1][r-1] += v;         }
		 for(int i = 0; i < 4; i++) {
		 for(int j = 0; j < 3; j++) {
		 for(int k = 0; k < 10; k++) {
		 System.out.print(" " + heya[i][j][k]);}
		 System.out.println();             }
		 if(i != 3) {
		 System.out.println("####################");
		 }
		 }
   }
}

Measured memory_bytes: 21068
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, w, n) for(int i = w; i < n; i++)
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))

const double PI = M_PI;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
const long long INF = 1LL << 60;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(15);
    
    double N; cin >> N;
    cout << PI * pow(N, 2) << ' ' << PI * N * 2 << endl;

    return 0;
}



Measured memory_bytes: 3260
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        
        for(int i = 1; i <= 10; i++) {
        	int xnext = r * x - d;
        	System.out.println(xnext);
        	x = xnext;
        }
    }
}

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

const ll INF = 1LL<<60;

int main(){
    int H,W;
    cin >> H >> W;
    int dp[10][10];
    int A[H][W];

    rep(i,10)rep(j,10){
      cin >> dp[i][j];
    }

    rep(i,H)rep(j,W){
      cin >> A[i][j];
    }

    rep(k,10)rep(i,10)rep(j,10){
      dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k][j]);
    }

    ll ans = 0;
    rep(i,H) rep(j,W){
      ans += dp[A[i][j]][1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
n=int(input())
c=[]
s=[]
f=[]
for i in range(n-1):
    C,S,F=map(int,input().split())
    c.append(C)
    s.append(S)
    f.append(F)
for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<s[j]:t=s[j]
        elif t%f[j]==0:pass
        else:t=t+f[j]-t%f[j]
        t+=c[j]
    print(t)


Measured memory_bytes: 41708
#include<iostream>
#include<math.h>
#include<string>
#include<map>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<stack>
#include<algorithm>
#include<climits>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long int
#define vll vector<ll>
#define mii map<ll, ll>
#define debug(x) cerr << #x << " is " << x << "\n";
#define debug1(x, y) cerr << #x << " is " << x << "\n" << #y << " is " << y << "\n";
#define w(x) ll x; cin >> x; while(x--)
#define endl "\n"
#define f first 
#define s second 
#define fo(n) for(ll i = 0LL; i < n; ++i) 
#define setbits(n) __builtin_popcount(n)
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(x.begin(), x.end())
#define pb push_back
#define mk make_pair
#define PERMUTE next_permutation
#define RESET(a, b) memset(a, b, sizeof(a))
#define MOD 1000000007
using namespace std;
 
int main(){
    fast
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    string ans;
    n %= 10;
    if(n == 3)
    {
        ans = "bon";
    }
    else if(n == 0 || n == 1 || n == 6 || n == 8)
    {
        ans = "pon";
    }
    else
    {
        ans = "hon";
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash>
    //gp_hash_table<long long, int, custom_hash>
};
long long genrand(long long L,long long R)
{
	return uniform_int_distribution<long long>(L, R)(rng);
}
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}

int n, m, q, ans = 0;
vector<int> v;
int a[50], b[50], c[50], d[50];
void solve(int idx){
	if(idx==n){
		int res = 0;
		for(int i = 0; i<q; i++){
			if(v[b[i]] - v[a[i]]==c[i]){
				res += d[i];
			}
		}
		ans = max(ans, res);
		return;
	}
	int st = 1; if(idx) st = v[idx-1];
	for(int i = st; i<=m; i++){
		v.pb(i);
		solve(idx+1);
		v.pop_back();
	}
}

int main() {
	
	scanf("%d%d%d", &n, &m, &q);
	for(int i = 0; i<q; i++){
		scanf("%d%d%d%d", a+i, b+i, c+i, d+i); a[i]--; b[i]--;
	}
	solve(0);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3836
h,w = map(int,input().split())
m = [list(str(input())) for i in range(h)]
for i in range(h):
    for j in range(w):
        if m[i][j] == "#":
            if i == 1:
                if j == 0:
                    obj = [m[i][j+1],m[i+1][j]]
                elif j == w - 1:
                    obj = [m[i][j-1],m[i+1][j]]
                else:
                    obj = [m[i][j-1],m[i][j+1],m[i+1][j]]
            elif i == h - 1:
                if j == 0:
                    obj = [m[i-1][j],m[i][j+1]]
                elif j == w - 1:
                    obj = [m[i-1][j],m[i][j-1]]
                else:
                    obj = [m[i-1][j],m[i][j-1],m[i][j+1]]
            else:
                if j == 0:
                    obj = [m[i-1][j],m[i][j+1],m[i+1][j]]
                elif j == w - 1:
                    obj = [m[i-1][j],m[i][j-1],m[i+1][j]]
                else:
                    obj = [m[i-1][j],m[i][j-1],m[i][j+1],m[i+1][j]]
            
            if "#" not in obj:
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3188
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main() {
  char b;
  cin >> b;
  char o;
  if (b == 'A') {
    o = 'T';
  } else if (b == 'T') {
    o = 'A';
  } else if (b == 'C') {
    o = 'G';
  } else {
    o = 'C';
  } 
  cout << o << endl;
  
  return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  
  int sum=0;
  rep(i,n-1){
    if(s[i]==s[i+1]){
      sum++;
    }
  }
  int ans=min(n-1, sum+2*k);
  cout(ans);
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, q;
    cin >> n >> q;

    dsu d(n);
    for(int i=0; i<q; i++){
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) d.merge(u, v);
        else cout << d.same(u, v) << endl;
    }    

    return 0;
}

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

int main(){
  int n,m=0,l=0;
  cin >> n ;
  int k=n;
  
  while(1){
    m=k%10;
    l=l+m;  
   if(m==k){break;}
    k=(k-m)/10;
  }
  
  if(n%l==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  

}


Measured memory_bytes: 256
import itertools
while True:
    n, x = [int(i) for i in input().split()]
    if n == 0 and x == 0:
        break
    
    count = 0
    for i, j, k in itertools.combinations(range(1, n+1),3):
        if i + j + k == x:
            count = count + 1
    print(count)


Measured memory_bytes: 5640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}


int main (){
    int n,x;
    cin >> n >> x;
    vector<int> l(n);
    Rep(i,n){
        cin >> l[i];
    }
    int d = 0;
    int ans = 1;
    Rep(i,n){
        d = d + l[i];
        if(d <= x) ans++;
        else break;
    }
    cout << ans << "\n";
}

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

int answer(int L, int R){
  if (L + 2018 <= R) return 0;

  int l, r;
  l = L % 2019;
  r = R % 2019;
  if (l > r) return 0;

  int ans = 2019;

  for(int i = l; i < r; i++){
    for(int j = i + 1; j <= r; j++){
      int newans = (i * j) % 2019;
      if (newans < ans) ans = newans;
    }
  }
  return ans;
}


int main(){
  int L, R;
  scanf("%d %d", &L, &R);

  int ans;
  ans = answer(L, R);

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

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  	int len,flag = 0,i;
  	char s[110];
    scanf("%d",&len);
    //getchar(); 
  	scanf("%s",s);
  	//printf("%s",s);
  	if(len&1)flag = 1;
    if(!flag){
      int hl = len/2;
    	for(i = 0;i < hl;i++)
          if(s[i] == s[i+hl])continue;
      	  else {flag=1;break;}
    }
  if(flag)printf("No\n");
  else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
# ABC135C - City Savers
# greedy algorithm
def main():
    n = int(input())
    A = list(map(int, input().rstrip().split()))
    B = tuple(map(int, input().rstrip().split()))
    ans = 0
    for i in range(n):
        cur1 = min(A[i], B[i])
        cur2 = min(A[i + 1], B[i] - cur1)
        A[i] -= cur1
        A[i + 1] -= cur2
        ans += cur1 + cur2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 19116
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, K, ans=0;
    cin >> N >> K;
   vector<int> p(N);
    for(int i=0; i<N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    for(int i=0; i<K; i++){
        ans += p[i];
    }
    cout << ans << endl;
}

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


int main()
{
    int t=1;
    //cin>>t;
    while( t-- )
    {
        ll d,t,s;
        cin>>d>>t>>s;

        if( t*s>=d )
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<pair<string,pair<int,int>>> vec(n);
    for(int i=0;i<n;i++){
        string s;
        int p;
        cin >> s >> p;
        p = 100 - p;
        vec[i].first = s;
        vec[i].second.first = p;
        vec[i].second.second = i;
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<n;i++) cout << vec[i].second.second+1 << endl;
    return 0;

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = []
def chr(a,b):
  #  print(a,b)
    if a >= b:
        a = a%b
    else:
        b = b%a
    if a == 0 or b == 0:
        return(max(a,b))
    else:
        return(chr(a,b))

ans.append(chr(a[0],a[1]))
#print(ans)

for i in range(1,n):
    ans.append(chr(ans[-1],a[i]))
print(ans[-1])

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

const int amax = 1e6;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());

	vector<int> cnt(amax + 1);
	for (int i = 0; i < n; i++) {
		if (cnt[a[i]] == 0) {
			for (int j = a[i]; j < cnt.size(); j += a[i]) cnt[j] = 1;
		}
		else if (cnt[a[i]] == 1) cnt[a[i]] = 2;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (cnt[a[i]] == 1) ans++;
	}
	cout << ans << endl;
}


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

class Main{


	public static void main(String[] args) {
		

		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		long[] T = new long[n];

		long x=1L;
		for(int i = 0;i < n;i++){
			T[i]  = sc.nextLong();
		}
		Arrays.sort(T);

		for(int i = 0;i < n;i++){
			x = lcm(T[i], x);
		}



		System.out.println(x);

	}

	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}
	
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}

}

Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0142
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                HashSet<int> mods = new HashSet<int>();
                for (int i = 1 ; i <= (n - 1) / 2 ; i++) mods.Add((i * i) % n);

                int[] res = new int[(n - 1) / 2 + 1];
                foreach (var item1 in mods)
                {
                    foreach (var item2 in mods)
                    {
                        int diff = item1 - item2;
                        if (diff < 0) diff += n;
                        res[Math.Min(diff, n - diff)]++;
                    }
                }

                for (int i = 1 ; i < res.Count() ; i++)
                {
                    Console.WriteLine(res[i]);
                }             
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16780
n,m,q=map(int,input().split())
req=[tuple(map(int,input().split())) for i in range(q)]
ans=0
def construction(arr):
    global ans
    if len(arr)==n:
        ret=0
        for i in range(q):
            if arr[req[i][1]-1]-arr[req[i][0]-1]==req[i][2]:ret+=req[i][3]
        ans=max(ret,ans)
        return
    if len(arr)==0:
        for i in range(m):
            construction(arr+[i])
        return
    for i in range(arr[-1],m):
        construction(arr+[i])
    return
construction([])
print(ans)

Measured memory_bytes: 9128
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class UnionFind:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


def main():
    N, *XY = map(int, read().split())

    MAX = 100010
    uf = UnionFind(MAX * 2)
    for x, y in zip(*[iter(XY)] * 2):
        uf.union(x, y + MAX)

    x_comp = Counter()
    y_comp = Counter()
    for i in range(MAX):
        x_comp[uf.find(i)] += 1
    for i in range(MAX, 2 * MAX):
        y_comp[uf.find(i)] += 1

    ans = 0
    for k in x_comp.keys():
        ans += x_comp[k] * y_comp[k]

    ans -= N

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 115072
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

int main() {
  string S;
  cin >> S;

  ll count0=0, count1=0;
  rep(i, S.size()) {
    if (S[i] == '0') count0++;
    if (S[i] == '1') count1++;
  }
  ll ans = S.size() - abs(count0 - count1);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//S?§??????????
		int S = sc.nextInt();
		//h??????
		int h = S / 60 / 60;
		//??????
		int m = (S / 60) % 60;
		//s?§?
		int s = S % 60;
		//??¨???
		System.out.println(h + ":" + m + ":" + s);
	}
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n)cin >> v[i];
  sort(ALL(v),greater<ll>());
  ll res = 0;
  priority_queue<ll> que;
  que.push(v[0]);
  for(int i = 1;i < n;i++){
    ll k = que.top();que.pop();
    res += k;
    que.push(v[i]);
    que.push(v[i]);
  }
  cout << res << endl;




  return 0;
}

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

typedef unsigned ui;

ui mx, my;

ui id(ui x, ui y) {
	if (y == 0) return x;
	else if (x == mx) return mx + y;
	else if (y == my) return mx + my + (mx - x);
	else if (x == 0) return mx + my + mx + (my - y);
	else return ~0;
}

struct seg { ui p, i, f; };
bool operator<(seg s1, seg s2) { return s1.p < s2.p; }

int main(void) {
	ios::sync_with_stdio(0); cin.tie(0);
#ifdef _DEBUG
	ifstream cin("1.in");
#endif
	ui n; cin >> mx >> my >> n;

	vector<seg> xv;
	ui cnt = 0;
	while (n--) {
		ui x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		ui u = id(x1, y1), v = id(x2, y2);
		if (!~u || !~v) continue;
		if (u > v) swap(u, v);
		xv.push_back({ u, ++cnt, 0 });
		xv.push_back({ v, cnt, 1 });
	}
	stable_sort(xv.begin(), xv.end());

	bool f = 0;
	vector<ui> st;
	for (seg s : xv) {
		if (s.f) {
			if (st.back() == s.i)
				st.pop_back();
			else
				f = 1;
		}
		else st.push_back(s.i);
		if (f) break;
	}

	if (!f) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int x[10],y[10];
int main() {
	//freopen("in.txt","r",stdin);
	int n,m;
	bool ff=false;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++) {
		scanf("%d%d",&x[i],&y[i]);
	}
	if(n==1) {
		for(int i=0;i<10;i++) {
			bool f=true;
			for(int j=0;j<m;j++) {
				if(i!=y[j]) f=false;
			}
			if(f) {
				printf("%d\n",i);
				ff=true;
				break;
			}
		}
		if(!ff) printf("-1\n");
	}
	else if(n==2) {
		for(int i=10;i<100;i++) {
			bool f=true;
			for(int j=0;j<m;j++) {
				if(x[j]==1&&i/10!=y[j]) f=false;
				if(x[j]==2&&i%10!=y[j]) f=false;
			}
			if(f) {
				printf("%d\n",i);
				ff=true;
				break;
			}
		}
		if(!ff) printf("-1\n");
	}
	else {
		for(int i=100;i<1000;i++) {
			bool f=true;
			for(int j=0;j<m;j++) {
				if(x[j]==1&&i/100!=y[j]) f=false;
				if(x[j]==2&&(i/10)%10!=y[j]) f=false;
				if(x[j]==3&&i%10!=y[j]) f=false;
			}
			if(f) {
				printf("%d\n",i);
				ff=true;
				break;
			}
		}
		if(!ff) printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
vector<vector<int>> G;
pii dfs(int i, int p){
    int zcnt = 0, ans = 0, nu = false, cnt = 0, nn;
    for(auto x: G[i])
        if(x != p){
            cnt++;
            pii d = dfs(x, i);
            if(!d.ff)zcnt++;
            ans+=d.ff;
            if(d.ss)nu = true, nn = d.ff;
        }
    ans += max(0, zcnt-1);
    if(nu)nu = ans==nn;
    if(!cnt)nu = true;
    if(i==p && nu)ans++;
    //cout << i << " " << ans << endl;
    return {ans, nu || zcnt!=0};
}
int S(pii p){ return p.ff + p.ss; }
signed main(){
    int n;
    cin >> n;
    G.resize(n);
    for(int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for(int i = 0; i < n; i++)
        if(G[i].size() == 1)return cout << dfs(i, i).ff << endl, 0;
}


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

typedef long long ll;

const int kN = 1e5 + 5;
const int kP = 4e3 + 5;

int n, cnt = 0; ll s[kN], s2[kN], ns[kN], p[kP];
std::map<ll, int> totb;
bool is_p[kP];
void Sieve() {
	memset(is_p, true, sizeof(is_p));
	is_p[1] = false;
	for(int i = 2; i < kP; ++i) {
		if(is_p[i]) p[++cnt] = i;
		for(int j = 1; j <= cnt && i * p[j] < kP; ++j) {
			is_p[i * p[j]] = false;
			if(i % p[j] == 0) break;
		}
	}
}

int main() {
	scanf("%d", &n); Sieve();
	for(int i = 1; i <= n; ++i) scanf("%lld", s + i);
	for(int i = 1; i <= n; ++i) {
		ns[i] = 1;
		for(int j = 1; p[j] * p[j] * p[j] <= s[i]; ++j) {
			ll cp = p[j] * p[j] * p[j];
			while(s[i] % cp == 0) s[i] /= cp;
		}
		s2[i] = s[i];
		for(int j = 1; p[j] * p[j] * p[j] <= s[i]; ++j)
			if(s[i] % p[j] == 0) {
				if(s[i] % (p[j] * p[j]) == 0) ns[i] *= p[j];
				else ns[i] *= p[j] * p[j];
				while(s[i] % p[j] == 0) s[i] /= p[j];
			}
		ll sqr = (ll)sqrt(s[i]);
		if(sqr * sqr == s[i]) ns[i] *= sqr;
		else if(s[i] <= 1e5) ns[i] *= s[i] * s[i];
		else ns[i] = 0;
		++totb[s2[i]];
	}
	int ans = 0; bool flag = false;
	for(int i = 1; i <= n; ++i) {
		if(s2[i] == 1) { flag = true; continue; }
		ans += std::max(totb[s2[i]], totb[ns[i]]);
		totb[s2[i]] = totb[ns[i]] = 0;
	}
	printf("%d", ans + flag);
	return 0;
}

Measured memory_bytes: 12928
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc = null;
		StringBuilder sb = new StringBuilder(s);
		StringBuilder pres;
		int l1 = s.length();
		while(true) {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		}
		System.out.println(l1 - sb.length());
	}
}


Measured memory_bytes: 27684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    int i,n;
    ll l,s[N];
    cin>>n>>l;
    for(i=0;i<n;i++){
        cin>>s[i];

    } 
    int foo=-1;
    for(i=0;i<n-1;i++){
        if(s[i]+s[i+1]>=l){
            foo=i;
            break;
        }
    }
    if(foo==-1){
        cout << "Impossible\n";
        return 0;
    }
    cout << "Possible\n";
    for(i=0;i<foo;i++){
        cout << i+1 << endl;
    }
    for(i=n-2;i>foo;i--){
        cout <<i+1<<endl;
    }
    cout << foo+1 << endl;


 
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> G[214514];
set<int> si[214514];
int grundy[214514];
set<int> si2[214514];
int grundy2[214514];
signed main(){
  int n;
  cin>>n;
  int p[n];
  int c[n],c2[n];
  for(int i=0;i<n;i++){
    cin>>p[i];
    p[i]--;
    c[i]=c2[i]=0;
  }
  for(int i=0;i<n;i++){
    G[p[i]].push_back(i);
    c[p[i]]++;
    c2[p[i]]++;
  }
  queue<int> q,q2;
  for(int i=0;i<n;i++){
    if(c[i]==0) q.push(i);
    if(c2[i]==0) q2.push(i);
  }
  
  memset(grundy,0,sizeof(grundy));
  while(!q.empty()){
    int x=q.front();q.pop();
    c[p[x]]--;
    if(c[p[x]]==0) q.push(p[x]);
    while(si[x].count(grundy[x])) grundy[x]++;
    si[p[x]].insert(grundy[x]);
  }
  
  memset(grundy2,0,sizeof(grundy2));
  while(!q2.empty()){
    int x=q2.front();q2.pop();
    c2[p[x]]--;
    if(c2[p[x]]==0) q2.push(p[x]);
    while(si2[x].count(grundy2[x])) grundy2[x]++;
    si2[p[x]].insert(grundy2[x]);
  }
  
  for(int i=0;i<n;i++){
    if(c[i]==0) continue;
    //cout<<i<<endl;
    {
      c[p[i]]--;
      if(c[p[i]]==0) q.push(p[i]);
      assert(c[p[i]]==0);
      while(si[i].count(grundy[i])) grundy[i]++;
      si[p[i]].insert(grundy[i]);
      while(!q.empty()){
	int x=q.front();q.pop();
	if(x==i) continue;
	//cout<<x<<":"<<p[x]<<endl;
	c[p[x]]--;
	if(c[p[x]]==0) q.push(p[x]);
	while(si[x].count(grundy[x])) grundy[x]++;
	si[p[x]].insert(grundy[x]);
      }
      bool ok=1;
      for(int j=0;j<n;j++){
	//cout<<"grundy["<<j<<"]:"<<grundy[j]<<endl;
	int tmp=0;
	while(si[j].count(tmp)) tmp++;
	if(tmp!=grundy[j]){
	  ok=0;
	  break;
	}
	if(grundy[p[j]]==grundy[j]){
	  ok=0;
	  break;
	}
      }
      if(ok){
	cout<<"POSSIBLE"<<endl;
	return 0;
      }
    }
    {
      c2[p[i]]--;
      if(c2[p[i]]==0) q2.push(p[i]);
      assert(c2[p[i]]==0);
      while(si2[i].count(grundy2[i])) grundy2[i]++;
      grundy2[i]++;
      while(si2[i].count(grundy2[i])) grundy2[i]++;
      si2[p[i]].insert(grundy2[i]);
      while(!q2.empty()){
	int x=q2.front();q2.pop();
	if(x==i) continue;
	c2[p[x]]--;
	if(c2[p[x]]==0) q2.push(p[x]);
	while(si2[x].count(grundy2[x])) grundy2[x]++;
	si2[p[x]].insert(grundy2[x]);
      }
      bool ok=1;
      for(int j=0;j<n;j++){
	//cout<<"grundy2["<<j<<"]:"<<grundy2[j]<<endl;
	int tmp=0;
	while(si2[j].count(tmp)) tmp++;
	if(tmp!=grundy2[j]){
	  ok=0;
	  break;
	}
	if(grundy2[p[j]]==grundy2[j]){
	  ok=0;
	  break;
	}
      }
      if(ok){
	cout<<"POSSIBLE"<<endl;
	return 0;
      }
    }
    break;
  }
  //assert(0);
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 54016
#include<stdio.h>
int main()
{
	int a, b;

	scanf("%d %d", &a, &b);
	if (1 < a < 100, 1 < b < 100){
		printf("%d %d\n", a*b, 2 * a + 2 * b);
	}
	
	else{ printf("error"); };

	return 0;
}

Measured memory_bytes: 2588
N,M,X=map(int,input().split())
A=list(map(str,input().split()))
count_bef=0
count_aft=0

for i in range(0,X):
  if str(i) in A:
    count_bef += 1
for j in range(X,N+1):
  if str(j) in A:
    count_aft += 1
if count_bef<=count_aft:
  print(count_bef)
else:
  print(count_aft)

Measured memory_bytes: 3064
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    S = [['#' if i < 50 else '.' for j in range(100)] for i in range(100)]

    for n in range(A - 1):
        q, r = divmod(n, 50)
        i = 3 * q + 1 + (r % 2 == 1)
        j = r
        S[i][j] = '.'

    for n in range(B - 1):
        q, r = divmod(n, 50)
        i = 3 * q + 51 + (r % 2 == 1)
        j = r
        S[i][j] = '#'

    print(100, 100)
    for row in S:
        print(''.join(row))

    return


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    char s[3];
    while(scanf("%s",s)!=EOF)
    {
        int n=strlen(s);
        if(n==3)
       {
        for(int i=2;i>=0;i--)
        {
            printf("%c",s[i]);
        }
       }
    else if(n==2)
        printf("%s\n",s);
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String O = sc.nextLine();
		String E = sc.nextLine();
		int l = Math.min(O.length(), E.length());

		String pass = "";
		for(int i=0;i<l;i++) {
			pass = pass + O.substring(i, i+1);
			pass = pass + E.substring(i, i+1);
		}

		if(O.length() != E.length()) {
			pass = pass + O.substring(O.length()-1);
		}

		System.out.println(pass);
	}
}

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

int main()
{
    int w;
char ch;
    int num[31];
    cin>>w;
    for(int i=1;i<=w;i++){
        num[i]=i;
    }
   int n;
   cin>>n;
   while(n--){
       int a,b;
       cin>>a>>ch>>b;
        swap(num[a],num[b]);
   }
   for(int i=1;i<=w;i++){
       cout<<num[i]<<endl;
   }
    return 0;
}


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
  int n;
  int a[1000];
  cin >> n;
  for(int i= 0;i < n;i++){
    cin >> a[i];
  }
  for(int i = 0;i < n/2;i++){
    int c = a[i];
    a[i] = a[n-i-1];
    a[n-i-1] = c;
  }
  for(int i = 0;i < n;i++){
    cout << a[i];
    if(i != n-1){
      cout << " ";
    }   
  }
  cout << endl;
}

Measured memory_bytes: 3108
from functools import reduce

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(lambda x, y: (x*y)%p, range(n, n - r, -1))
    denom = reduce(lambda x, y: (x*y)%p, range(1, r + 1))
    return (numer * pow(denom, p-2, p)) % p

p = 10 ** 9 + 7
n, a, b = map(int, input().split())

ans = pow(2, n, p) - 1
ans -= cmb(n, a, p) + cmb(n, b, p)
print(ans % p)

Measured memory_bytes: 3684
#include<stdio.h>
int main(void){
	int a[10000],i,n,min,max;
	long int sum;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	min=a[0];
	max=a[0];
	sum=a[0];
	
	for(i=1;i<n;i++){
		if(a[i]<min){
			min=a[i];
		}
		if(max<a[i]){
			max=a[i];
		}
		sum+=a[i];
	}
	
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}


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

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

    int ans = 0;
    for (int i = 105; i <= n; i++)
    {
        if (i % 2 == 0) continue;

        int cnt = 0;
        for (int j = 1; j <= i; j++)
            cnt += int(i % j == 0);
        // cout << cnt << endl;
        if (cnt == 8)
            ans ++;
    }
    cout << ans << endl;
    // cout << int(true) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define zero(x) (((x)>0?(x):-(x))<eps)
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int>PII;
typedef pair<int,string>PIS;
const double eps=1e-9;
const double pi=acos(-1.0);
const int inf=1e9+7;
const int INF=0x3f3f3f3f;
//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;}
int a[100010];

int main(){
//    freopen("in.in","r",stdin);
//    freopen("out.out",";w",stdout);
    int n,c,k;
    cin>>n>>c>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int tmp=a[0];
    int ans=0,cnt=1;
    for(int i=1;i<n;i++){
        if(a[i]-tmp>k||cnt==c){
            tmp=a[i];
            ans++;
            cnt=0;
        }
        cnt++;
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 640