akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//deeply ingrained
using namespace std;


int main() {
    string a,b;
    int answer=0;
    cin>>a>>b;
    for(int i=0;i<a.size();i++) {
        if(a[i] != b[i])answer++;
    }
    cout<<answer<<endl;
    return 0;
}


Measured memory_bytes: 3876
function main(input) {
    var n = input[0].split(" ")[0]-0;
    var m = input[0].split(" ")[1]-0;
    var x = input[0].split(" ")[2]-0;
    var list = input[1].split(" ").map(v=>v-0);
    var a = 0, b=0;
    list.forEach(v=>{
        if(v<x) a++;
        else b++;
    });
    console.log(Math.min(a,b));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int N, M;
	bool ans = false;
	cin >> N >> M;

	vector<string> A(N);
	vector<string> B(M);

	for (int i = 0;i < N;i++)
		cin >> A[i];

	for (int i = 0;i < M;i++)
		cin >> B[i];

	vector<int> Pos(M);
	for (int i = 0;i < (N - M) + 1;i++)
	{
		for (int j = 0;j < (N - M) + 1;j++)
		{
			ans = true;
			for (int k = 0;k < M;k++)
			{
				Pos[k] = A[k + j].find(B[k], i);
			}

			sort(Pos.begin(), Pos.end());
			if (Pos.size() > 1)
			{
				for (int k = 1;k < M;k++)
				{
					if (Pos[k - 1] != Pos[k] || Pos[k - 1] == -1)
					{
						ans = false;
						break;
					}
				}
			}
			else
				if (Pos[0] == -1)
					ans = false;

			if (ans)
				break;
		}
		if (ans)
			break;
	}

	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
int main(){
  string a, b;cin >> a >> b;
  bool ans = false;
  for(int i=0;i<a.size();i++){
    bool match = true;
    for(int j=0;j<a.size();j++){
      if(a[j]!=b[(j+i)%a.size()]){match = false;break;}
    }
    if(match){ans=true;break;}
  }
  cout << (ans? "Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

   int x,y;
   int big,small;
   while(1){
	   cin>>x>>y;
	   if(x==0 && y==0){
		   break;
	   }else{
		   if(x>y){
			   big=x;
			   small=y;
		   }else{
			   big=y;
			   small=x;
		   }
		   cout<<small<<" "<<big<<endl;
	   }
   }

	return 0;
}

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

int main() {
    double x,y;
    int xs[4]={},ys[4]={};
    while(cin>>x>>y){
        if(x>=1.1)xs[0]++;
        else if(x>=0.6)xs[1]++;
        else if(x>=0.2)xs[2]++;
        else xs[3]++;
        if(y>=1.1)ys[0]++;
        else if(y>=0.6)ys[1]++;
        else if(y>=0.2)ys[2]++;
        else ys[3]++;
    }
    for(int i=0;i<4;i++)
        cout << xs[i] << ' ' << ys[i] << endl;
    return 0;
}

Measured memory_bytes: 1224
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 c = sc.nextInt();
		
		if(a < b){
			if(b < c){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17156
#include<stdio.h>

int main(){
    int i,j,t,data[10];
    
    for(i=0;i<10;i++) {
        scanf("%d",&data[i]);
    }
    
    for(i=0;i<9;i++) {
        for(j=0;j<9-i;j++) {
            if(data[j]<data[j+1]) {
                t=data[j];
                data[j]=data[j+1];
                data[j+1]=t;
            }
        }
    }
    for(i=0;i<3;i++) {
        printf("%d\n",data[i]);
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
int main(void)
{
    int K=0;
    int a=0;
    int extra=0;

    scanf("%d",&K);

    a=7%K;
    if(a==0){
        printf("1");
        return 0;
    }
    for(int i=1;i<K;i++){
        a=(a*10+7)%K;
        if(a==0){
            printf("%d",i+1);
            return 0;
        }
    }
    printf("-1");
    return 0;
}


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

int main(){
  vector<vector<int>> a(3,vector<int>(3));
  for(int i=0;i<3;i++){
	for(int j=0;j<3;j++){
      cin >> a.at(i).at(j);
    }
  }
  int n;
  cin >> n;
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> b.at(i);
  }
  
  vector<vector<bool>> c(3,vector<bool>(3));
  
  for(int k=0;k<n;k++){
    for(int i=0;i<3;i++){
	  for(int j=0;j<3;j++){
      	if( b.at(k) == a.at(i).at(j) ){
          c.at(i).at(j) = true;
        }
      }
    }
  }
  //縦
  for(int i=0;i<3;i++){
	for(int j=0;j<3;j++){
      if( !c.at(i).at(j) ) break;
      if( j == 2 ){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  for(int i=0;i<3;i++){
	for(int j=0;j<3;j++){
      if( !c.at(j).at(i) ) break;
      if( j == 2 ){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  if( ( c.at(0).at(2) && c.at(1).at(1) && c.at(2).at(0) ) ||
      (	c.at(0).at(0) && c.at(1).at(1) && c.at(2).at(2) )    ){
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
  return 0;
   
  
  
  return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 8200;
int t,n,a[N],pre[N];
bool check[N];

int main(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a) cout<<k<<'\n';
	else if(k>a&&k<=a+b) cout<<a<<'\n';
	else if(k>a+b&&k<=a+b+c) cout<<2*a+b-k<<'\n';
	
	return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<bitset>
#define reg register
inline int read(){
	reg int x=0,f=1;reg char ch=getchar();
	for(;ch<'0'||ch>'9';f=ch=='-'?-1:1,ch=getchar());
	for(;ch>='0'&&ch<='9';x=(x<<3)+(x<<1)+(ch^48),ch=getchar());
	return x*f;
}
std::bitset<4000005>S(1);
int main(){
	reg int n=read(),s=0;
	for(reg int i=1,x;i<=n;i++)s+=(x=read()),S|=(S<<x);s=(s+1)>>1;
	for(reg int i=s;;i++)if(S[i])return 0*printf("%d\n",i);
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int>adj[MAXN];
int vis[MAXN];
void dfs(int nd){
	vis[nd]=1;
	tr(it,adj[nd])
		if(!vis[*it])
			dfs(*it);	
}
int main(){
  //  freopen("file.in", "r", stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    while(m--){
    	int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		adj[u].pb(v);
		adj[v].pb(u);	
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    	if(!vis[i])
    		dfs(i),ans++;
    printf("%d\n",ans);		
	return 0;
}


Measured memory_bytes: 9216
#include <stdio.h>

int main()
{
	int max_num;
	int num;
	
	scanf("%d", &max_num);

	for (num = 1; num <= 100; num = num * 2) {
		if ((num * 2) > max_num) {
			break;
		}
	}

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

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxm=3e3+2;
 ll dp[maxm][maxm];
ll arr[maxm];
ll cal(int start,int end)
{
	if(start==end)return arr[start];
    if(dp[start][end]!=-1)return dp[start][end];
	return dp[start][end]=max(arr[start]-cal(start+1,end),arr[end]-cal(start,end-1));
}
int main()
{ 
   int n;cin>>n;memset(dp,-1,sizeof(dp));
   for(int i=0;i<n;i++)cin>>arr[i];
   	cout<<cal(0,n-1);  		
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,X;
    string S;
    cin >> N >>X;
    vector<ll> vec(N);

    REP(i, N)
        cin >> vec.at(i);
    
    vector<ll> sa(N);
    REP(i, N)
    sa.at(i) = max(X, vec.at(i)) - min(X, vec.at(i));

    ll ans = sa.at(0);
    REP(i, N){
        
        ll tmp2 = gcd(ans, sa.at(i));
        ans = tmp2;
    }
    cout << ans << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(x,array) for(auto& (x):(array))
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 2000000009


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<pint> vpint;

vint vec(100003);
map<int,int> table1,table2;

int main(){
    int n;

    cin>>n;
    rep(i,n)cin>>vec[i];
    rep(i,n){
        if(i%2==0){
            table1[vec[i]]++;
        }
        else{
            table2[vec[i]]++;
        }
    }
    if(n==2){
        if(vec[0]==vec[1])cout<<1<<endl;
        else cout<<0<<endl;
        return 0;
    }
    int a1,a2,b1,b2;
    int p1=0,p2=0,q1=0,q2=0;
    int i=0;
    table1[-1]=0;
    table2[-1]=0;
    forin(x,table1){
        if(p1<=x.second){
            a1=x.first;
            p1=x.second;
        }
    }
    forin(x,table1){
        if(p2<=x.second && a1!=x.first){
            a2=x.first;
            p2=x.second;
        }
    }

    forin(x,table2){
        if(q1<=x.second){
            b1=x.first;
            q1=x.second;
        }
    }
    forin(x,table2){
        if(q2<=x.second && b1!=x.first){
            b2=x.first;
            q2=x.second;
        }
    }
    if(a1!=b1){
        cout<<n-p1-q1<<endl;
    }
    else{
        if(n-p1-q2<=n-p2-q1)cout<<n-p1-q2<<endl;
        else cout<<n-p2-q1<<endl;
    }
    
    
}

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

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

    int nextFirstPos = 0, count = 0;
    while (1)
    {
        nextFirstPos = s.find("ABC", nextFirstPos);

        if (nextFirstPos < 0)
        {
            break;
        }
        else
        {
            ++count;
            nextFirstPos += 3;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
N, M = gets.split(" ").map(&:to_i)
LR = []
M.times do |m|
    LR.append(gets.split(" ").map(&:to_i))
end

l_max = 0
r_min = 110000

LR.each do |lr|
    l_max = [l_max, lr[0]].max
    r_min = [r_min, lr[1]].min
end

if r_min - l_max < 0
    puts 0
else
    puts r_min - l_max + 1
end

Measured memory_bytes: 20984
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static long allLcm;

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			allLcm = 1;
			Stick[] nodes = new Stick[N];
			boolean[] hasParent = new boolean[N];
			int[] l = new int[N];
			int[] r = new int[N];
			for (int i = 0; i < N; ++i) {
				int p = sc.nextInt();
				int q = sc.nextInt();
				nodes[i] = new Stick(p, q);
				l[i] = sc.nextInt() - 1;
				r[i] = sc.nextInt() - 1;
				if (l[i] != -1) hasParent[l[i]] = true;
				if (r[i] != -1) hasParent[r[i]] = true;
			}
			int root = -1;
			for (int i = 0; i < N; ++i) {
				if (l[i] != -1) {
					nodes[i].left = nodes[l[i]];
				} else {
					nodes[i].left = new Weight();
				}
				if (r[i] != -1) {
					nodes[i].right = nodes[r[i]];
				} else {
					nodes[i].right = new Weight();
				}
				if (!hasParent[i]) root = i;
			}
			nodes[root].set(new Rational(1, 1));
			System.out.println(nodes[root].sum());
		}
	}

	static abstract class Node {
		abstract long sum();

		abstract void set(Rational v);
	}

	static class Stick extends Node {
		Node left, right;
		int p, q;

		Stick(int p, int q) {
			this.p = p;
			this.q = q;
		}

		long sum() {
			return left.sum() + right.sum();
		}

		void set(Rational v) {
			this.left.set(v.mul(new Rational(q, p + q)));
			this.right.set(v.mul(new Rational(p, p + q)));
		}
	}

	static class Weight extends Node {
		Rational w;

		long sum() {
			return w.num * (allLcm / w.den);
		}

		void set(Rational v) {
			this.w = v;
			allLcm = lcm(allLcm, v.den);
		}
	}

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

	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	static class Rational {
		long num, den;

		Rational(long n, long d) {
			long gcd = gcd(n, d);
			this.num = n / gcd;
			this.den = d / gcd;
		}

		Rational add(Rational o) {
			return new Rational(this.num * o.den + this.den * o.num, this.den * o.den);
		}

		Rational mul(Rational o) {
			return new Rational(this.num * o.num, this.den * o.den);
		}

	}

}

Measured memory_bytes: 12000
#include <stdio.h>
#include <string.h>

int rotate(char pat[8][9])
{
    char bitmap[8][9]={0};
    int x,y;
    for(x = 0;x < 8;x++){
        for(y = 0;y < 8;y++){
            bitmap[x][7-y] = pat[y][x];
        }
    }
    memcpy(pat,bitmap,sizeof(bitmap));
    return 0;
}

int main(void)
{
    char pat[8][9];
    int i;
    for(i = 0;i < 8;i++){
        scanf("%s",pat[i]);
    }
    printf("90\n");
    rotate(pat);
    for(i=0;i<8;i++)printf("%s\n",pat[i]);
    printf("180\n");
    rotate(pat);
    for(i=0;i<8;i++)printf("%s\n",pat[i]);
    printf("270\n");
    rotate(pat);
    for(i=0;i<8;i++)printf("%s\n",pat[i]);
    return 0;
}

Measured memory_bytes: 524
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//236
	ll n,k;
	cin>>n>>k;
	ll m= (k*(k-1)/2)%MOD;
	ll ans = 0;
	vi arr(n);
	for(int &i:arr)cin>>i;
	int a = 0,b=0;
	for(int i=0;i<n;i++) {
		a=0;b=0;
		for(int j=0;j<i;j++)if(arr[j]>arr[i])a++;
		for(int j=i;j<n;j++)if(arr[j]>arr[i])b++;
		ans = (ans+(m*(a+b))%MOD)%MOD;
		ans = (ans+(a*k)%MOD)%MOD;
	}
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, m, n) for(ll i = (ll)m; i < (ll)n; i++)
#define PER(i, m, n) for(ll i = (ll)m; i > (ll)n; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main() {
    int n, t;
    cin >> n >> t;
    vector<ll> v(n);
    REP(i, 0, n) cin >> v[i];
    ll ans = t;

    REP(i, 1, n){
        ll dt = v[i] - v[i-1];
        if(dt <= t) ans += dt;
        else ans += t; 
    }

    cout << ans << endl;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> list(m,pair<int,int>(0,0));
  for(int i=0;i<m;i++) {
    int a,b;
    cin >> a >> b;
    list.at(i)=pair<int,int>(b,a);
  }
  sort(list.begin(),list.end());
  int temp=-1;
  int count=0;
  for(int i=0;i<m;i++) {
    if(list.at(i).second>temp) {
      temp=list.at(i).first-1;
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var N, W int
	fmt.Scanf("%d %d", &N, &W)

	type Item struct {
		w, v int
	}

	items := make([]Item, N)

	for i := range items {
		var item Item
		fmt.Scanf("%d %d", &item.w, &item.v)
		items[i] = item
	}

	// i 番目までの品物のみで重さが W 以下となる場合の価値の最大値
	dp := make([][]int, N+1)
	for i := range dp {
		dp[i] = make([]int, W+1)
	}

	for i := 0; i < N; i++ {
		item := items[i]

		for w := 0; w <= W; w++ {
			// i 番目を選ばない時
			dp[i+1][w] = max(dp[i+1][w], dp[i][w])

			// i 番目を選ぶ時
			if w-item.w >= 0 {
				dp[i+1][w] = max(dp[i+1][w], dp[i][w-item.w]+item.v)
			}
		}
	}

	fmt.Println(dp[N][W])
}

func max(a, b int) int {
	if a > b {
		return a
	}

	return b
}


Measured memory_bytes: 81792
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  int t;
  while(cin >> t, t) {
    int n;cin >> n;
    int sum = 0;
    REP(i,n) {
      int s, t;
      cin >> s >> t;
      sum += t-s;
    }
    if (sum >= t) {
      cout << "OK" << endl;
    } else {
      cout << t-sum << endl;
    }
  }
  
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

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

struct Cake {
	int H, W, S;
	Cake(ll _H, ll _W) :H(_H), W(_W) {
		S = H * W;
	}
	Cake() :H(0), W(0), S(0) {}
	bool operator<(const Cake& c) {
		return S < c.S;
	}
};

void solve() {
	ll n, W, H; scanf("%lld %lld %lld", &n, &W, &H); if (n == 0 and W == 0 and H == 0) exit(0);
	vector<Cake> vc;
	vc.emplace_back(H, W);
	for (int i = 0; i < n; i++) {
		ll p, s; scanf("%lld %lld", &p, &s);
		p--;
		auto itr = vc.begin() + p;
		s %= (itr->H + itr->W) * 2;
		if (s > itr->H + itr->W) s -= itr->H + itr->W;
		Cake c1, c2;

		if (s < itr->W) {
			c1 = Cake(itr->H, s);
			c2 = Cake(itr->H, itr->W - s);

		}
		else {
			//cout << i << " " << s << endl;
			s -= itr->W;
			c1 = Cake(s, itr->W);
			c2 = Cake(itr->H - s, itr->W);
		}
		if (c2 < c1) swap(c1, c2);
		//cout << i << " " << c1.H << " " << c1.W << " " << c2.H << " " << c2.W << endl;
		vc.erase(itr);
		vc.emplace_back(c1);
		vc.emplace_back(c2);
	}
	sort(vc.begin(), vc.end());
	for (int i = 0; i < vc.size(); i++) {
		cout << vc[i].S;
		if (i + 1 == vc.size()) cout << "\n";
		else cout << " ";
	}
}

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

	int kkt = 89;
	while (kkt) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;
    vi a[n+1];

    for(int i = 2 ; i <= n ; i++){
        int x;
        cin >> x;
        a[x].pb(i);
    }

    for(int i = 1 ; i <= n ; i++){
        cout << a[i].size() << endl;
    }
    return 0;
}

Measured memory_bytes: 14540
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int m = max(a, max(b, c));
    int sum = a + b + c;
    if (sum % 2 != (3 * m) % 2) m++;
    cout << (3*m - sum)/2 << endl;
}


Measured memory_bytes: 3600
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new AOJCGL_1C().doIt();
	}

	class AOJCGL_1C{
		private Point2D projection(Line2D l,Point2D p2){
			double kyori = l.getP1().distance(l.getP2());
			double angle = angle(l.getP1(),l.getP2(), p2);
			double t = l.getP1().distance(p2) * Math.cos(angle);
			Point2D result = new Point2D.Double(l.getP1().getX()+(l.getP2().getX()-l.getP1().getX())*t/kyori,
					l.getP1().getY()+(l.getP2().getY()-l.getP1().getY())*t/kyori);
			return result;
		}
		private double angle(Point2D p0, Point2D p1, Point2D p2){
			return Math.atan2(p2.getY()-p0.getY(),p2.getX()-p0.getX())-
					Math.atan2(p1.getY()-p0.getY(),p1.getX()-p0.getX());
		}
		void doIt(){
			Point2D p0 = new Point2D.Double(in.nextDouble(),in.nextDouble());
			Point2D p1 = new Point2D.Double(in.nextDouble(),in.nextDouble());
			int q = in.nextInt();
			for(int i=0;i<q;i++){
				Point2D p2 = new Point2D.Double(in.nextDouble(), in.nextDouble());
				Point2D ans = projection(new Line2D.Double(p0, p1), p2);
				System.out.printf("%.9f %.9f\n",ans.getX(),ans.getY());
			}
		}
	}

}

Measured memory_bytes: 39384
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

ll N;
vector<vector<ll>> edge;
bool jd=false;

bool dfs(ll u,ll p){
  int cnt=0;
  for(auto &v:edge[u]){
    if(v==p){continue;}
    if(dfs(v,u)){cnt++;}
  }
  if(cnt>=2){jd=true; return false;}
  if(cnt==1){return false;}
  if(p==-1){jd=true;}
  return true;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  edge.resize(N);
  for(int i=1;i<N;i++){
    int u,v;
    cin>>u>>v;
    u--; v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  dfs(0,-1);
  cout<<(jd?"First":"Second")<<endl;

  


  return 0;
}


Measured memory_bytes: 6400
def resolve():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    c = 0
    if a[0] > x:
        c += a[0] - x
        a[0] = x
    for i in range(n - 1):
        s = a[i] + a[i + 1]
        if s > x:
            c += s - x
            a[i + 1] -= s - x
    print(c)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 14052
#include<iostream>
#include<string>
using namespace std;
int main(){
  long long N,M,a,b,c,L;
  string S,T;
  cin >> N >> M >> S >> T;
  a=N;b=M;
  while(N != M){
    if(M>N) M=M-N;
    if(N>M) N=N-M;
  }
  c=M;
  L=a*b/c;
	for(int i=0;i<a;i++)
		if(i*b%a == 0&&S[i]!=T[i*b/a]){
				cout<<-1;
				return 0;
			}
	cout << L << endl;;
}

Measured memory_bytes: 512
#include <stdio.h>

#define MAX_SIZE 101

int solve(char s[], int n) {
    // todo
    if(n % 2 == 1) {
        return 0;
    }

    int half_n = n / 2;

    for(int i = 0; i < half_n; i ++) {
        if (s[i] != s[half_n + i]) {
            return 0;
        }
    }

    return 1;
}

int main() {
    int n, result;
    char s[MAX_SIZE];
    
    scanf("%d\n", &n);
    gets(s);

    result = solve(s, n);

    if (result)
        puts("Yes");
    else
        puts("No");
}

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

int main(){
  int H,W,count=0;
  cin >> H >> W;
  vector<vector<char>> A(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> A.at(i).at(j);
      if(A.at(i).at(j)=='#'){
        count++;
      }
    }
  }
  if(count==H+W-1){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<ll,ll>
#define iii pair<pair<ll, ll>, ll >
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
using namespace std;

int main(){
    int x;
    cin>>x;
    if(x>=400 && x<600)cout<<8<<endl;
    else if(x>=400 && x<800)cout<<7<<endl;
    else if(x>=400 && x<1000)cout<<6<<endl;
    else if(x>=400 && x<1200)cout<<5<<endl;
    else if(x>=400 && x<1400)cout<<4<<endl;
    else if(x>=400 && x<1600)cout<<3<<endl;
    else if(x>=400 && x<1800)cout<<2<<endl;
    else if(x>=400 && x<2000)cout<<1<<endl;
}


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

using namespace std;


using int64 = long long;

int64 dp[100000][4];
int N, A[100000][4];

int64 rec(int idx, int pv) {
  if(idx == N) return 0;
  if(~dp[idx][pv]) return dp[idx][pv];
  int64 ret = 0;
  for(int i = 0; i < 3; i++) {
    if(pv == i) continue;
    ret = max(ret, rec(idx + 1, i) + A[idx][i]);
  }
  return dp[idx][pv] = ret;
}

int main() {
  cin >> N;
  memset(dp, -1, sizeof(dp));
  for(int i = 0; i < N; i++) cin >> A[i][0] >> A[i][1] >> A[i][2];
  cout << rec(0, 3) << endl;

}


Measured memory_bytes: 11136
#include <cstdlib>
#include <iostream>
 
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
 
  int a,b;
  std::cin >> a >> b;
  std::cout << a*b << " " << 2*(a+b) << std::endl;
  return EXIT_SUCCESS;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll N, X, T;
    cin >> N >> X >> T;
    PRINT(((N + X - 1) / X) * T);
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n;
    map<int, int> mp;
    rep(i, 0, n){
        int d;
        cin >> d;
        mp[d]++;
    }
    cin >> m;
    bool f = true;
    rep(i, 0, m){
        int t;
        cin >> t;
        if(mp[t] != 0){
            mp[t]--;
        }else{
            f = false;
        }
    }
    cout << (f ? "YES" : "NO") << endl;
}

Measured memory_bytes: 14848
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int n;
    int R[MAX];

    cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> R[i];
    }

    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1;i < n;i++) {
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }

    cout << maxv << endl;

    return 0;
}



Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

void solve() {
  ll N, K;
  cin >> N >> K;
  vector<ll> p(N), c(N);
  rep(i, N)
    cin >> p[i], p[i]--;
  rep(i, N)
    cin >> c[i];

  ll ans = -1e18;
  rep(s, N) {
    ll su = 0, len = 0, k = K-1;
    ll i = p[s];
    while (true) {
      len++;
      su += c[i];
      if (i == s) break;
      i = p[i];
    }

    //cout << s << " " << len << " " << su << endl;
    ll score1 = 0, score2 = c[s];
    if (su > 0) {
      ll nLoop = k / len;
      k -= nLoop * len;
      score1 += nLoop * su;
    }
    chmax(ans, score1 + score2);
    //cout << "k = " << k << endl;

    i = p[s];
    rep(_, N+10)  {
      if (k <= 0) break;
      score2 += c[i];
      i = p[i];
      chmax(ans, score1 + score2);
      k--;
    }
  }
  cout << ans << endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


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

int main(){
   int n;
   cin >> n;
   vector<int> d(n);
   for(int i = 0; i < n; i++) cin >> d[i];
   sort(d.begin(),d
   .end());
   int ans = d[n/2] - d[n/2 -1];
   cout << ans << endl;
   return 0;

}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!

A = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
K = int(input())
print(A[K - 1])

Measured memory_bytes: 3060
import numpy
a,b = map(int,input().split())

if numpy.sign(a*b)==-1:
  print('Zero')
elif (numpy.sign(a)==1) or (numpy.sign(b)==1):
  print('Positive')
elif (a-b)%2==0:
  print('Negative')
else:
  print('Positive')

Measured memory_bytes: 12480
#include <bits/stdc++.h>
using namespace std;
int main(){
	int w;
	while(1){
		cin>>w;
		if(w==-1)break;
		int res=1150;
		if(w>10)res+=(w-10)*125;
		if(w>20)res+=(w-20)*15;
		if(w>30)res+=(w-30)*20;
		cout<<4280-res<<endl;
	}
}

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

int main()
{
    int n, sum = 0;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    for (int i = 0; i < n-1; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += a[i] * a[j];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	while(1){
		int N, M; cin >>N>>M;
		if(!N && !M) break;

		int r; cin >>r;
		int pc[1001];
		static int time[10001][1261];
		fill(time[0], time[10000], 0);
		for(int i=0; i<r; i++){
			int t, n, m, s; cin>>t>>n>>m>>s;
			if(s==1){
				pc[n] = t;
			} else{
				for(int j=pc[n]; j<t; j++){
					time[m][j] = 1;
				}
			}
		}

		int q; cin >> q;
		for(int i=0; i<q; i++){
			int s, e, m; cin>>s>>e>>m;
			int count=0;
			for(int j=s; j<e; j++){
				count += time[m][j];
			}
			cout << count << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 52272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	int ans = 0;
	rep2(i,1,n+1){
		int num = i;
		int digit = 0;
		while(num){
			num /= 10;
			digit++;
		}
		if(digit%2) ans++;
	}
	out(ans);
}




Measured memory_bytes: 256
from math import sqrt

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]

def calc(r): #半径rが与えられたときに全てが重なるかを判定
    lst = [] #交点を入れるリスト
    for i in range(N - 1):
        x1 = XY[i][0]
        y1 = XY[i][1]
        for j in range(i + 1, N):
            x2 = XY[j][0]
            y2 = XY[j][1]
            diff = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

            if diff > 2 * r:
                return False
            
            h = sqrt(r ** 2 - (diff / 2) ** 2)
            
            if x1 == x2:
                ny = (y1 + y2) / 2
                lst.append([x1 - h, ny])
                lst.append([x1 + h, ny]) 
            elif y1 == y2:
                nx = (x1 + x2) / 2
                lst.append([nx, y1 - h])
                lst.append([nx, y1 + h])
            else:
                a = (y2 - y1) / (x2 - x1) #2点を結ぶ直線の傾き

                b = -1 / a

                size = sqrt(1 + b ** 2)

                nx = h / size
                ny = nx * b

                #もとの2点の中点
                xc = (x1 + x2) / 2
                yc = (y1 + y2) / 2

                lst.append([xc + nx, yc + ny])
                lst.append([xc - nx, yc - ny])
    # print (r)
    # print (lst)
    nr = r + eps
    for x, y in lst: #中心の点
        flag = True
        for X, Y in XY:
            tmp = (x - X) ** 2 + (y - Y) ** 2
            if tmp > nr ** 2:
                flag = False
                break
        if flag:
            return True
    return False
    
l = 0
r = 1000

eps = 10 ** (-9)

for i in range(100):
    mid = (l + r) / 2
    if calc(mid):
        r = mid
    else:
        l = mid

print (r)

Measured memory_bytes: 3396
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

void solv()
{
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	if (a + b + c >= 22){
		printf("bust");
	}
	else{
		printf("win");
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll modinv(ll a) {
    ll m=Mod;
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}



int main(){
  ll i,j;
  ll n;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++) cin>>a[i];
  ll sum=0;
  for(i=0;i<n;i++){
      sum=sum^a[i];
  }


      ll tmp=0;
      ll z=1;
      ll q=modinv(2);
      vector<ll> v0(1<<20,1),v1(1<<20,0);
      vector<ll> vz(1<<20,0);

      for(i=0;i<n;i++){
          tmp=tmp^a[i];
          if(tmp==0){
              z++;
              q*=2;
              q%=Mod;
          }
          else {
              v0[tmp]+=v1[tmp]*(z-vz[tmp]);
              v0[tmp]%=Mod;
              v1[tmp]+=v0[tmp];
              v1[tmp]%=Mod;
              vz[tmp]=z;

          }
      }

      if(sum!=0) {
          cout<<v0[sum]<<endl;
      }

      else {
          ll ans=0;
          for(i=0;i<(1<<20);i++) ans+=v1[i];
          cout<<(ans+q)%Mod<<endl;
      }
     

  return 0;
}

Measured memory_bytes: 28800
#include<iostream>
#include<string>
#include <sstream>
using namespace std;
int main() {

	int n;
	int sum=0;
	string sn;
	
	cin >> sn;

	string temp;
	for (int i = 0; i < sn.size(); i++) {
		temp = sn[i];
		n = atoi(temp.c_str());
		sum += n;
	}
	if (sum % 9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 3356
n = int(input())
A = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(n - i - 1):
        if (A[j] > A[j + 1]):
            A[j], A[j + 1] = A[j + 1], A[j]
            count += 1

print(' '.join(map(str, A)))
print(count)



Measured memory_bytes: 5600
#include <iostream>

using namespace std;
void swap(int &a, int &b);

int main()
{
	int x[3000][2];
	int count = 0;
	while(1)
	{
		cin >> x[count][0] >> x[count][1];
		if (x[count][0] == 0 && x[count][1] == 0)
			break;
		count++;
	}

	for (int i = 0; i < count; ++i)
	{
		if (x[i][1] < x[i][0])
			swap(x[i][0], x[i][1]);
		cout << x[i][0] << " " << x[i][1] << endl;
	}

	return 0;
}

void swap(int &a, int &b)
{
	int temp = a;
	a = b;
	b = temp;
	return;
}




Measured memory_bytes: 3084
'''
ITP-1_7-B
 ????????????????????°
1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????????????????????????°???
?±???????????????°?????????????????????????????????
????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????
1 + 3 + 5 = 9
2 + 3 + 4 = 9
??????????????????????????????
???Input
?????°??????????????????????????\?????¨??????????????????????????????????????????????????§??????
????????§??????????????? n???x ??? 1 ???????????????????????????
n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
n ??? 3 ??\??? 100?????\?????¨????????????
???Output
????????????????????????????????????????????????????????°????????????????????????????????????
'''

while True:
    n, x = map(int, input().split())

    # EndCheck
    if n == x == 0:
        break

    ansCnt = 0
    for cnt1 in range(1,n+1):
        for cnt2 in range(cnt1+1,n+1):
            for cnt3 in range(cnt2+1,n+1):
                if cnt1 + cnt2 + cnt3 == x:
                    ansCnt += 1
                    break

    print(ansCnt)

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

#define COUT(x) cout << x << endl
#define CIN(x) cin >> x
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define EXIST(s, e) (s.find(e) != s.end())
#define SORT(c) sort(c.begin(), c.end())
#define ERASEUNIQE(v) v.erase(unique(v.begin(), v.end()), v.end())

// 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();
}

// math
template <class T>
inline T sqr(T x) { return x * x; }

// typedef
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

// container util
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()

// constant
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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



int main(int argc, char const *argv[])
{
    int k, odd, even, ans;
    CIN(k);

    if (k % 2 == 0) {
        odd = k / 2;
        even = k / 2;
    }
    else
    {
        even = k / 2;
        odd = (k+1) / 2;
    }

    ans = odd * even;

    COUT(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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, k;
ll T[100000];

int check(ll P) {
    int i = 0;
    rep(j, k) {
        ll s = 0;
        while(s + T[i] <= P) {
            s += T[i];
            i++;
            if(i == n) return n;
        }
    }
    return i;
}

int solve() {
    ll left = 0;
    ll right = 100000 * 10000;
    ll mid;
    while(right - left > 1) {
        mid = (left + right) / 2;
        int v = check(mid);
        if(v >= n) right = mid;
        else left = mid;
    }

    return right;
}

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

    cin >> n >> k;
    rep(i, n) cin >> T[i];
    ll ans= solve();
    cout << ans << endl;
}


Measured memory_bytes: 3952
//2018.9.27 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e5+10;
namespace MAIN{
    int n;
    int a[N],b[N];
    int ans;
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)a[i]=b[i]=read();
        sort(b+1,b+n+1);
        for(res i=1;i<=n;i++)a[i]=lower_bound(b+1,b+n+1,a[i])-b,ans+=_abs(a[i]-i)&1;
        printf("%d\n",ans>>1);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        a: i64,
        b: i64,
    }

    let a = a - 1;
    let b = b - 1;

    let ans = if (b - a) % 2 == 0 {
        (b - a) / 2
    } else {
        let f = |a: i64, b: i64| a + 1 + (b - (a + 1)) / 2;

        // aが1で待機パターン
        let a1 = f(a, b);

        // bがnで待機パターン
        let a2 = f(n - 1 - b, n - 1 - a);

        std::cmp::min(a1, a2)
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) // present in container?
#define vpresent(c,x) (find(all(c),x) != (c).end()) // present in vector?
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr), cout.tie(nullptr)
#define endl '\n'
using namespace std;

int n;
const int xd = 1e18;

void solve(){   
    int ans = 1, zero = 0;
    cin >> n;
    vector<int> ara(n);
    for(int i = 0; i < n; ++i){
        cin >> ara[i];
        if(ara[i] == 0)
            zero++;
    }

    if(zero){
        cout << 0 << endl;
        return;
    }
    
    for(int i = 0; i < n; ++i){
        if(ara[i] <=1000000000000000000/ ans ){
            ans *= ara[i];
        }else{
            cout << -1 << endl;
            return;
        }
    }
    cout << ans << endl;
}
signed main(){
	fastio;
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3992