akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}

Node treeMaximum(Node x){

  while(x->right !=NIL){
    x=x->right;
  }
  return x;
    

}

Node treeSearch(Node u, int k){

  if(u==NIL ||k==u->key)
     return u;
  if(k<u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
  
}

Node treeSuccessor(Node x){
  if(x->right !=NIL)
    return treeSuccessor(x->right);

  Node y;
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;

  }
      return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;



}

void inorder(Node u){

  if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);

  
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20608
#include<iostream>
#include<queue>
using namespace std;
int N,M,S,T,u,v,D;
vector<pair<int,int>>G[1<<17];
long mod=1e9+7,a[1<<17],b[1<<17],c[1<<17],d[1<<17];
priority_queue<pair<long,int>>P;
void calc(int S,long*d,long*w)
{
	for(int i=w[S]=1;i<=N;)d[i++]=-1e18;
	P.push({d[S]=0,S});
	while(P.size())
	{
		long c=P.top().first,u=P.top().second;
		P.pop();
		if(d[u]==c)for(auto p:G[u])
		{
			long v=p.first,nxt=c-p.second;
			if(d[v]<nxt)w[v]=w[u],P.push({d[v]=nxt,v});
			else if(d[v]==nxt)(w[v]+=w[u])%=mod;
		}
	}
}
main()
{
	cin>>N>>M>>S>>T;
	for(;cin>>u>>v>>D;G[v].push_back({u,D}))G[u].push_back({v,D});
	calc(S,a,b);calc(T,c,d);
	long ans=b[T]*b[T],t=a[T];
	for(u=0;u++<N;)
	{
		if(2*a[u]==t)ans-=b[u]*b[u]%mod*d[u]%mod*d[u]%mod;
		for(auto p:G[u])if(2*a[u]>t&&2*a[v=p.first]<t&&a[u]+c[v]-p.second==t)ans-=b[u]*b[u]%mod*d[v]%mod*d[v]%mod;
	}
	cout<<ans%mod;
}


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

using namespace std;
int mini(long long g,long long h,long long e)
{
    g=g>h?g:h;
    g=g>e?g:e;
    return g;
}
int main()
{
    int n,i,k=0;
    long long x,s=0;
    cin>>n;
    long long a[n];
    map<long long,int>m;
    for(i=0;i<n;i++)
    {
        cin>>x;
        m[x]++;
        if(m[x]==1)
        {
            a[k]=x;
            k++;
        }
    }
    int j,l;
    for(i=0;i<k-2;i++)
    {
        for(j=i+1;j<k-1;j++)
        {
            for(l=j+1;l<k;l++)
            {
                if((a[i]!=a[j])&&(a[i]!=a[l])&&(a[j]!=a[l]))
                {
                    x=mini(a[i],a[j],a[l]);
                    if(a[i]+a[j]+a[l]>x*2)
                        s +=(m[a[i]]*m[a[j]]*m[a[l]]);
                }
            }
        }
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    Pll p=Pll(0,A*100);
    ll sw=A*100, su=0;
    rep(a,31)rep(b,16)rep(c,3001)rep(d,1501){
        if(a==0&&b==0)continue;
        if(100*A*a+100*B*b+c*C+d*D > F)continue;
        if((A*a+B*b)*E < C*c+d*D)continue;
        if(p.fi*(100*A*a+100*B*b+C*c+D*d) < p.se*(C*c+D*d)){
            p.se = 100*A*a+100*B*b+C*c+D*d;
            p.fi = C*c+D*d;
        }
    }
    cout << p.se << " " << p.fi << endl;
}

Measured memory_bytes: 3620
from collections import defaultdict, deque

def solve(N, M, edges):
  outbound = defaultdict(deque)
  in_degree = defaultdict(int)
  for s,t in edges:
    outbound[s].append(t)
    in_degree[t] += 1

  q = deque()
  for i in range(N + 1):
    if in_degree[i] == 0:
      q.append(i)

  dp = [0 for _ in range(N + 1)]

  while q:
    node = q.popleft()
    for child in outbound[node]:
      dp[child] = max(dp[child], dp[node] + 1)
      in_degree[child] -= 1
      if in_degree[child] == 0:
        q.append(child)

  print(max(dp))


def iln(): return list(map(int, input().split()))


N, M = iln()
edges = []
for i in range(M):
  edges.append(iln())
  
solve(N, M, edges)


Measured memory_bytes: 105988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n); for (int i = 1; i <= (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n,cnt=0;
  cin >> n;
  rep(i,n){
    if(i==105||i==135||i==165||i==189||i==195){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    cout << A*B/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll a[n];
    ll cnt[100010] = {};
    ll sum = 0;
    rep(i, 0, n) {
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    int q;
    cin >> q;
    while (q--) {
        ll b, c;
        cin >> b >> c;
        sum -= b * cnt[b];
        sum += c * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 5156
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int a,b,c,d,n,t;
int main(){
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&n);
	t=n&1,n-=t,a*=8,b*=4,c*=2;
	printf("%lld\n",1ll*min(min(a,b),min(c,d))*(n>>1)+(min(min(a,b),c)>>1)*t);
	return 0;
}

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

int main()
{
    int a,b,h;
    int area;
    cin>>a>>b>>h;
    if(1<=a && a<=100 && 1<=b && b<=100 && 1<=h && h<=100)
    {
        area=((a+b)*h/2);
        cout<<area;
    }
    return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s;
    cin >> s;
    s = " " + s;
    if (s[3] == s[4] && s[5] == s[6]) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    string s;
    cin>>s;
    vector<ll>a;
    if(s[0]=='>')a.push_back(0);
    for(int i=0;i<s.length();){
        int j=i;
        while(true){
            if(i==s.length())break;
            if(s[j]==s[i])i++;
            else break;
        }
        a.push_back(i-j);
    }
    if(s[s.length()-1]=='<')a.push_back(0);
    ll ans = 0;
    //cout<<a.size()<<endl;
    for(int i=0;i<a.size();i+=2){
        ll m = max(a[i],a[i+1]);
        ans+=m;
        ans+=a[i]*(a[i]-1)/2;
        ans+=a[i+1]*(a[i+1]-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

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

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define ff first
#define ss second
#define err stderr
#define out stdout

typedef long long int ll;
typedef long double ld;
typedef short int sh;

inline void readI(int *i)
{
	register int t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=(t*znak);
}
inline void readUI(int *i)
{
	register int t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=t;
}
inline void readL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak*=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=(t*znak);
}
inline void readUL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=t;
}
inline void writeL(ll l)
{
	if (l==0)
	{
		putchar(48);
	}
	else
	{
		if (l<0)
		{
		   l*=-1;
		   putchar(45);
		}
		int _tab[21];
		int wsk=0;
		while (l>0)
		{
			++wsk;
			_tab[wsk]=(l%10)+48;
			l/=10;
		}
		for (int j=wsk; j>=1; --j)
		{
			putchar(_tab[j]);
		}
	}
}
inline void writeS(string s)
{
	int l=s.length();
	for (int i=0; i<l; ++i)
	{
		putchar(s[i]);
	}
}
inline void space()
{
	putchar(32);
}
inline void endl()
{
	putchar(10);
}

#define debug if(0)
#define debug2 if(1)
#define debug3 if(1)
#define debug4 if(1)

int n, p;
int tab[20][20];
ll dp[(1<<16)+5];

int main()
{
	readUI(&n);
	for (int i=0; i<n; ++i)
	{
		for (int j=0; j<n; ++j)
		{
			readI(&tab[i][j]);
		}
	}
	p=(1<<n);
	for (int x=1; x<p; ++x)
	{
		for (int i=0; i<n; ++i)
		{
			for (int j=0; j<i; ++j)
			{
				if (((1<<i)&x) && ((1<<j)&x))
				{
					dp[x]+=tab[i][j];
				}
			}
		}
		for (int maska=x-1; maska>=0; --maska)
		{
			maska=(maska&x);
			int maska1=(x^maska);
			dp[x]=max(dp[x], dp[maska]+dp[maska1]);
		}
		debug
		{
			fprintf (err, "x=%d dp[x]=%lld\n", x, dp[x]);
		}
	}
	fprintf (out, "%lld\n", dp[(1<<n)-1]);
	return 0;
}
/*
*/




Measured memory_bytes: 896
#include<stdio.h>
int main()
{
    int a,b,x,y,z,i;
    scanf("%d",&a);
    x=a%2;
    y=a/2;
    if(x==0)
    {
        printf("%d\n",y);
    }
    else
        printf("%d\n",y+1);


    return 0;
}


Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    cnt=0
    if n<=k:
        print(1)
    else:

        while True:
            n-=k
            n+=1
            cnt+=1
            if n<=k:
                cnt+=1
                print(cnt)
                break
resolve()

Measured memory_bytes: 13812
a,b,x=list(map(int, input().split()))

import math

if x <= (a*a*b)/2:
    h = (2*x)/(a*b)
    ans = math.degrees(math.atan(b/h))
else:
    h = 2*(a*a*b-x)/(a*a)
    ans = math.degrees(math.atan(h/a))
print(ans)

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

int main(void)
{
    ll n;
    cin >> n;
    int max = -1;
    string a;
    for(int i=sqrt(n);i>0;i--){
        if(n%i==0){
            a = to_string(n/i);
            break;
        }
    }
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let a = cin.next();
    let a = a.as_bytes();
    if a[1] == a[2] && (a[0] == a[1] || a[2] == a[3]) {
        println!("Yes");
    } else {
        println!("No");
    }
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int ceil(int x,int y){
	if(x%y==0){
		return x/y;
	}
	return x/y+1;
}
const int N=502;
int ar[N][N];
int main(){
	int num,i,j,k,l,n;
	cin>>num;
	n=ceil(num,4)*2;
	if(num==1){
		cout<<"1\n1";
		return 0;
	}
	cout<<n<<'\n';
	for(i=1;i<=n;i++){
		if((i&1)){
			for(j=1;j<=n;j++){
				ar[i][j]=(i+j)%n+1;
			}
		}
		else{
			for(j=1;j<=n;j++){
				ar[i][j]=(i+j)%n+1+n;
			}
		}
	}
	for(k=num+1;k<=2*n;k++){
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(ar[i][j]==k){
					ar[i][j]-=n;
				}
			}
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cout<<ar[i][j]<<' ';
		}
		cout<<'\n';
	}
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
int main() {
	int n,m,l,r;
	cin>>n>>m;
	r=m; l=m-n;
	FOR(i,0,n-1) l++,cout<<l<<" ";
	cout<<m<<" ";
	FOR(i,0,n-1) r++,cout<<r<<" ";
	return 0;
}


Measured memory_bytes: 256
def Base_10_to_n(X, n):
    if (int(X / n)):
        return Base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)


############################


#####関数をつかってみる．#####
######今回は二進数に変換######
# x10 = 35
# x2 = Base_10_to_n(x10, 2)
# print(x2)  # "100011"が表示される．def Base_10_to_n(X, n):
# print(len(x2))

n,k=map(int,input().split())
result = Base_10_to_n(n,k)
# print(result)
print(len(result))
# http://pixelbeat.jp/how_to_convert_n_ary_value_to_-decimal_and_decimal_to_n_ary/
#http://techtipshoge.blogspot.com/2010/05/10n.html
# http://iatlex.com/python/base_change#10n-2
# を参考にした


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

int main(){
    int X,Y,Z,a,c;
    cin >> X >> Y >>Z;
a =X;
X=Y;
Y=a;
c=X;
X=Z;
Z=c;

cout << X<<"\t"<< Y<<"\t"<< Z <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) v.begin(),v.end()

const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

// 二項係数計算
ll 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;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

const int D = 80 * 160 + 10;
const int D2 = D*2;
typedef bitset<D2> bs;
int a[100][100];
bs dp[90][90];



const int N = 20;
int h;
int w;
vector<vector<char>> maze(N, vector<char>(N,'#'));

const int MAX_WH = 21;
int d[MAX_WH][MAX_WH];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const int INF = 1001001001;
int bfs(int x, int y) {
    queue<P> que;
    rep(i,MAX_WH) {
        rep(j,MAX_WH) {
            d[j][i] = INF;
        }
    }
    que.push(P(x,y));
    d[x][y] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        for (int i=0; i< 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    int mx = 0;
    rep(i,h) rep(j,w) {
            if (d[j][i] == INF) continue;
            mx = max(mx, d[j][i]);
        }
    return mx;
}

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
void dfs(){

}
const int MX = 100000;
vector<int> G[MX];

int main(){
    int n;cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    int mi = 1001001001;
    for (int i=0;i<=100;i++) {
        int sum = 0;
        rep(j,n){
            sum += (v[j] - i) * (v[j] - i);
        }
        mi = min(sum, mi);
    }
    cout << mi << endl;
}



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

using namespace std;
typedef long long ll;

ll A,B,C,K;

int main(){
    cin >> A >> B >> C >> K;
    if(A >= K){
        cout << K << endl;
        return 0;
    }
    if(A+B >= K){
        cout << A << endl;
        return 0;
    }
    cout << A - (K - A - B) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstring>
 
using namespace std;
 
int n,k,cards[100000];
 
int main(void)
{
    while(true)
    {
        memset(cards,0,sizeof(cards));
        cin >> n >> k;
        if(n == 0 && k == 0)
            exit(0);
        for(int i = 0;i < k;i++)
            cin >> cards[i];
        sort(cards,cards+k);
        int result = 0;
        if(cards[0] != 0)
        {
            int maxcount = 0;
            for(int i = 0;i < k;i++)
            {
                int ptr_up = i;
                int ptr_dn = i+2;
                int prev_up = cards[i+1];
                int prev_dn = cards[i+1];
                int count = 1;
                while(ptr_up >= 0 && prev_up - 1 == cards[ptr_up])
                {
                    prev_up--;
                    ptr_up--;
                    count++;
                }
                while(ptr_dn < k && prev_dn + 1 == cards[ptr_dn])
                {
                    prev_dn++;
                    ptr_dn++;
                    count++;
                }
                maxcount = max(maxcount,count);
            }
            result = maxcount;
        }
        else
        {
            int maxcount = 0;
            for(int i = 1;i < k;i++)
            {
                int ptr_up = i;
                int ptr_dn = i+1;
                int prev_up = cards[i]+1;
                int prev_dn = cards[i]+1;
                int count = 1;
                while(ptr_up >= 0 && prev_up - 1 == cards[ptr_up])
                {
                    prev_up--;
                    ptr_up--;
                    count++;
                }
                while(ptr_dn < k && prev_dn + 1 == cards[ptr_dn])
                {
                    prev_dn++;
                    ptr_dn++;
                    count++;
                }
                maxcount = max(maxcount,count);
            }
            result = maxcount;
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 3512
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long foo (long arg) {
  long ret = 0;
  while (arg) {
    ret += arg % 10;
    arg /= 10;
  }
  return ret;
}

void solve() {
  long N, A, B;
  cin >> N >> A >> B;

  long ans = 0;

  for (long i = 1; i <= N; i++) {
    long tmp = foo(i);
    if (A <= tmp and tmp <= B) ans += i;
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdint>
#include <cstdio>

int main(void) {
    int n;
    std::scanf("%d\n", &n);
    int* u = new int[n];
    int* v = new int[n];
    bool* w = new bool[n];
    bool* node = new bool[n];
    bool* is_decided = new bool[n];
    for (int i = 0; i < n; i++) {
        int ww;
        std::scanf("%d %d %d\n", u + i, v + i, &ww);
        w[i] = (ww % 2 == 1);
        u[i]--;
        v[i]--;
        is_decided[i] = false;
    }
    node[u[0]] = false;
    is_decided[u[0]] = true;

    bool all_node_decided = false;
    while (!all_node_decided) {
        all_node_decided = true;
        for (int i = 0; i < n - 1; i++) {
            if (is_decided[u[i]] && !is_decided[v[i]]) {
                node[v[i]] = w[i] ? !node[u[i]] : node[u[i]];
                is_decided[v[i]] = true;
            }
            if (is_decided[v[i]] && !is_decided[u[i]]) {
                node[u[i]] = w[i] ? !node[v[i]] : node[v[i]];
                is_decided[u[i]] = true;
            }
            all_node_decided =
                all_node_decided && is_decided[u[i]] && is_decided[v[i]];
        }
    }

    for (int i = 0; i < n; i++) {
        if (node[i] == true) printf("1\n");
        if (node[i] == false) printf("0\n");
    }

    return 0;
}


Measured memory_bytes: 1536
n = int(input())
dic = {}
set = set()
for i in range(n):
    s = input()
    if s not in set:
        set.add(s)
        dic[s] = 1
    else:
        dic[s] += 1
vmax = max(dic.values())
maxkey = []
for i in dic.keys():
    if dic[i] == vmax:
        maxkey.append(i)
maxkey.sort()
for i in maxkey:
    print(i)

Measured memory_bytes: 107096
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<map>

using namespace std;

int N,K;

vector<int> color;

using Graph=vector<vector<int>>;

map<pair<int,int>,int> mp;

Graph E;

int dfs(int n,int m,int w)
{
  int s,t;
  s=1;
  for(auto u:E[n])
  {
    if(u==m) continue;
    
    if(u<n) t=mp[make_pair(u,n)];
    else t=mp[make_pair(n,u)];
      
    if(s<w || s>w)
    {
      color[t]=s;
    }
    
    if(s==w)
    {
      s++;
      color[t]=s;
    }
    
    dfs(u,n,s);
    
    s++;
  }
  
}
int main()
{
  cin >> N;
  int i,j,k,m,n;

  E.assign(N,vector<int>());

  for(i=0;i<N-1;i++)
  {
    
    cin >> j >> k ;
    j--;
    k--;
    
    mp[make_pair(j,k)]=i;
          
    E[k].push_back(j);
    E[j].push_back(k);

  }
  
  color.assign(N,0);
 
  K=0;
  for(i=0;i<N;i++)
  {
    n=E[i].size();
    K=max(K,n);
  }
    cout << K << endl;

  dfs(0,-1,0);
  
  for(i=0;i<N-1;i++)
  {
    cout << color[i] << endl ;
  }
  
  
  
}

Measured memory_bytes: 14720
#include <stdio.h>

int main(void)
{
	char str[1001];
	int i;
	
	scanf("%s", str);
	
	i = 0;
	while (str[i] != '\0'){
		str[i] = (str[i] - 'A' + 23) % 26 + 'A';
		i++;
	}
	
	printf("%s\n", str);
	
	return (0);
}

Measured memory_bytes: 524
n = int(input())
a = [list(map(int,input().split())),list(map(int,input().split()))]
ame = 0
ame_l = []
for i in range(n): #重複する列の選択
  for j in range(n): #各列足してく
    if i > j:
      ame += a[0][j]
    elif i == j:
      ame += a[0][j]+a[1][j]
    else:
      ame += a[1][j]
    if j == n-1:
      ame_l.append(ame)
      ame = 0
print(max(ame_l))

Measured memory_bytes: 9136
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  cout<<(abs(x-a)<abs(x-b)?'A':'B')<<endl;
  return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
lis=[a,b,c,d,e,f]
#print(lis)
a=lis.count(1)
b=lis.count(2)
c=lis.count(3)
d=lis.count(4)
kekka=[a,b,c,d]
a=kekka.count(1)
b=kekka.count(2)

if a!=2 and b!=2 :
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3064
mod=10**9+7
n=int(input())
s=input()
DP=[[0]*n for _ in range(n)]
for j in range(n):
    DP[0][j]=1
for i in range(n-1):
    if s[i]=='<':
        acc=0
        for j in range(n-1-i)[::-1]:
            acc+=DP[i][j+1]
            acc%=mod
            DP[i+1][j]+=acc
            DP[i+1][j]%=mod
    else:
        acc=0
        for j in range(n-i-1):
            acc+=DP[i][j]
            acc%=mod
            DP[i+1][j]+=acc
            DP[i+1][j]%=mod
print(DP[n-1][0])

Measured memory_bytes: 113244
//B - Kagami Mochi: 
//Assunto: 
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, x;
    set<int> stack;
    cin >> n;
    loop(i, 0, n) {
        cin >> x;
        stack.insert(x);
    }
    cout << stack.size() << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
const int mo = 1e9 + 7;
using namespace std;
int pow(int x, int t){
	int res = 1;
	while (t > 0){
		if (t & 1) res = 1ll * res * x % mo;
		x = 1ll * x * x % mo;
		t >>= 1;
	}
	return res;
}
int n, k, dp[10001]; vector <int> p;
int main(){
	scanf("%d%d", &n, &k);
	for (int i = 1; i * i <= n; i++){
		if (n % i == 0){
			p.push_back(i);
			if (i * i != n) p.push_back(n / i);
		}
	}
	sort(p.begin(), p.end()); int ans = 0;
	for (int i = 0; i < p.size(); i++){
		dp[i] = pow(k, (p[i] + 1) >> 1);
		for (int j = 0; j < i; j++)
			if (p[i] % p[j] == 0) dp[i] = (dp[i] - dp[j] + mo) % mo;
		ans = (ans + 1ll * dp[i] * (p[i] / (1 + (p[i] % 2 == 0))) % mo) % mo;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main(){
    
    int N;
    cin >> N;
    vector<int> H(N);
    
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    
    int ok = 0;
    
    for (int i = N-1; i > 0; i--) {
        if (H[i-1] > H[i] ) {
            ok = 1;
            
            H[i-1] = H[i-1] - 1;
            
            if (H[i-1] == H[i]) {
                ok = 0;
            }
         
            if (ok == 1) {
                break;
            }
        }
    }
    
    if (ok == 0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

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

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << 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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int a, b;

int main() {
	while (cin >> a >> b) cout << a-b << endl;
    return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int a, b, c;
  std::cin >> a >> b >> c;
  if (a + b == c || a + c == b || b + c == a)
    std::cout << "Yes"
              << "\n";
  else
    std::cout << "No"
              << "\n";
}


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

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

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	string s;
	cin >> n >> s;

	int k[2] = {}; // [0] = '(', [1] = ')'
	int l[2] = {};
	string res = "";
	for (int i = 0; i < n; i++) {
		if (s[i] == '(')
			k[0]++;
		else
			k[1]++;

		if (k[1] > k[0]) {
			l[0]++;
			k[0]++;
		}
	}
	l[1] = max(0, k[0] - k[1]);
	res = string(l[0], '(') + s + string(l[1], ')');

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define INF  -10000000000

int main()
{
    int n;
    int k;
    cin >> n >> k;
    cout << n-k+1 << endl;
}


Measured memory_bytes: 256
import math
a,b,c=map(int,input().split())

s=0.5*a*b*math.sin(math.radians(c))
l=a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(c)))
h=b*math.sin(math.radians(c))

print("%.6f %.6f %.6f"%(s,l,h))

Measured memory_bytes: 7868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXQ = 57;
const int MAXN = 17;
//Q种排列，Q~50个，枚举要不要需要2^50 ,
//所以还是回溯吧...枚举规则用哪一条

struct Node
{
    int a,b,c,d;
};
int N,M,Q;
int ret;
int A[MAXN];
Node nodes[MAXQ];
// cur [1...N]代表A的第几个（枚举）；因为N小所以选择枚举A的，Q小的话就枚举Q了
void search(int cur)
{
    if(cur > N)
    {
        int ans = 0;
        for(int i = 1;i <= Q;i ++)
        {
            Node & n = nodes[i];
            if(A[n.b] - A[n.a] == n.c) ans += n.d;
        }
        ret = max(ret, ans);
        return;
    }
    //A[cur-1]<=A[cur]<=M
    for(int i = A[cur-1];i <= M; i ++)
    {
        A[cur] = i;
        search(cur + 1);
    }
}
int main()
{
    cin>>N>>M>>Q;
    for(int i =1;i <=Q;i ++)
    {
        cin>>nodes[i].a>>nodes[i].b>>nodes[i].c>>nodes[i].d;
    }
    A[0] = 1;
    search(1);
    cout<<ret<<endl;
    return 0;
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	LL I,O,T,J,L,S,Z; cin >> I >> O >> T >> J >> L >> S >> Z;
	LL ans = I/2*2 + O + J/2*2 + L/2*2;
	if(I && J && L) ans = max(ans,3+O+(I-1)/2*2+(J-1)/2*2+(L-1)/2*2);
	cout << ans << endl;
	return 0;
}


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



//“Remember, Hope is a good thing, maybe the best of things, and no good thing ever dies.”

//― Stephen King


#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define in insert
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d ",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
//#define scan(v) for(int i = 0; i<n; i++){int x;cin>>x;v.pb(x);}
#define pi 2 * acos (0.0)
#define inf 1e9
#define co cout
#define en '\n'
#define re return
#define con continue
#define dbg cout<<"___________ok____________"<<endl;
#define yes() printf("YES\n")
#define no() puts("NO\n")
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define all(v) v.begin(), v.end()
#define unq(a) sort(all(a)), a.erase(unique(all(a)),a.end())
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
#define prn(v) for(auto x: v)cout<<x<<" ";
const double EPS = 1e-9;
const int MXX = 2e5 + 5;

vector<int>g[MXX];
bool vis[MXX];
int cnt = 0;
void dfs(int curr)
{
    vis[curr] = 1;
    cnt++;
    for(auto x: g[curr])
    {
        if(!vis[x])
        {
            dfs(x);
        }
    }
}
int main ()
{
    FAST_IO;
    int n, m;
    cin>>n>>m;
    FOR(i, 0, m)
    {
        int u, v;
        cin>>u>>v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    vi v;
    FOR(i, 0, n)
    {
        if(!vis[i])
        {
            cnt = 0;
            dfs(i);
            v.pb(cnt);
        }
    }
    sort(all(v));
    reverse(all(v));
    if(sz(v) == 1)co<<n<<en;
    else
    {
        co<<v[0]<<en;
    }
    return 0;
}


Measured memory_bytes: 20908
N = int(input())
S = str(input())
sum = 0
L = []
for i in range(N):
    if S[i] == "I":
        sum += 1
        L.append(sum)
    elif S[i] == "D":
        sum -= 1
        L.append(sum)

if max(L) > 0:
    print(max(L))

else:
    print(0)


Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <set>

struct UnionFind {
  std::vector<size_t> par;
  std::vector<size_t> rank;

  UnionFind(size_t N) : par(N), rank(N) {
    for (size_t i=0; i<N; i++) {
      par[i] = i;
    }
  }

  size_t root(size_t x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

  bool same(size_t x, size_t y) {
    return root(x) == root(y);
  }

  void unite(size_t x, size_t y) {
    size_t root_x = root(x);
    size_t root_y = root(y);
    if (root_x == root_y) return;

    if (rank[root_x] < rank[root_y])
      par[root_x] = root_y;
    else
      par[root_y] = root_x;

    if (rank[root_x] == rank[root_y])
      rank[root_x]++;
  }
};

int main() {
  int N, M;

  std::cin >> N >> M;

  UnionFind uf(N);

  for (int i=0; i<M; i++) {
    int x, y, _z;
    std::cin >> x >> y >> _z;

    uf.unite(x, y);
  }

  std::set<int> rs;

  for (int i=0; i<N; i++) {
    rs.insert(uf.root(i));
  }

  int ans = rs.size();

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <math.h>

int isprime(int);

int main(){
	int n,i;
	while(scanf("%d",&n) != EOF){
		for(i = 1;;i++) if(isprime(n - i)) {
			printf("%d ",n - i);
			break;
		}
		for(i = 1;;i++) if(isprime(n + i)) {
			printf("%d\n",n + i);
			break;
		}
	}
	return 0;
}

int isprime(int num){
	int i;
	for(i = 2;i <= (int)sqrt((double)num);i++){
		if(num % i == 0) return 0;
	}
	return 1;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	o, e := next(), next()

	b := make([]byte, len(o)+len(e))
	for i := 0; i < len(b); i++ {
		if i%2 == 0 {
			b[i] = o[i/2]
		} else {
			b[i] = e[i/2]
		}
	}

	fmt.Println(string(b))
}


Measured memory_bytes: 640
H,W=map(int,input().split())

dp = [[0 for i in range(W)] for j in range(H)]

arr = []
for h in range(H):
  s = list(input())
  arr.append(s)

if arr[0][0] == "#":
  dp[0][0] = 1
  
for h in range(H):
  for w in range(W):
    if h == 0:
      if w != 0:
        a = arr[h][w]
        b = arr[h][w-1]
        if a == b or a == ".":
          dp[h][w] = dp[h][w-1]
        else:
          dp[h][w] = dp[h][w-1] + 1
 
    else:      
      if w == 0:
        a = arr[h][w]
        b = arr[h-1][w]
        if  a == b or a == ".":
          dp[h][w] = dp[h-1][w]
        else:
          dp[h][w] = dp[h-1][w] + 1

      else:
        a = arr[h][w] 
        b = arr[h][w-1]
        c = arr[h-1][w]
        if a == "." or (a == b and a == c):
          dp[h][w] = min(dp[h][w-1],dp[h-1][w])
        elif a == b:
          dp[h][w] = dp[h][w-1]
        elif a == c:
          dp[h][w] = dp[h-1][w]
        else:
          dp[h][w] = min(dp[h][w-1] + 1,dp[h-1][w]+1)
    
print(dp[H-1][W-1])

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		int a, b;
		while ((n = in.nextInt()) != 0) {
			a = 0;
			b = 0;
			for (int i = 0; i < n; i++) {
				int pa = in.nextInt();
				int pb = in.nextInt();
				if (pa > pb) {
					a += (pa + pb);
				} else if (pa < pb) {
					b += (pa + pb);
				} else {
					a += pa;
					b += pb;
				}
			}
			System.out.println(a + " " + b);
		}
	}
}

Measured memory_bytes: 51744
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    int N, M, P, AC = 0, *WA, sum = 0;
    string S;
    bool* Q;

    cin >> N >> M;

    Q = new bool[N + 1];
    WA = new int[N + 1];
    for (int i = 1; i <= N; i++) {
        Q[i] = false;
        WA[i] = 0;
    }

    for (int i = 0; i < M; i++) {
        cin >> P >> S;
        if (!Q[P]) {
            if (S == "AC") {
                Q[P] = true;
                AC++;
                sum += WA[P];
            }
            else {
                WA[P]++;
            }
        }
    }

    cout << AC << " " << sum;

    return 0;

}



Measured memory_bytes: 768
n=int(input())
a= list(map(int, input().split()))
b=[0]*n

# 金
ans=1000
# 株
cnt=0
for i in range(1, n):
    if a[i] > a[i - 1]:
        b[i] -= 1
        b[i-1]+=1

for i in range(n):
    if b[i]==1:
        cnt+=ans//a[i]
        ans-=cnt*a[i]
    elif b[i]==-1:
        ans+=cnt*a[i]
        cnt=0

print(ans)

Measured memory_bytes: 61764
# encoding: utf-8
import sys
# input = sys.stdin.readline
inf = 10 ** 18
 
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
 
cnct = [[] for _ in range(N)]
for ai, bi in ab:
    cnct[ai - 1].append(bi - 1)
    cnct[bi - 1].append(ai - 1)
# print("#", cnct)
 
# start from a leaf
for src in range(N):
    if len(cnct[src]) > 1: break
# print("#", src)
 
import heapq
 
len_max = 0
for i in range(2):
    q = []
    d = [inf] * N
    prev = [None] * N
    #
    heapq.heappush(q, (0, src))
    d[src] = 0
    while len(q) > 0:
        du, u = heapq.heappop(q)
        # print("#", du, u)
        for dst in cnct[u]:
            # print("##", dst)
            if d[dst] > du + 1:
                d[dst] = du + 1
                prev[dst] = u
                heapq.heappush(q, (du + 1, dst))
    #
    if len_max == max(d):
        break
    elif len_max < max(d):
        len_max = max(d)
        src = d.index(len_max)
    else:
        continue
 
# print("#", len_max)
 
if len_max % 3 == 1:
    print('Second')    
else:
    print('First')

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int n;
    cin >> n;
    vector<pair<string, int> >p(n);
    vector<int> ans(n);
    vector<int> del;
    string tmp;
    rep(i,n)
    {
        cin >> tmp >> p[i].second;
        p[i].first = tmp;
    }
    string lower;
    int lower_pos;
    int ans_n = 1;
    bool flag;
    rep(j,n)
    {
        lower = "zzzzzzzzzzz";
        lower_pos = -1;
        rep(i,n)
        {
            flag = false;
            rep(k,del.size()) if(del[k] == i)
            {
                flag = true;
                break;
            }
            if(flag) continue;
            if(lower > p[i].first)
            {
                lower_pos = i;
                lower = p[i].first;
            }
            else if(lower == p[i].first)
            {
                if(p[lower_pos].second < p[i].second)
                {
                    lower_pos = i;
                }
            }
        }
        if(lower_pos == -1) ans[j] = n - 1;
        else ans[j] = lower_pos;
        del.push_back(lower_pos);
        ans_n++;
        //rep(k,del.size()) cout << del[k];
        //cout << endl;
    }
    rep(i,n) cout << ans[i]+1 << endl;
}


Measured memory_bytes: 256
//
//  Roller Coaster.cpp
//  National Olympiad in Informatics in Provinces
//
//  Created by 黄子齐 on 2019/9/28.
//  Copyright © 2019 黄子齐. All rights reserved.
//

#include <stdio.h>
int n, h, x;
int main() {
//    freopen("mytestdata.in", "r", stdin);
    scanf("%d%d", &n, &h);
    int sum=0;
    for (int i=1; i<=n; i++) {
        scanf("%d", &x);
        sum += (x>=h);
    }
    printf("%d\n", sum);
    return 0;
}


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

int main(){
  int n, q;
  cin >> n >> q;
  fenwick_tree<ll> fw(n);
  rep(i,n) {
    ll a;
    cin >> a;
    fw.add(i,a);
  }
  rep(i,q) {
    int t, x, y;
    cin >> t >> x >> y;
    if(t == 0) fw.add(x,y);
    else cout << fw.sum(x,y) << endl;
  } 
  return 0; 
}

Measured memory_bytes: 8212
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

RandomNumberGenerator RNG;
const unsigned long long base = RNG(10,1<<30);

struct RollingHash {
    typedef unsigned long long ull;

    const ull MASK30 = (1ull << 30) - 1;
    const ull MASK31 = (1ull << 31) - 1;
    const ull mod = (1ull << 61) - 1;
    const ull POSITIVIZER = mod * 3;

    vector<ull> hash,power;

    RollingHash(const vector<long long> &s) {
        int sz = s.size();
        hash.assign(sz + 1,0);
        power.assign(sz + 1,1);
        for (int i = 0; i < sz; i++) {
            power[i+1] = CalcMod(Mul(power[i],base));
            hash[i+1] = CalcMod(Mul(hash[i],base) + s[i]);
        }
    }

    ull get(int l, int r) {
        ull res;
        res = CalcMod(hash[r] + POSITIVIZER - Mul(hash[l],power[r-l]));
        return res;
    }


    ull Mul (ull a, ull b) {
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        ull midu = mid >> 30;
        ull midd = mid & MASK30;
        return (au * bu * 2 + midu + (midd << 31) + ad * bd);
    }

    ull CalcMod(ull val) {
        val = (val & mod) + (val >> 61);
        if (val > mod) val -= mod;
        return val;
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];

    vector<ll> p(N),q(2*N);
    rep(i,N) p[i] = B[i]^B[(i+1)%N];
    rep(i,2*N) q[i] = A[i%N]^A[(i+1)%N];

    RollingHash rp(p),rq(q);
    vector<int> K;
    rep(i,N) {
        if (rp.get(0,N) == rq.get(i,i+N)) K.emplace_back(i);
    }
    vector<ll> X(K.size());
    rep(i,K.size()) X[i] = B[0]^A[K[i]];

    rep(i,K.size()) cout << K[i] << " " << X[i] << endl;
}

Measured memory_bytes: 23156