akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int N,A,B,C,D,ans;
    bool F=true;
    string S,T;
int main(){
    cin>>N>>A;
    N%=500;
    cout<<(N<=A?"Yes":"No")<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	int n1 = n - 1;
	for (int mask = 0; mask < (1 << n1); mask++)
	{
		//vi v;
		map<int, int>m1;
		zip(i, 0, n1)
		{
			if (mask & (1 << i))
			{
				//v.pb(i);
				m1[i]++;
			}
		}
		string t = s;
		int pre = 0;
		zip(i, 0, n)
		{
			if (m1[i])
			{
				string x = s.substr(pre, i - pre + 1);
				int y = 0;

				if (x.size() > 0)
				{
					stringstream geek(x);
					geek >> y;
					ans += y;
				}


				pre = i + 1;
			}
		}
		string x1 = s.substr(pre, n - pre);
		int y1 = 0;
		if (x1.size())
		{
			stringstream geek(x1);
			geek >> y1;
			ans += y1;

		}
		// if (x1.size())

	}
	cout << ans << en;



	return 0;
}



Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner vd = new Scanner(System.in);
		int l = vd.nextInt() + vd.nextInt();
		int r = vd.nextInt() + vd.nextInt();
		
		vd.close();
		if(l>r)System.out.println("Left");
		if(l==r)System.out.println("Balanced");
		if(l<r)System.out.println("Right");
		
	}

}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		int [] list = new int []  {A+B,A-B,A*B};
		Arrays.sort(list) ;

		System.out.println( list[2] );
	}
}

Measured memory_bytes: 21844
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};
vvll g(10,vll(10,0));
ll dfs(ll v,ll n,vector<bool> vis){
    bool all_v = true;
    rep(i,n) if(!vis[i]) all_v = false;
    if(all_v) return 1;
    int ret=0;
    rep(i,n){
        if(!g[v][i]) continue;
        if(vis[i]) continue;

        vis[i]=true;
        ret += dfs(i,n,vis);
        vis[i] = false;
    }
    return ret;
}

int main(){
    ll n,m;
    cin >> n >> m;
    vll a(m),b(m);
    rep(i,m) {
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        g[a[i]][b[i]] = 1;
        g[b[i]][a[i]] = 1;
    }
    vector<bool> c(n,false);
    c[0]=true;
    cout << dfs(0,n,c) << endl;;
    return 0;
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;


const int N=2e5+5;
ll f[N],invf[N];

int mul(int a, int b) {
    return (ll) a * b % mod;
}
int my_pow(int a, int b) {
    int r = 1;
    while(b) {
        if(b % 2) {
            r = mul(r, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return r;
}
int inv_fac(int a) {
    return my_pow(a, mod - 2);
}
 
int binomial(int a, int b) {
    if(a < 0 || b < 0 || b > a) {
        return 0;
    }
    return mul(f[a], mul(invf[b], invf[a-b]));
}
 
int fa(int a, int b) {
    int tmp = binomial(a + b, b);
    //~ debug() << imie(a) imie(b) imie(tmp);
    return tmp;
}

ll mpow(ll x, ll y){ 
    ll res = 1;
    x = x % mod;
    while (y > 0) { 
        if (y & 1) res = (res * x) % mod; 
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
  
ll modInv(ll n){ 
    return mpow(n,mod-2); 
} 

void fact(){
    f[0]=1;
    invf[0]=1;
    for(ll i=1;i<N;i++){
        f[i]=(f[i-1]*i)%mod; 
        invf[i]=inv_fac(f[i]);
    }
}

ll paths(pair<ll,ll> p1, pair<ll,ll> p2){
    ll a=p1.first, b=p1.second, x=p2.first, y=p2.second;
    return ((f[x-a+y-b]*modInv(f[x-a]))%mod*modInv(f[y-b]))%mod;
}

ll paths1(pair<ll,ll> p1, pair<ll,ll> p2){
    ll a=p2.first - p1.first, b=p2.second - p1.second;
    return (f[a+b]*(modInv(f[a])*modInv(f[b]))%mod)%mod;
}

const int M=1e3+5;
//ll dp[M];
ll n,m,k;

bool comp(pair<ll,ll> a, pair<ll,ll> b){
    return a.first+a.second<b.first+b.second;
}


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    fact();
    cin>>n>>m>>k;
    ll x,y;
    vector<pair<ll,ll>> a(k);
    for(ll i=0;i<k;i++){
        cin>>a[i].first>>a[i].second; 
    }
    sort(a.begin(),a.end(),comp);
    a.pb({n,m});
    k=a.size();
    vector<ll> dp(k);
    //memset(dp,-1,sizeof(dp));
    for(ll i=0;i<k;i++){
        ll p=fa(a[i].first-1, a[i].second-1), sub=0;
        for(ll j=0;j<i;j++){
            if(a[j].first<=a[i].first && a[j].second<=a[i].second)
                p=(p-mul(dp[j],fa(a[i].first - a[j].first, a[i].second-a[j].second))+mod)%mod;
        }
        dp[i]=p;
    }
    cout<<dp[k-1];


    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int a, b, c;
	int c7 = 0, c5 = 0;
	cin >> a >> b >> c;
	if (a == 5) {
		c5++;
	} else {
		c7++;
	}
	if (b == 5) {
		c5++;
	} else {
		c7++;
	}
	if (c == 5) {
		c5++;
	} else {
		c7++;
	}
	cout << (c5 == 2 && c7 == 1? "YES" : "NO") << endl;
	return 0;
}



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

typedef long long ll;

int main() {
    ll N, D, X, Y, ans = 0;
    cin >> N >> D;
    rep(i, N) {
        cin >> X >> Y;
        if (X * X + Y * Y <= D * D) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;

ll N;
ll ans;
ll a[300300];
int main(){
  cin >> N;
  rep(i,N*3){
    cin >> a[i];
  }
  sort(a,a+3*N);
  rep(i,N){
    ans += a[3*N-2-2*i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 2688
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
	ll N;
	vector<int> A;
	cin >> N;
	for(int i = 0; i < N; i++){
		ll a;
		cin >> a;
		A.push_back(a);
	}
	
	sort(A.begin(), A.end());
	
	vector<ll> first;
	vector<ll> second;
	
	while(A.size() >1 ){
		int a = A.back();
		int a_ = A[A.size()-2];
		if(a > 0 && a_ > 0){
			A.pop_back();
			first.push_back(A.front());
			second.push_back(a);
			A.front() -= a;
		}else{
			int b = A.front();
			A.erase(A.begin(), A.begin()+1);
			first.push_back(A.back());
			second.push_back(b);
			A.back() -= b;
		}
	}
	
	cout << A[0] << endl;
	for(int i = 0; i < first.size(); i++){
		cout << first[i] << " " << second[i] << endl;
	}
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}

int main() {
  int64_t a, b, c, d, n;
  cin >> a >> b >> c >> d >> n;
  a *= 4;
  b *= 2;
  int64_t x = min(min(a, b), min(b, c));
  if (x*2 <= d) {
    cout << x*n << endl;
  } else {
    if (n%2 == 0) {
      cout << (n/2)*d << endl;
    } else {
      cout << (n/2)*d+x << endl;
    }
  }
}

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

int n, m, q;
vector<vector<int>> v(50, vector<int>(4, 0));

int dfs(vector<int> a) {  // 最大を返す
  int ans = 0;
  if (a.size() == n) {
    for (int i = 0; i < q; i++) {
      if (a[v[i][1] - 1] - a[v[i][0] - 1] == v[i][2])
        ans += v[i][3];
    }
  } else {
    int las = (a.size() == 0) ? 1 : a[a.size() - 1];
    for (int i = las; i <= m; i++) {
      a.push_back(i);
      ans = max(ans, dfs(a));
      a.pop_back();
    }
  }
  return ans;
}

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

int main() {
  cin >> n >> m >> q;
  v.resize(q);
  for (int y = 0; y < q; y++)
    for (int x = 0; x < 4; x++)
      cin >> v[y][x];
  cout << dfs(vector<int>{}) << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}


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

int main() {
	int n, ans = 0;
	cin >> n;
	vector<int> a(n);
	rep(i,n) {
		cin >> a[i];
		if(i%2 == 0 && a[i]%2 == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>//たてH cm よこ W cm の長方形を描くプログラム

int main(void){
 
	int a,b,i,j;

	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)
			break;
		for(i=0;i<a;i++){
			if(i==0||i==(a-1)){
				for(j=0;j<b;j++)
					printf("#");
			}
			else {
				printf("#");
				for(j=1;j<b-1;j++)
					printf(".");
				printf("#");
			}
				printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <stdio.h>

int main(void)
{
	int num[2][4];
	int h_count = 0;
	int b_count = 0;
	int i, j;

	while (scanf("%d %d %d %d", &num[0][0], &num[0][1], &num[0][2], &num[0][3]) != EOF) {
		scanf("%d %d %d %d", &num[1][0], &num[1][1], &num[1][2], &num[1][3]);
		h_count = 0;
		b_count = 0;

		for (i = 0; i < 4; i++) {
			if (num[1][i] == num[0][i]) {
				h_count++;
			}

			for (j = 0; j < 4; j++) {
				if (num[1][i] != num[0][i] &&
					num[1][i] == num[0][j]) {
					b_count++;
				}
			}
		}

		printf("%d %d\n", h_count, b_count);
	}

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

void prime_factorization(ll N, map<ll, int>& res) {
  if(N == 1 || N == 0) return;
  ll n = N;
  ll i = 2;
  while(n >= i * i) {
    while(n % i == 0) {
      if(res.count(i)) res[i]++;
      else res[i] = 1;
      n /= i;
    }
    if(i == 2) i++;
    else i += 2;
  }
  if(n != 1) res[n]++;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<ll, int> mp;
  for(int i=1; i<=N; i++) {
    prime_factorization(i, mp);
  }
  ll ans = 1;
  for(auto m: mp) {
    (ans *= (m.second+1)) %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	vector<ll> a(q + 1);
	a[0] = n;
	for (int i = 1; i <= q; ++i) {
		scanf("%lld", &a[i]);
	}
	map<ll, ll> cnt; // [0,r] -> c
	cnt[a[q] - 1] = 1;
	for (int i = q - 1; i >= 0; --i) {
		auto it = cnt.lower_bound(a[i]);
		while (it != cnt.end()) {
			ll x = it->first;
			ll c = it->second;
			assert(x >= a[i]);
			if ((x + 1) % a[i]) cnt[(x + 1) % a[i] - 1] += c;
			cnt[a[i] - 1] += (x + 1) / a[i] * c;
			cnt.erase(it++);
		}
	}
	vector<ll> ans(n);
	for (auto& x : cnt) {
		assert(x.first < n);
		ans[x.first] += x.second;
	}
	for (int i = n - 2; i >= 0; --i) {
		ans[i] += ans[i + 1];
	}
	for (ll x : ans) printf("%lld\n", x);
}


Measured memory_bytes: 9088
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        int cnt = 0;
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == s.charAt(i+1)) {
                cnt++;
            }
        }
        System.out.println(cnt > 0? "Bad":"Good");
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=8005,mod=998244353;
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  if(x<0) x+=mod;
  return x;
}
int mult(int x,int y)
{
  ll tmp=(ll)x*y;
  if(tmp>=mod) tmp%=mod;
  return tmp;
}
int ncr[N][N],pw[N];
int calc(int n,int r)
{
  return ncr[n+r-1][r-1];
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  rep(i,0,N) ncr[i][0]=1;
  rep(i,1,N)
    rep(j,1,i+1)
    ncr[i][j]=add(ncr[i-1][j],ncr[i-1][j-1]);
  pw[0]=1;
  rep(i,1,N) pw[i]=mult(pw[i-1],2);
  int n,k;
  cin>>n>>k;
  swap(n,k);
  rep(i,2,2*k+1)
    {
      int ans=0;
      if(i<=k)
	{
	  if(i&1)
	    {
	      int x=i/2,useless=k-i+1;
	      rep(j,0,x+1)//these many occur at least once
		ans=add(ans,mult(ncr[x][j],mult(pw[j],calc(n-j,useless+j))));
	    }
	  else
	    {
	      int x=i/2-1,useless=k-i+1;
	      rep(j,0,x+1)//these many occur at least once
		ans=add(ans,mult(ncr[x][j],mult(pw[j],calc(n-j,useless+j))));
	      rep(j,0,x+1)//these many occur at least once
		ans=add(ans,mult(ncr[x][j],mult(pw[j],calc(n-1-j,useless+j))));
	    }
	}
      else
	{
	  if(i&1)
	    {
	      int x=k-i/2,useless=k-2*x;
	      rep(j,0,x+1)//these many occur at least once
		ans=add(ans,mult(ncr[x][j],mult(pw[j],calc(n-j,useless+j))));
	    }
	  else
	    {
	      int x=k-i/2,useless=k-1-2*x;
	      rep(j,0,x+1)//these many occur at least once
		ans=add(ans,mult(ncr[x][j],mult(pw[j],calc(n-j,useless+j))));
	      rep(j,0,x+1)//these many occur at least once
		ans=add(ans,mult(ncr[x][j],mult(pw[j],calc(n-1-j,useless+j))));
	    }
	}
      cout<<ans<<endl;
    }
  return 0 ;
}


Measured memory_bytes: 248960
#include<bits/stdc++.h>
using namespace std;
int n,arr[5],x;
double dp[305][305][305];
int vis[302][305][305];

double solve(int a,int b,int c)
{
    if(!a && !b && !c)
        return 0;
    if(vis[a][b][c])
        return dp[a][b][c];
    vis[a][b][c]=1;
    if(c)
        dp[a][b][c]+=solve(a,b+1,c-1)*c/n;
    if(b)
        dp[a][b][c]+=solve(a+1,b-1,c)*b/n;
    if(a)
        dp[a][b][c]+=solve(a-1,b,c)*a/n;
    return dp[a][b][c] = (dp[a][b][c]+1)*n/(a+b+c);
}
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>x;
        arr[x]++;
    }
    cout<<fixed<<setprecision(10)<<solve(arr[1],arr[2],arr[3])<<endl;
}


Measured memory_bytes: 330112
#include<stdio.h>
int main(void){
	int A,B;
	int i,cnt=0;
	scanf("%d %d",&A,&B);
	for(i=A;i<=B;i++){
		cnt+=i/10000==i%10 && (i/1000)%10==(i%100)/10;
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String[] arr = line.split(" ");

        // String型をint型に変換
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);

        int x;
        int y;

        if(a > b){
            x = a;
            y = b;
        } else{
            x = b;
            y = a;
        }

        // ユークリッドの互除法
        int c;
        while((c = x % y) != 0){
            x = y;
            y = c;
        }

        System.out.println(y);
        sc.close();

    }
}


Measured memory_bytes: 26152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define OUT(s) cout << s << "\n";
#define S_LEN(s) s.length();
#define L_LEN(l) sizeof(l) / sizeof(l[0]);
using namespace std;
string S;


void Main(){
    if (S.substr(2, 1) == S.substr(3, 1) && S.substr(4, 1) == S.substr(5, 1)) {
        OUT("Yes");
    } else {
        OUT("No");
    }
}

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

    cin >> S;

    Main();
    return 0;
}


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

typedef struct{
	int n, cost;
}Data;

typedef struct{
	Data data;
	int prior;
}node;

typedef struct{
	node* nodes;
	int arr_sz;  /*???????????????????????????*/
	int que_sz;  /*?¬????????´?????????´????????????*/
}priority_queue;

node* my_realloc(node* old_ptr, int old_sz, int new_sz){
	node* new_ptr = (node*)malloc(sizeof(node) * new_sz);
	if(old_sz){
		memcpy(new_ptr, old_ptr, sizeof(node) * old_sz);
		free(old_ptr);
	}
	return new_ptr;
}

void push(priority_queue *q, Data d, int prior){
	if(q->que_sz >= q->arr_sz){
		int new_sz = (q->arr_sz ? q->arr_sz * 2 : 8);
		q->nodes = my_realloc(q->nodes, q->arr_sz, new_sz);
		q->arr_sz = new_sz;
	}
	
	int k = q->que_sz;
	
	while(true){
		if(k == 0)break;
		
		int next = (k - 1) / 2;
		if(q->nodes[next].prior > prior){
			q->nodes[k] = q->nodes[next];
			k = next;
		}
		else break;
	}
	
	q->nodes[k].data = d;
	q->nodes[k].prior = prior;
	
	++q->que_sz;
}

Data pop(priority_queue *q){
	Data ret = q->nodes[0].data;
	
	q->nodes[0] = q->nodes[--q->que_sz];
	
	int k = 0;
	while(true){
		int l = k * 2 + 1, r = k * 2 + 2;
		int next = -1;
		
		if(l < q->que_sz)next = l;
		if(r < q->que_sz)next = (q->nodes[r].prior < q->nodes[l].prior ? r : l);
		
		if(next == -1)break;
		
		if(q->nodes[next].prior < q->nodes[k].prior){
			q->nodes[k] = q->nodes[next];
			k = next;
		}
		else break;
	}
	
	q->nodes[k] = q->nodes[q->que_sz];
	
	return ret;
}

typedef struct{
	int to, cost;
}Edge;

#define maxN  100005
#define maxM  500001
#define inf 2000000000

int cost[maxN];
Edge *g[maxN];
int g_sz[maxN], cnt[maxN];
int n, m, r;
int s[maxM], t[maxM], d[maxM];

void dijkstra(int k){
	int i;
	
	priority_queue que = {0};
	for (i = 0; i < n; ++i)cost[i] = inf;
	cost[k] = 0;
	Data d;
	d.n = k, d.cost = 0;
	push(&que, d, d.cost);
	
	while (que.que_sz){
		d = pop(&que);
		
		int v = d.n;
		if (cost[v] < d.cost)continue;
		for (i = 0; i < g_sz[v]; ++i){
			Edge e = g[v][i];
			if (cost[e.to] > cost[v] + e.cost){
				cost[e.to] = cost[v] + e.cost;
				
				Data x;
				x.n = e.to, x.cost = cost[e.to];
				push(&que, x, x.cost);
			}
		}
	}
}

int main(void){
	scanf("%d%d%d", &n, &m, &r);
	
	int i;
	
	for(i = 0; i < m; ++i){
		scanf("%d%d%d", &s[i], &t[i], &d[i]);
		
		++cnt[s[i]];
	}
	
	for(i = 0; i < n; ++i){
		g[i] = (Edge*)malloc(sizeof(Edge) * cnt[i]);
	}
	
	for(i = 0; i < m; ++i){
		Edge e;
		e.to = t[i], e.cost = d[i];
		g[s[i]][g_sz[s[i]]++] = e;
	}
	
	dijkstra(r);
	
	for(i = 0; i < n; ++i){
		if(cost[i] == inf)printf("INF\n");
		else printf("%d\n", cost[i]);
	}
	
	for(i = 0; i < n; ++i){
		free(g[i]);
	}
	
	return 0;
}

Measured memory_bytes: 14916
# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
# import sys ; sys.exit() # プログラム終了
# from copy import deepcopy ; b=deepcopy(a)
# chr(ord('a') + 1)
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#
n = str(input())
ans = 0
for s in n:
    if s == "+":
        ans += 1
    else:
        ans -= 1

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
vector<ll> a,sum;
ll dp[410][410];
ll dfs(int l,int r){
    if(dp[l][r]!=-1)return dp[l][r];
    if(l==r)return dp[l][r]=0;
    ll res=dfs(l+1,r);
    for(int i=l+1;i<r-1;i++){
        res=min(res,dfs(l,i)+dfs(i+1,r));
    }
    res=min(res,dfs(l,r-1));
    return dp[l][r]=res+sum[r]-sum[l-1];
}
int main(){
    memset(dp,-1,sizeof(dp));
    int n;cin>>n;
    a.resize(n+10);
    sum.resize(n+10);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int j=1;j<=n;j++)sum[j]+=sum[j-1]+a[j];
    cout<<dfs(1,n)<<endl;
}   


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

#define ll long long
#define ar array
#define endl "\n"

int main(){
    //
    //freopen("input.txt", "r", stdin);
    //
    ios::sync_with_stdio(0);
    cin.tie(0);

    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int num_taken[2];
    num_taken[0]=ceil((float)a/(float)d);
    num_taken[1]=ceil((float)c/(float)b);

    if(num_taken[0]>num_taken[1]||num_taken[0]==num_taken[1]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,cnt=0;
cin>>n;
vector<int>p(n);
for(int &x:p)cin>>x;
set<int>s;
for(int i=1;i<n-1;i++){
    vector<int>r(3);
    r[0]=p[i-1];
    r[1]=p[i];
    r[2]=p[i+1];
    sort(r.begin(),r.end());
    if(r[1]==p[i])cnt++;

}
cout<<cnt;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	static String judge(double xp0, double yp0, double xp1, double yp1, double xp2, double yp2){
		double[] p1_to_p2 = {xp2 - xp1, yp2 - yp1};
		//double BorderLine = p1_to_p2[1] / p1_to_p2[0];
		double[] p1 = {xp1 - xp0, yp1 - yp0};
		double[] p2 = {xp2 - xp0, yp2 - yp0};

		if(cross(p1, p2)){ //parallel
			if(normSqr(p1) >= normSqr(p2) && inPro(p1, p2) >= 0){ //ON_SEGMENT?
				return("ON_SEGMENT");
			}else{
				if(normSqr(p2) > normSqr(p1) && inPro(p1, p2) >= 0){
					return("ONLINE_FRONT");
				}else{
					return("ONLINE_BACK");
				}
			}
		}else{ //not_parallel
			if(isThisClockwise(p1, p2)){
				return("CLOCKWISE");
			}else{
				return("COUNTER_CLOCKWISE");
			}
		}
	}

	static boolean isThisClockwise(double[] p1, double[] p2){
		double[] p1_to_p2 = {p2[0] - p1[0], p2[1] - p1[1]};

		if(p1_to_p2[0] == 0){
			if(p1_to_p2[1] >= 0){
				if(p1[0] >= 0){
					return false;
				}else{
					return true;
				}
			}else{
				if(p1[0] >= 0){
					return true;
				}else{
					return false;
				}
			}
		}else if(p1_to_p2[1] == 0){
			if(p1_to_p2[0] >= 0){
				if(p1[1] >= 0){
					return true;
				}else{
					return false;
				}
			}else{
				if(p1[1] >= 0){
					return false;
				}else{
					return true;
				}
			}
		}else{
			double t = - p1[0] / p1_to_p2[0];
			if(p1[1] + t * p1_to_p2[1] >= 0){ //????????????????°?????????????
				if(p1_to_p2[0] >= 0){
					return true;
				}else{
					return false;
				}
			}else{
				if(p1_to_p2[0] >= 0){
					return false;
				}else{
					return true;
				}
			}
		}
	}

	static boolean cross(double[] p1, double[] p2){
		return((p1[0]*p2[1] - p1[1]*p2[0] == 0) ? (true) : (false));
	}

	static double inPro(double[] p1, double[] p2){
		return(p1[0] * p2[0] + p1[1] * p2[1]);
	}

	static double normSqr(double[] p){
		return(p[0]*p[0] + p[1]*p[1]);
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int xp0 = in.nextInt();
		int yp0 = in.nextInt();
		int xp1 = in.nextInt();
		int yp1 = in.nextInt();
		int q = in.nextInt();

		for(int i = 0; i < q; i ++){
			System.out.println(judge(xp0, yp0, xp1, yp1, in.nextInt(), in.nextInt()));
		}

	}
}

Measured memory_bytes: 33848
N = int(input())
A = list(map(int, input().split()))
ans = 0
k = True

while k == True:
	for i in range(len(A)):
		if A[i] % 2 == 1:
			k = False
			break

	if k == True:
		ans += 1
		for i in range(len(A)):
			A[i] = A[i] / 2

print(ans)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b < c + d)
	{
		cout << "Right" << endl;
	}
	else if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Left" << endl;
	}

}

Measured memory_bytes: 256
s=list(input())
S=[]
for i in range(len(s)):
    S.append(int(s[i]))
if 1<=S[2]*10+S[3] and S[2]*10+S[3]<=12:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('MMYY')
    else:
        print('NA')

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

using namespace std;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
	
	int N; cin>>N;
	bool ans = true;
	bool nop = true;
	int t = 0;
	int s = 0;
	for (int i = 1; i <= N; i++) {
	    int v; cin>>v;
	    if (nop and v != i) {
	        nop = false;
	        t = v;
	        s = i;
	    } else if (!nop and v != i) {
	        if (i != t or v != s) {
	            ans = false;
	        }
	        nop = true;
	        break;
	    }
	}
	ans &= nop;
	cout << (ans ? "YES" : "NO") << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    long long int dp[10][1001];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<=100;i++){
        for(int j=9;j>0;j--){
            for(int k=1000;k-i>=0;k--){
                dp[j][k]+=dp[j-1][k-i];
            }
        }
    }
    int n,s;
    while(cin>>n>>s,n||s)cout<<dp[n][s]<<endl;
}

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

const int N=100005;
queue<int> q;
vector<int> g[N];
int d[N], f[N];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=1, x, y; i<=m; i++) {
		scanf("%d%d", &x, &y);
		g[y].push_back(x);
		d[x]++;
	}
	for (int i=1; i<=n; i++) if (d[i]==0) q.push(i);
	
	int ans = 0;
	while (!q.empty()) {
		int x=q.front(); q.pop();
	//	printf("x:  %d\n", x);
		for (int i=0; i<g[x].size(); i++) {
			int y=g[x][i];
			d[y]--;
			f[y]=max(f[y], f[x]+1);
			if (d[y]==0) q.push(y);
		}
		ans=max(f[x], ans);
	}
//	for (int i=1; i<=n; i++) printf("%d ", f[i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	final int ROW = 0;
	final int COL = 1;
	final int QUEEN = 1;
	final int X = 2;

	boolean[] row, col, rDia, lDia; 
	boolean[][] board;
	void run() {
		Scanner scan = new Scanner(System.in);
		board = new boolean[8][8];
		row = new boolean[8];
		col = new boolean[8];
		rDia = new boolean[2 * 8 - 1];
		lDia = new boolean[2 * 8 - 1];

		int k = scan.nextInt();
		for (int i = 0; i < k; i++) {
			int r = scan.nextInt();
			int c = scan.nextInt();
			board[r][c] = true;
			row[r] = true;
			col[c] = true;
			rDia[(c + (8 - 1)) - r] = true;
			lDia[r + c] = true;
		}
		dfs(0);
	}
	void dfs(int r) {
		if (r == 8) {
			for (int i = 0; i < 8; i++) {
				for (int j = 0; j < 8; j++)
					System.out.print(board[i][j] == true ? "Q" : ".");
				System.out.println();
			}
			return;
		}
		if (row[r])
			dfs(r + 1);
		for (int i = 0; i < 8; i++) {
			if (!row[r] && !col[i] && !rDia[(i + (8 - 1)) - r] && !lDia[r + i]) {
				board[r][i] = true;
				row[r] = true;
				col[i] = true;
				rDia[(i + (8 - 1)) - r] = true;
				lDia[r + i] = true;
				dfs(r + 1);
				board[r][i] = false;
				row[r] = false;
				col[i] = false;
				rDia[(i + (8 - 1)) - r] = false;
				lDia[r + i] = false;
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 26216
use std::cmp;

fn main() {
    let (r, c, k): (usize, usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let mut item = vec![vec![0; c]; r];
    for _ in 0..k {
        let (r, c, v): (usize, usize, i64) = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            (
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
            )
        };

        item[r - 1][c - 1] = v;
    }

    let mut dp = vec![vec![0; 4]; c];
    for i in 0..r {
        for j in 0..c {
            for l in (0..3).rev() {
                dp[j][l + 1] = cmp::max(dp[j][l + 1], dp[j][l] + item[i][j]);
            }
            if j < c - 1 {
                for l in 0..4 {
                    dp[j + 1][l] = cmp::max(dp[j + 1][l], dp[j][l]);
                }
            }
            dp[j][0] = *(dp[j].iter().max().unwrap());
        }
    }
    println!("{}", dp[c - 1][0]);
}

Measured memory_bytes: 72696
N=int(input())
A=list(map(int,input().split()))
L=A[::]
for i in range(N//2,0,-1):
    x=N//i
    s=sum([L[i*k-1] for k in range(1,x+1)])%2
    if L[i-1]!=s: L[i-1]=s
print(sum(L))
L=[str(i+1) for i,c in enumerate(L) if c==1]
print(" ".join(L))

Measured memory_bytes: 93024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

int main() {
	fread(cn, 1, cm, stdin); 
	ci = cn;
	int N = 0;
	int fu = 0;
	int saishou = 1e9;
	ll goukei = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	rep(i, N) {
		if (ci - cn + 16 > cm) {
			ct = getcha();
			if (ct == '-') { fu ^= 1; ct = getcha(); }
			int A = ct - '0';
			while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
			goukei += A;
			saishou = min(saishou, A);
		}
		else {
			ct = *ci++;
			if (ct == '-') { fu ^= 1; ct = *ci++; }
			int A = ct - '0';
			while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
			goukei += A;
			saishou = min(saishou, A);
		}
	}

	if (fu & 1) goukei -= saishou * 2;

	co(goukei);

	Would you please return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, A, B;
    cin >> N >> A >> B;
    if(A%2 == B%2) cout << llabs(A-B) / 2 << endl;
    else
    {
        ll na = N - A;
        ll nb = N - B;
        ll a = A-1;
        ll b = B-1;
        cout << min(na, min(nb, min(a, b))) + 1 + llabs(A-B) / 2 << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3560
#include<stdio.h>
int main(){
long i,n,a[111111],ans=0;
scanf("%ld",&n);
a[n]=0;
for(i=0;i<n;i++)
scanf("%ld",&a[i]);
for(i=0;i<n;i++){
ans+=a[i]/2;
if(a[i]%2==1&&a[i+1]>0){
ans++;
a[i+1]--;
}
}
printf("%ld\n",ans);
return 0;
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b = map(int, raw_input().split())
ans = ""
if a == b:
    ans = "Draw"
elif a > b:
    if b != 1:
        ans = "Alice"
    else:
        ans = "Bob"
else:
    if a != 1:
        ans = "Bob"
    else:
        ans = "Alice"
    
# 出力
print ans

Measured memory_bytes: 2568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;


public class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer in=new StringTokenizer(br.readLine());
        int N =Integer.parseInt(in.nextToken());
        int M =Integer.parseInt(in.nextToken());
        in = null;
		int[] arr = new int[N+1];
		HashSet<Integer> rootNodes = new HashSet<Integer>();

		for (int i = 0; i < M; i++) {
			in=new StringTokenizer(br.readLine());
			int x = Integer.parseInt(in.nextToken());
			int y = Integer.parseInt(in.nextToken());
			in = null;
			union(arr, x, y);
		}
		br = null;
		for (int i = 1; i <= N; i++) {
			rootNodes.add(find(arr, i));
		}
		System.out.print(rootNodes.size());
	}

	static int find(int[] parent, int i) {
	    while (parent[i] != 0) {
	        i = parent[i];
	    }
	    return i;
	}

	static void union(int[] parent, int x, int y) {
	    int xset = find(parent, x);
	    int yset = find(parent, y);
	    if (xset != yset) {
	    	if (xset <= yset) {
	    		parent[xset] = yset;
	    	}	else {
	    		parent[yset] = xset;
	    	}

	    }
	}

}

Measured memory_bytes: 41112
n = int(input()) # length of string
str = input()
mid = n // 2 # the first char in later str
counter = 0
if n % 2 != 0:
  print("No")
else:
  for i in range(mid):
    if str[i] == str[mid + i]:
      counter += 1   
  if counter == mid :
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll h, w;
    cin >> h >> w;

    vvl board(h, vl(w));
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '#') {
                board[i][j] = 1;
            }
        }
    }

    vvl v(h, vl(w));
    rep(i, h) {
        bool ok = false;
        rep(j, w) {
            if(board[i][j]) {
                ok = true;
            }
        }
        if(ok) {
            rep(j, w) {
                v[i][j] = board[i][j];
            }
        }
        else {
            rep(j, w) {
                v[i][j] = -1;
            }
        }
    }

    rep(j, w) {
        bool ok = false;
        rep(i, h) {
            if(v[i][j] == 1) {
                ok = true;
            }
        }
        if(ok) {
            rep(i, h) {
                if(v[i][j] != -1) {
                    v[i][j] = board[i][j];
                }
            }
        }
        else {
            rep(i, h) {
                v[i][j] = -1;
            }
        }
    }

    rep(i, h) {
        bool ok = false;
        rep(j, w) {
            if(v[i][j] != -1) {
                ok = true;
            }
        }
        if(ok) {
            rep(j, w) {
                if(v[i][j] == 0) {
                    cout << '.';
                }
                else if(v[i][j] == 1) {
                    cout << '#';
                }
            }
            cout << "\n";
        }
    }
    
    re0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

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

ll prod(int a) { //2^a mod
    ll p = 1;

    rep(i, a) {
        p = (p * 2) % MOD;
    }
    return p;
}

int main() {
    int n;
    cin >> n;
    map<int, int> cnt;
    if (n % 2 == 0) {

        rep(i, n) {
            int a;
            cin >> a;
            if (a % 2 == 0) {
                cout << 0 << endl;
                return 0;
            }
            cnt[a]++;
        }

        rep(i, n) {
            if (i % 2 == 1) {
                if (cnt[i] != 2) {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }

        cout << prod(n / 2) << endl;

    } else {

        rep(i, n) {
            int a;
            cin >> a;
            if (a % 2 == 1) {
                cout << 0 << endl;
                return 0;
            }
            cnt[a]++;
        }

        rep(i, n) {
            if (i == 0) {
                if (cnt[0] != 1) {
                    cout << 0 << endl;
                    return 0;
                }
            } else if (i % 2 == 0) {
                if (cnt[i] != 2) {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }

        cout << prod(n / 2) << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
import numpy

N = int(input())
A_list = list(map(int,input().split(' ')))
# index_list = list(range(1,N+1))
# number = numpy.array(A_list, index_list)
junban = numpy.argsort(A_list)
junban = numpy.array(junban) + 1
junban2 = map(str,junban)
result = ' '.join(junban2)
print(result)

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


using namespace std;
#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 repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(x), end(x), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(x), rend(x), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T>
constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args>
constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args>
constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class T>
constexpr T ceiling(const T a, const T b) { return (a + b - 1) / b; }
ll plusMod(ll& a, const ll b) { return a = (a + b) % mod; }
template<typename A, size_t N, typename T>
constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
void solve() {
    cin >> n;

    cout << n * n * n << endn;
}

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

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

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

class Factorial {
    public:
      ll modd = 1000 * 1000 * 1000 + 7;
      vector<ll> bin;

      Factorial(int n) : bin(n+1, 0) {
          bin[0] = 1;
          forr(i,1,n) {
              bin[i] = i*bin[i-1]; bin[i] = bin[i] % modd;
          }
      }

      ll val(int i) {  return bin[i];  }
};

vector<vector<int>> answer(int n, int colour) {
    if (n==1) { return vector<vector<int>>();  }
    if (n==2) { return vector<vector<int>>(2, vector<int>(2, colour));  }
    vector<vector<int>> ret(n, vector<int>(n));
    forr(i,0,n)  {
        for(int j = i+1; j < n; j++) {
            if (i%2!=j%2) {  ret[i][j] = colour;  }
        }
    }
    vector<vector<int>> ret1 = answer(n/2, colour+1);
    vector<vector<int>> ret2;
    if (n%2==0) {  ret2=ret1;  } else { ret2 = answer(n-n/2, colour+1); }
    forr(i,0,n) {
        for(int j = i+1; j < n; j++) {
            if ((i%2==0) && (j%2==0)) {
                ret[i][j] = ret2[i/2][j/2];                
            }
            if ((i%2==1) && (j%2==1)) {
                ret[i][j] = ret1[(i-1)/2][(j-1)/2];                
            }
        }
    }
    return ret;
};

int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;


//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);

        vector<vector<int>> ans = answer(n, 1);

        forr(i,0,n-1) {
            for(int j = i+1; j < n; ++j) {
                cout << ans[i][j] << " ";
            }
            cout << endl;
        }
       
    }
    return 0;
}


Measured memory_bytes: 1792
#レーベンシュタイン距離

a = [None] + list(input())
b = [None] + list(input())
dp = [[float('inf')]*(len(a)) for _ in range(len(b))]
for i in range(len(a)):
    dp[0][i] = i
for i in range(len(b)):
    dp[i][0] = i

for i in range(1,len(b)):
    for j in range(1,len(a)):
        if b[i] == a[j]:
            c = 0
        else:
            c = 1
        dp[i][j] = min(dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+c)

print(dp[len(b)-1][len(a)-1])


Measured memory_bytes: 43084