akhauriyash/Code-Regression huggingface dataset:
#import re
import sys
#input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    s = input()
    ans = ""
    for i in range(len(s)):
        ans += "x"
    print(ans)
    


    
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int x;
    for(int i=0;i<5;i++){
        cin >> x;
        if(x==0) cout << i+1 << endl;
    }

    return 0;
}


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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '

#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
string s;
int main()
{
    fast_io;
    cin>>s;
    for(ll i=0;i<3;i++){
        if(s[i]==s[i+1])return cout<<"Bad",0;

    }
    cout<<"Good";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
const ll mod = 1e9+7;

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> c(n);
    vector<pair<int,int>> d(m);
    rep(i,n){
         int a,b;
         cin >> a >> b;
         c[i]={a,b};
    }
    rep(i,m){
         int a,b;
         cin >> a >> b;
         d[i] = {a,b};
    }
    int id=0;
    rep(i,n){
         int mn = 1 << 30;
         rep(j,m){
          if (mn > (abs(d[j].first-c[i].first)+abs(d[j].second-c[i].second))){
               mn=abs(d[j].first-c[i].first)+abs(d[j].second-c[i].second);
               id = j+1;
          }
         }
         cout << id << endl;        
    }
     return 0;
}


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

int main()
{
	int i = 1;
	int n;
	while(1){
		cin >> n;
		if(n != 0){
			cout << "Case " << i << ": " << n << endl;
			i++;
		}
		else {
			break;
		}
	}
	return 0;
}

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

const int N = 1e5+10;
const int INF = 1e18+10;

int V,E;
vector<int> G[N];
vector<int> path;
int visited[N];
int indeg[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  visited[s] = 1;
  while(!q.empty()){
    int u = q.front(); q.pop();
    path.push_back(u);
    for(int i = 0; i < G[u].size(); i++){
      int v = G[u][i];
      indeg[v]--;
      if(indeg[v] == 0 && !visited[v]){
        visited[v] = 1;
        q.push(v);
      }
    }
  }
}

void tsort(){
  for(int u = 0; u < V; u++){
    for(int i = 0; i < G[u].size(); i++){
      int v = G[u][i];
      indeg[v]++;
    }
  }

  for(int u = 0; u < V; u++){
    if(indeg[u] == 0 && !visited[u]) bfs(u);
  }
}

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

  cin >> V >> E;
  for(int i = 0; i < E; i++){
    int s,t; cin >> s >> t;
    s--,t--;
    G[s].push_back(t);
  }

  tsort();
  vector<int> dp(N,0);
  int ans = 0;
  for(auto p : path){
    for(int i = 0; i < G[p].size(); i++){
      int v = G[p][i];
      dp[v] = max(dp[v],dp[p]+1);
    }
    ans = max(ans,dp[p]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8948
#include<bits/stdc++.h>
using namespace std;
#define nn 508

int dp[2][nn][nn];
int sig[nn][nn];
void upd(int&x,int y){
	x=max(x,y);
}
int n;int fst[nn][nn];int ans=0;
int ax[]={-1,1,0,0,0},ay[]={0,0,-1,1,0};

#define pii pair<int,int>
#define mp make_pair
vector<pii> wait[nn*nn];int vis[nn][nn];
void spread(int now,int cg){
	int eg=cg;vector<int> all;
	for(int i=1+cg-1;i<=1+n-cg;i++) for(int j=1+cg-1;j<=1+n-cg;j++) 
		if(i and j and i<=n and j<=n) vis[i][j]=0,wait[dp[now][i][j]].push_back(mp(i,j)),all.push_back(dp[now][i][j]),all.push_back(sig[i][j]);
	
	if(all.size()<=n*10){
			sort(all.begin(),all.end());reverse(all.begin(),all.end());
			for(int ii=0;ii<all.size();ii++) if(wait[all[ii]].size()){int i=all[ii];
			for(int e=0;e<wait[i].size();e++){
				pii p=wait[i][e];
				int x=p.first,y=p.second;if(vis[x][y]) continue;vis[x][y]=1;
				for(int k=0;k<4;k++){
					if(x+ax[k]>=1+cg and x+ax[k]<=n-cg and y+ay[k]>=1+cg and y+ay[k]<=n-cg)
					if(dp[now][x+ax[k]][y+ay[k]]<min(dp[now][x][y],sig[x+ax[k]][y+ay[k]])){
						
						dp[now][x+ax[k]][y+ay[k]]=min(dp[now][x][y],sig[x+ax[k]][y+ay[k]]);
						wait[dp[now][x+ax[k]][y+ay[k]]].push_back(mp(x+ax[k],y+ay[k]));
					}
				}
			}
			wait[i].clear();
		}
		
	}
	else 
	for(int i=n*n;i>=1;i--) if(wait[i].size()){
		for(int e=0;e<wait[i].size();e++){
			pii p=wait[i][e];
			int x=p.first,y=p.second;if(vis[x][y]) continue;vis[x][y]=1;
			for(int k=0;k<4;k++){
				if(x+ax[k]>=1+cg and x+ax[k]<=n-cg and y+ay[k]>=1+cg and y+ay[k]<=n-cg)
				if(dp[now][x+ax[k]][y+ay[k]]<min(dp[now][x][y],sig[x+ax[k]][y+ay[k]])){
					
					dp[now][x+ax[k]][y+ay[k]]=min(dp[now][x][y],sig[x+ax[k]][y+ay[k]]);
					wait[dp[now][x+ax[k]][y+ay[k]]].push_back(mp(x+ax[k],y+ay[k]));
				}
			}
		}
		wait[i].clear();
	}
	
	
	for(int i=1+cg-1;i<=n-cg+1;i++) for(int j=1+cg-1;j<=n-cg+1;j++) for(int k=0;k<4;k++) if(dp[now][i][j]>=sig[i+ax[k]][j+ay[k]]) 
			fst[i+ax[k]][j+ay[k]]=min(fst[i+ax[k]][j+ay[k]],eg);
	
}
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n*n;i++){
		int x=i;scanf("%d",&x);
		sig[(x-1)/n+1][(x-1)%n+1]=n*n+1-i;
	}
	
	memset(fst,0x3f,sizeof fst);
	int now=0;for(int i=1;i<=n;i++) dp[now][1][i]=sig[1][i],dp[now][n][i]=sig[n][i],dp[now][i][1]=sig[i][1],dp[now][i][n]=sig[i][n];
	for(int g=1;g<=n;g++){
		now^=1;spread(now^1,g-1);
		
		int bad=0;
		memset(dp[now],0,sizeof dp[now]);
		int cg=g-1;
	for(int i=1+cg-1;i<=1+n-cg;i++) for(int j=1+cg-1;j<=1+n-cg;j++)  if(min(i-1,n-i)<=g-1 or min(j-1,n-j)<=g-1) upd(dp[now][i][j],n*n);
	//	cg=0;
	for(int i=1+cg-1;i<=1+n-cg;i++) for(int j=1+cg-1;j<=1+n-cg;j++) {
			for(int k=0;k<5;k++) upd(dp[now][i+ax[k]][j+ay[k]],dp[now^1][i][j]);
			if(fst[i][j]>n+n) bad=1;
		}
		if(!bad) break;
	}	
	for(int i=2;i<n;i++) for(int j=2;j<n;j++) ans+=fst[i][j];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 186752
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

signed main() {
  int n; cin >> n;
  vector<int> w(n);
  vector<int> cumul(n);
  int sum = 0;
  for(int i = 0; i < n; i++) {
      cin >> w[i];
      sum += w[i];
  }
  cumul[0] = w[0];
  for(int i = 1; i < n; i++) {
      cumul[i] = (cumul[i-1]+w[i]);
  }
  int ans = 10000;
  for(int i = 0; i < n; i++) {
      ans = min(ans, abs(cumul[i]-(sum - cumul[i])));
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<map>
using namespace std;

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

int main()
{
	int n;
	while(cin>>n && n!=0){
		bool goal[20];
		memset(goal,false,sizeof(goal));
		int gx[20],gy[20];
		map<pair<int,int>,int> Idx;
		for(int i=0;i<n;i++){
			cin>>gx[i]>>gy[i];
			Idx[make_pair(gx[i],gy[i])]=i;
		}

		int m; 
		cin>>m;
		int x=10,y=10;
		for(int i=0;i<m;i++){
			int r=0,dist;
			char c;cin>>c>>dist;
			if(c=='N') r=2;
			else if(c=='E') r=1;
			else if(c=='S') r=0;
			else r=3;

			if(Idx.count(make_pair(x,y))){
				goal[Idx[make_pair(x,y)]]=true;
			}


			for(int k=0;k<dist;k++){
//				cout<<x<<" "<<y<<endl;
				x+=dx[r];y+=dy[r];
				if(Idx.count(make_pair(x,y))){
					goal[Idx[make_pair(x,y)]]=true;
				}
			}
		}
		bool ok=true;
		for(int i=0;i<n;i++){
			if(!goal[i]) ok=false;
		}
		if(ok) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin>> k;
    int a = 7 % k;
    int cnt=1;

    while(true){
        if(a == 0){
            break;
        }

        if(cnt != 1 && cnt > k + 100){
            cnt=-1;
            break;
        }
        a *= 10;
        a += 7;
        a %= k;
        cnt++;
    }
    cout<< cnt << endl;
}

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

int N, K;
vector<int> u, v;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n], b[m];
    map<int, int> mp;
    map<int, int> mpp;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[a[i]]++;
        mpp[a[i]]++;
        u.push_back(a[i]);
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
        if (mp[b[i]] == 1)
            v.push_back(b[i]);
        if (mpp[b[i]] == 0)
            u.push_back(b[i]);
    }
    cout << v.size() << " " << u.size() << endl;
    sort(u.begin(), u.end());
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    for (int i = 0; i < u.size(); i++)
    {
        cout << u[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 24992
#include<stdio.h>
int judge_abc(char *s,char a[4]){
  if(*s==a[0]){
    *s++;
    if(*s==a[1]){
      *s++;
      if(*s==a[2]){
        return 1;
      }
    }
  }
  return 0;
}
int main(void){
  char s[4];
  scanf("%s",s);
  while(
  judge_abc(s,"abc")||
  judge_abc(s,"acb")||
  judge_abc(s,"bac")||
  judge_abc(s,"bca")||
  judge_abc(s,"cab")||
  judge_abc(s,"cba")
  ){
    puts("Yes");
    return 0;
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
vector<char> ans;
vector<string> s(100010);
void solve(ll& a, ll& b, char c) {
	a++;
	b--;
	ans.push_back(c);
}
bool move(ll& a, ll& b, string c, string s1, string s2) {
	if (a == 0 and b == 0) return false;
	else if (a == 1 and b == 1) s1 == s2 ? solve(a, b, c[0]) : solve(b, a, c[1]);
	else a < b ? solve(a, b, c[0]) : solve(b, a, c[1]);
	return true;
}
int main() {
	ll n, a, b, c;
	cin >> n >> a >> b >> c;
	REP(i, n) cin >> s[i];
	bool ok = true;
	REP(i, n) {
		if (s[i] == "AB") if (!move(a, b, "AB", "AC", s[i + 1])) ok = false;
		if (s[i] == "AC") if (!move(a, c, "AC", "AB", s[i + 1])) ok = false;
		if (s[i] == "BC") if (!move(b, c, "BC", "AB", s[i + 1])) ok = false;
	}
	if (!ok) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	REP(i, n) cout << ans[i] << endl;
}



Measured memory_bytes: 6708
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int r,g,b;
cin>>r>>g>>b;
int m=r*100+g*10+b;
if(m%4==0)cout<<"YES";
else cout<<"NO";
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, c, d) = getLongs()
    println(
            Math.max(Math.max(a * c, a * d), Math.max(b * c, b * d))
    )
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

Measured memory_bytes: 36540
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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 N;
int x[1010], y[1010], id[1010];

int main() {
  cin >> N;
  rep(i, N) {
    cin >> x[i] >> y[i];
    id[i] = i;
  }

  double ans = 0;
  int cnt = 0;
  do {
    cnt++;

    for (int i = 0; i < N - 1; i++) {
      double tmp =
          (double)(x[id[i]] - x[id[i + 1]]) * (x[id[i]] - x[id[i + 1]]);
      tmp += (double)(y[id[i]] - y[id[i + 1]]) * (y[id[i]] - y[id[i + 1]]);

      ans += sqrt(tmp);
    }

  } while (next_permutation(id, id + N));

  printf("%.12f\n", (double)ans / (double)cnt);
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? (a=b,1) : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;

    int N = s.length();
    for (char &c : s) {
        if (c == 'R') c = '>';
        if (c == 'L') c = '<';
    }

    int ans[100010] {};

    int rp;
    rep(i, N) {
        if (i < N-1 && s[i] == '>' && s[i+1] == '<') {
            rp = i;
        }
        else if (s[i] == '<') {
            const int dist = abs(i - rp);
            if (dist & 1) {
                ans[rp+1] += 1;
            } else {
                ans[rp] += 1;
            }
        }
    }


    int lp;
    for (int i = N-1; i >= 0; --i) {
        if (i > 0 && s[i] == '<' && s[i-1] == '>') {
            lp = i;
        }
        else if (s[i] == '>') {
            const int dist = abs(i - lp);
            if (dist & 1) {
                ans[lp-1] += 1;
            } else {
                ans[lp] += 1;
            }
        }
    }

    rep(i, N) {
        cout << ans[i] << (i < N-1 ? ' ' : '\n');
    }

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

int gcd(int n, int m) {
    if(m == 0) return n;
    return gcd(m, n % m);
}

vector<pair<int, int>> factorize(int n) {
    vector<pair<int, int>> ret;
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            ret.emplace_back(i, 0);
            while(n % i == 0) {
                n /= i;
                ret.back().second++;
            }
        }
    }
    if(n != 1) ret.emplace_back(n, 1);
    return ret;
}

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

    int g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, x;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> x;
    if(x == 1 || x == 2 * n - 1) finish("No");
    vector <int> a(2 * n - 1);
    a[n - 1] = x;
    a[n] = x + 1;
    a[n - 2] = x - 1;
    if(x + 2 <= 2 * n - 1) a[n - 3] = x + 2;
    else a[n + 1] = x - 2;
    set <int> all;
    for(int i = 1 ; i <= 2 * n - 1 ; i++){
        all.insert(i);
    }
    for(auto &i : a){
        if(i) all.erase(i);
    }
    for(auto &i : a){
        if(i == 0){
            i = *all.begin();
            all.erase(all.begin());
        }
    }
    cout << "Yes\n";
    for(auto &i : a) cout << i << "\n";
}


Measured memory_bytes: 11648
#include<stdio.h>
int main(void){
int j,t,jt;
scanf("%d %d %d",&j,&t,&jt);
if(j==1&&t==0&&jt==0)printf("Close\n");
if(j==0&&t==1&&jt==0)printf("Close\n");
if(j==1&&t==1&&jt==0)printf("Open\n");
if(j==0&&t==0&&jt==1)printf("Open\n");
if(j==0&&t==0&&jt==0)printf("Close\n");
return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000000

int main()
{
   string s;
   cin>>s;
   int n=s.length();
   int ans=0;
   for(int i=0;i<n/2;i++)
   {
       if(s[i]!=s[n-1-i])
        ans++;
   }
   cout<<ans;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int ans[10010];
int main(){
	int n;
	std::cin>>n;
	REP(i,100){
		REP(j,100){
			REP(k,100){
				if(i*i+j*j+k*k+i*j+j*k+k*i<=n)ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
			}
		}
	}
	REP(i,n)std::cout<<ans[i]<<std::endl;
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N;
    cin >> N;

    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
    }

    deque<ll> que;
    rep (i, N) {
        ll tmp = lower_bound(que.begin(), que.end(), A[i]) - que.begin();
        if (tmp == 0) {
            que.push_front(A[i]);
        } else {
            que[tmp-1] = A[i];
        }
    }

    cout << que.size() << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[10000];
    long long max=-1000000,min=1000000,sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
        if(max<a[i])
        max=a[i];
        if(min>a[i])
        min=a[i];
    }
    cout << min << ' ' << max << ' ' << sum << endl;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ans(n);
    vector<bool> flag(n, false);
    bool non = false;
    if (n > 1) ans[0] = 1;
    rep(i,m) {
        int s, c;
        cin >> s >> c; s--;
        if (flag[s] && ans[s] != c) { non = true;}
        if (n > 1 && s == 0 && c == 0) { non = true;}
        ans[s] = c;
        flag[s] = true;
    }
    if (non) {
        cout << -1 << "\n";
    }
    else {
        rep(i,n) cout << ans[i];
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i,x,y;
	i = 1;
	while(1){
    scanf("%d %d", &x, &y);
    if ( x == 0 && y == 0 ) {
		break;  
    } else if (x >= y) {
       printf("%d %d\n", y, x);
	} else if (y > x) {    
	   printf("%d %d\n", x, y);
		i++;
	}
	}
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a, b;
    cin >> a >> b;
    if(a == 1 && b == 1) {
        cout << "Draw" << endl; 
        return 0;
    }else if(a == 1){
        cout << "Alice" << endl;
        return 0;
    }else if(b == 1){
        cout << "Bob" << endl;
        return 0;
    }

    if(a > b) cout << "Alice" << endl;
    else if(b > a) cout << "Bob" << endl;
    else cout << "Draw" << endl;



    return 0;
}

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

#define DBG 0
#define BUFSIZE 10

static int input[30];
static int input_size;
static int input_max = 0;
static char *prime;

void get_input() {
  char buf[BUFSIZE];
  for (input_size = 0; input_size < 30; input_size++) {
       if (NULL == fgets(buf, BUFSIZE, stdin)) {
	 if (DBG) {
	   fprintf (stderr, "EOF\n");
	 }
	 break;
       }
       buf[strlen(buf)-1] = 0;
       if (buf[0] == 0) {
	 break;
       }
       if (DBG) {
	 fprintf(stderr, "input=%s\n", buf);
       }
       input[input_size] = atoi(buf);
       if (input_max < input[input_size]) {
	 input_max = input[input_size];
       }
  }
  return;
}

int main (void) {
  char str[100];
  int p, i, j, c, n;
  get_input();
  if (DBG) {
    fprintf(stderr, "input size=%d  max=%d\n", input_size, input_max);
  }
  if (NULL == (prime = calloc(input_max+1, sizeof(char)))) {
    sprintf(str, "input_max=%d", input_max);
    perror(str);
    return 1;
  }

  prime[0] = 1;
  prime[1] = 1;
  for (p=2; p*p<=input_max; p++) {
    if (prime[p] == 1) {
      continue;
    }
    if (DBG) {
      fprintf(stderr, "%d is prime.\n", p);
    }
    for (i=2*p; i<=input_max; i+=p) {
      prime[i] = 1;
    }
  }

  if (DBG) {
    for (i=0; i<input_max+1; i++) {
      if (prime[i] == 0) {
	fprintf(stderr, "%d\n", i);
      }
    }
  }

  for (i=0; i<input_size; i++) {
    c = input[i];
    for (j=0, n=0; j<=c; j++) {
      if (prime[j] == 0) {
	n++;
      }
    }
    printf("%d\n", n);
  }
  return 0;
}

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

int main(){
  int N, M;
  cin>>N;
  vector<int> buka(N+1);
  for(int i=2; i<=N; i++){
    int a;
    cin>>a;
    buka.at(a)++;
  }
  for(int i=1; i<=N; i++) cout<<buka.at(i)<<endl;
}


Measured memory_bytes: 4052
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()

from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort

ans = 0

for b in B:
    ans += bisect_left(A,b) * (N - bisect_right(C,b))

print(ans)

Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    char c[200005];
    scanf("%s",c);
    queue<int> q;
    for(int i= 0;i<n;i++){
        if(c[i]=='A')q.push(0);
        else q.push(1);
    }
    //printf("%d\n",q.front());
    //q.front()^=1;
    //printf("%d\n",q.front());
    int flag=0;
    for(int i = 0;i<2*n;i++){
        k--;
        if(q.front()^flag){
            q.pop();
            flag^=1;
            q.push(flag);
        }
        else{
            q.front()^=1;
        }
        if(k==0){
            break;
        }
    }
    if(n%2){
        if(k&1)q.front()^=1;
    }
    while(q.size()){
        printf("%c",(q.front()^flag)+'A');
        q.pop();
    }
    printf("\n");
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)



int main() {
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if(a + b >= c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main()
{
  int w, h, x, y, r;
 
  cin >> w >> h >> x >> y >> r;
  
  if ((r <= x) && (x <= w - r) && (r <= y) && (y <= h - r))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1160
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int MAXLOG = 62;

struct basis {
  int base[MAXLOG];

  void clear() {
   for(int i = MAXLOG - 1; i >= 0; i--) base[i] = 0;
  }

  void prepare(int val) {
    for(int i = MAXLOG - 1; i >= 0; i--) {
      if((val >> i) & 1) {
      if(!base[i]) { base[i] = val; return; }
      else val ^= base[i];
    }
  } 
 }  
 int size() {
   int c = 0;
   for(int i = 0; i < MAXLOG; i++) c += (bool)(base[i]);
   return c;
 }

 int max_xor() {
  int res = 0;
  for(int i = MAXLOG - 1; i >= 0; i--)
    if(!((res >> i) & 1) && base[i]) res ^= base[i];
  return res;
 }

  bool possible(int val) {
   for(int i = MAXLOG - 1; i >= 0; i--)
    if(((val >> i) & 1) && base[i]) val ^= base[i];
   return (val == 0);
  }
};

void solve() {
  int n; cin >> n;
  int data[n+5];
  for(int i = 0; i < n; i++) cin >> data[i];
  basis b; b.clear();
  string s; cin >> s;
  for(int i = n-1; i >= 0; i--) {
     if(s[i] == '1') {
       if(!b.possible(data[i])) {
        cout << "1\n"; return;
       }
     } else {
      b.prepare(data[i]);
     }
  }
  cout << "0\n";
}

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

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}    


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<int> edges[1010];
int v[1010];
bool ans = true;

int dfs(int i) {
    int sum = 0;
    bitset<5010> bs;
    bs.set(0);
    for (int& j : edges[i]) {
        int w = dfs(j);
        sum += w+v[j];
        bs = (bs<<w)|(bs<<(v[j]));
    }
    int mx = -1;
    for (int j = v[i];j >= 0;--j) if (bs[j]) {
        mx = j;
        break;
    }
    if (mx < 0) ans = false;
    return sum-mx;
}

int main() {
    int n;
    cin >> n;
    for (int i = 1;i < n;++i) {
        int u;
        cin >> u;
        u--;
        edges[u].push_back(i);
    }
    for (int i = 0;i < n;++i) cin >> v[i];
    dfs(0);
    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE");
    return 0;
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(C < A){
        cout << "NO" << endl;
    }
    else if(A + B < C){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  char _s[1000];
  while(~scanf("%s",_s)){
    string s(_s);
    REP(i,s.size()){
      if(s[i]=='@'){
        char a=s[i+2];
        int b=s[i+1]-'0';
        cout<<string(b,a);
        i+=2;
      }else{
        cout<<s[i];
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    Sort(a);
    
    int lb = -1, ub = n;
    while(ub - lb > 1){
        int m = (lb + ub) / 2;
        ll sum = 0;
        For(i, n){
            if(i > m && 2*sum < a[i]){
                lb = m;
                goto next;
            }
            sum += a[i];
        }
        ub = m;
        next:;
    }
    Cout(n-ub);
}




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

int main() {
    int n, d;
    cin >> n >> d;
    long long x, y, cnt = 0;

    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        if (sqrt(x * x + y * y) <= d) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>
int main()
{
	int N,X,i,j,k,r;
	for(;scanf("%d%d",&N,&X),X+N;printf("%d\n",r))
	{
		for(i=1,r=0;i<=N;i++)
			for(j=i+1;j<=N;j++)
			{
				k=X-i-j;
				if(j<k&&k<=N)
					r++;
			}
	}
	return 0;
}



Measured memory_bytes: 2092
#include<stdio.h>
#define MAX 500
int main()
{
  int a,b,i=1;
  int array[MAX];
  scanf("%d%d",&a,&b);
  array[1] = a;
  array[2] = b;
  while(array[i]!=array[i+1])
    {
      if(array[i] > array[i+1])
    {
      array[i+2] = array[i] - array[i+1];
    }
      else
    {
      array[i+2] = array[i+1] - array[i];
    }
      i++;
    }
  printf("%d\n",array[i]);
  return 0;
}

Measured memory_bytes: 596
#[test]
fn test_solve() {
    assert_eq!(solve("2\n2 2\n9 1\n"), "3\n");
    assert_eq!(solve("3\n1 1\n0 8\n7 1\n"), "9\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let m: usize = sc.read();
    let (nd, sd) = (0..m).fold((0, 0), |(nd, sd), _| {
        let d: usize = sc.read();
        let c: usize = sc.read();
        (nd + c, sd + d * c)
    });

    format!("{}\n", nd - 1 + (sd - 1) / 9)
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,K;
  cin >>N>>K;
  
  int s=0;
  int a=K/2;
  
  for(int i=0; i<N; i++){
    int x;
    cin >>x;
    
    if(x<=a)
      s +=x;
    else
      s +=K-x;
  }
  
  cout <<2*s<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main() {
    int h, w; cin >> h >> w;
    vector<string> grid(h);
    rep(i, h) cin >> grid[i];
    vector<vector<int>> cnt(h, vector<int>(w));
    // left right
    rep(i, h) {
        vector<int> done(w);
        rep(j, w) {
            if (grid[i][j] == '#') continue;
            if (done[j]) continue;
            int l = 0;
            while (j+l < w) {
                if (grid[i][j+l] == '#') break;
                ++l;
            }
            rep(k, l) {
                cnt[i][j+k] += l;
                done[j+k] = 1;
            }
        }
    }
    // up down
    rep(j, w) {
        vector<int> done(h);
        rep(i, h) {
            if (grid[i][j] == '#') continue;
            if (done[i]) continue;
            int l = 0;
            while (i+l < h) {
                if (grid[i+l][j] == '#') break;
                ++l;
            }
            rep(k, l) {
                cnt[i+k][j] += l;
                done[i+k] = 1;
            }
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) ans = max(ans, cnt[i][j]-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20096
from math import sqrt, fabs


def calcu_cirucumcenter(x1, y1, x2, y2, x3, y3):
    """
   ??????O?????§?¨????(x, y)??¨????????¨
   (x-x1)**2 + (y-y1)**2 = (x-x2)**2 + (y-y2)**2
   x**2 -2*x1*x + x1**2 + y**2 -2*y1*y + y1**2 = ... -2*x2*x, x2**2, -2*y2*y, y2**2
   ?????¨????????¨ (-2*x1 + 2*x2)x + (-2y1 + 2*y2)y + (x1**2 + y1**2 - x2**2 - y2**2) = 0
   x1, x3???????????????????§????
   (-2*x1 + 2*x3)x + (-2y1 + 2*y3)y + (x1**2 + y1**2 - x3**2 - y3**2) = 0
   
   ??????????????¢????????\????????¢???????????£???????¨??????¨???????§£???
   | a b | = |e|
   | c d |   |f|
   """
    a = -2 * x1 + 2 * x2
    b = -2 * y1 + 2 * y2
    c = -2 * x1 + 2 * x3
    d = -2 * y1 + 2 * y3
    e = -1* (x1 ** 2 + y1 ** 2 - x2 ** 2 - y2 ** 2)
    f = -1 * (x1 ** 2 + y1 ** 2 - x3 ** 2 - y3 ** 2)

    x = 1 / (a * d - b * c) * (d * e - b * f)
    y = 1 / (a * d - b * c) * (-c * e + a * f)
    return x, y


if __name__ == '__main__':
    epsilon = 1e-9

    # ??????????????\???
    num = int(input())
    for i in range(num):
        x1, y1, x2, y2, x3, y3 = [float(x) for x in input().split(' ')]

        # ?????\????????????(??????)????±???????
        x, y = calcu_cirucumcenter(x1, y1, x2, y2, x3, y3)
        # ?¨????????????¨?????? -0.0 ???????????´???????????¶?????? 0.0 ?????????
        if fabs(x) < epsilon:
            x = 0.0
        if fabs(y) < epsilon:
            y = 0.0

        # ????????????????????§????????¢?????????
        r = sqrt((x - x1)**2 + (y - y1)**2)

        print('{0:.3f} {1:.3f} {2:.3f}'.format(x, y, r))

Measured memory_bytes: 7784
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
ll INF = 1000000000000000001; //10^18+1
ll MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)

int f(int n){
  if(n>1){
    return n*f(n-1);
  }else{
    return 1;
  }
}

int main() {
  ll N,p=0,q=0,cnt=0;
  cin >> N;
  ll P[N],Q[N],R[N];
  bool a,b;
  for(int i=0;i<N;i++)cin >> P[i];
  for(int i=0;i<N;i++)cin >> Q[i];
  for(int i=0;i<N;i++)R[i]=i+1;
  do{
    cnt++;
    a=true;
    b=true;
    for(int i=0;i<N;i++){
      if(P[i]!=R[i]){
        a=false;
      }
      if(Q[i]!=R[i]){
        b=false;
      }
      if(!a&&!b)break;
    }
    if(a)p=cnt;
    if(b)q=cnt;
  }while(next_permutation(R,R+N));
  cout << abs(p-q) << endl;
}

Measured memory_bytes: 256
import sys
import itertools
import copy

input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    N, M = MI()
    numlist = [i for i in range(1, N)]
    mylist2 = [[0 for i in range(N)] for j in range(M)]
    result = 0
    for i in range(M):
        a, b = MI()
        mylist2[min(a, b) - 1][max(a, b) - 1] = 1
    for j in itertools.permutations(numlist, len(numlist)):
        mylist = copy.deepcopy(mylist2)
        index = 0
        past = 0
        for k in j:
            try:
                
                if mylist[min(past, k)][max(past, k)] == 1:
                    mylist[min(past, k)][max(past, k)] = 0
                    past =  k
                    index += 1
                else:
                    break
            except:
                if mylist[0][k] == 1:
                    mylist[0][k] = 0
                    past = k
                    index += 1
                else:
                    break
        if index == len(numlist):
            result += 1
    print(result)
    
main()
                        
                    
        
    

Measured memory_bytes: 58712
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    BeatMeScanf;
    //freopen("G:/C++/in.txt", "r", stdin);
    //freopen("G:/C++/out.txt", "w", stdout);

    char ch;
    cin>>ch;
    cout<<++ch<<endl;

    return 0;
}



Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            int n = int.Parse(Console.ReadLine());
            if (n == 0)
            {
                break;
            }
            string[] s = Console.ReadLine().Split((' '));
            double[] ds = new double[s.Length];
            double sum = 0;
            double m = 0;
            for (int i = 0, count = s.Length; i < count; i++)
            {
                ds[i] = double.Parse(s[i]);
                sum += ds[i];
            }
            m = sum / n;
            sum = 0;
            for(int i = 0,count = s.Length;i<count;i++)
            {
                sum += (ds[i] - m) * (ds[i] - m);
            }
            Console.WriteLine("{0:f5}",Math.Sqrt(sum/n));
        }
    }
}

Measured memory_bytes: 5880
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

int n,w,h;

pair<P,P> cut(P p,int s){
	int sw=p.second,sh=p.first/p.second;
	s%=(sw+sh);
	if(s<sw){
		return MP(MP(sh*s,s),MP(sh*(sw-s),sw-s));
	}else{
		s-=sw;
		return MP(MP(sw*s,sw),MP(sw*(sh-s),sw));
	}
}

int main(){
	while(1){
		cin>>n>>w>>h;
		if(n+w+h==0)break;
		vector<P>v;
		v.PB(MP(w*h,w));
		REP(i,n){
			int a,b;
			cin>>a>>b;a--;
			P p=v[a];v.erase(v.begin()+a);
			pair<P,P> pp=cut(p,b);
			if(pp.first.first<pp.second.first){
				v.PB(pp.first);
				v.PB(pp.second);
			}else{
				v.PB(pp.second);
				v.PB(pp.first);
			}
		}
		sort(ALL(v));
		REP(i,v.size()){
			cout<<v[i].first;
			if(i==v.size()-1)cout<<endl;
			else cout<<" ";
		}
	}
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
typedef long long               ll;
const int mod = 1e9+7;
#ifndef M_PI
#define M_PI acos(-1.0)
#endif

int main(){
	int n;
	bool par = false;
	cin>>n;
	for(int i=0; i<n; ++i){
		int a;
		scanf("%d", &a);
		if(a&1){
			par = !par;
		}
	}
	if(par){
		cout<<"NO";
	}
	else{
		cout<<"YES";
	}
	return 0;
}


Measured memory_bytes: 256