akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.next());
        int k=Integer.parseInt(sc.next());
        int l=Integer.parseInt(sc.next());
        UnionFindTree roads=new UnionFindTree(n);
        for(int i=0;i<k;i++){
            roads.union(Integer.parseInt(sc.next())-1,Integer.parseInt(sc.next())-1);
        }
        UnionFindTree trains=new UnionFindTree(n);
        for(int i=0;i<l;i++){
            trains.union(Integer.parseInt(sc.next())-1,Integer.parseInt(sc.next())-1);
        }
        HashMap<Pair,Integer> map=new HashMap<>();
        for(int i=0;i<n;i++){
            Pair p=new Pair(roads.find(i),trains.find(i));
            if (map.containsKey(p)){
                map.put(p,map.get(p)+1);
            }else{
                map.put(p,1);
            }
        }
        StringBuilder sb=new StringBuilder();
        for (int i=0;i<n;i++){
            if(i!=0){
                sb.append(" ");
            }
            Pair p=new Pair(roads.find(i),trains.find(i));
            sb.append(map.get(p));
        }
        System.out.println(sb);
    }

    static class Pair{
        int x;
        int y;
        public Pair(int x,int y){
            this.x=x;
            this.y=y;
        }
        public int hashCode(){
            return Objects.hash(x,y);
        }
        public boolean equals(Object o){
            if(o==this){
                return true;
            }
            if(!(o instanceof Pair)){
                return false;
            }
            Pair p=(Pair) o;
                return p.x==x && p.y==y;
        }
    }

    static class UnionFindTree{
        int[] par;
        int[] rank;
        public UnionFindTree(int size){
            this.par=new int[size];
            this.rank=new int[size];
            for(int i=0;i<size;i++){
                makeSet(i);
            }
        }
        public void makeSet(int i){
            par[i]=i;
            rank[i]=0;
        }
        public void union(int x,int y){
            int xRoot=find(x);
            int yRoot=find(y);
            if(rank[xRoot]>rank[yRoot]){
                par[yRoot]=xRoot;
            }else if(rank[xRoot]<rank[yRoot]){
                par[xRoot]=yRoot;
            }else if(xRoot!=yRoot){
                par[yRoot]=xRoot;
                rank[xRoot]++;
            }
        }
        public int find(int v){
            if (par[v]!=v){
                par[v]=find(par[v]);
            }
            return par[v];
        }
        public boolean same(int x,int y){
            return find(x)==find(y);
        }
    }
}

Measured memory_bytes: 105324
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.format;

void main()
{
	auto input1 = readln.chomp.to!int;
	int maximumAmount = 0;
	int totalPaymentAmount;
	foreach(i; 0..input1){
		auto input2 = readln.chomp.to!int;
		if(maximumAmount <= input2){
			totalPaymentAmount += maximumAmount;
			maximumAmount = input2;
		}
		else
		{
			totalPaymentAmount += input2;
		}
	}

	writeln(totalPaymentAmount + (maximumAmount/2));
}

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

ll ppow(ll a,ll b,ll mod){
	a%=mod;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int a[3000];
int main(){
	int p;cin>>p;
	rep(i,p)scanf("%d",&a[i]);
	deque<int>v{1};
	rep(i,p){//*(x-i)
		deque<int>u=v;
		v.push_front(0);
		for(int j=v.size()-2;j>=0;j--){
			(v[j]+=p-u[j]*i%p)%=p;
		}
	}
	deque<int>ans(v.size()-1);
	rep(i,p){
		if(!a[i])continue;
		int d=0;
		deque<int>u;// /(x-i)
		for(int j=v.size()-1;j>0;j--){
			u.push_back((v[j]+p-d)%p);
			d=(p-i)*(v[j]-d)%p;
		}
		reverse(u.begin(),u.end());
		ll x=1;
		rep(j,p){
			if(j!=i)(x*=(j+p-i))%=p;
		}
		x=ppow(x,p-2,p);
		rep(j,u.size()){
			(ans[j]+=u[j]*x)%=p;
		}
	}
	for(int i:ans)cout<<i<<' ';
	cout<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,C;
  cin >> N >> C;
  int N_MAX=510;
  int C_MAX=40;
  int D[C_MAX][C_MAX]={0};
  for(int i=1;i<=C;i++){
    for(int j=1;j<=C;j++){
      cin >> D[i][j];
    }
  }
  int c[N_MAX][N_MAX]={0};
  int q;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      cin >> q;
      c[(i+j)%3][q]++;
    }
  }
  ll cnt=0;
  ll ans=INF;
  for(int i=1;i<=C;i++){
    for(int j=1;j<=C;j++){
      if(i==j)continue;
      for(int k=1;k<=C;k++){
        if(j==k||k==i)continue;
        cnt=0;
        for(int m=1;m<=C;m++){
          cnt+=D[m][i]*c[0][m];
          cnt+=D[m][j]*c[1][m];
          cnt+=D[m][k]*c[2][m];
        }
        ans=min(cnt,ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
long long n,m,i,j,k,l,p,q,u,dp[115][4][4],mod=1e9+7,ans;
string st1,st2;
int main()
{
	cin>>n>>st1>>st2;
	st1=" "+st1;
	st2=" "+st2;
	dp[0][0][0]=1;
	for (i=1;i<st1.length();i++)
	{
		if (st1[i]!=st2[i])
		{
			if (st1[i-1]==st1[i]&&st2[i-1]==st2[i])
			{
				for (j=1;j<=3;j++)
				{
					for (k=1;k<=3;k++)
					{
						dp[i][j][k]=(dp[i][j][k]+dp[i-1][j][k])%mod;
					}
				}
			}
			else			 
			{
				for (j=1;j<=3;j++)
				{
					for (k=1;k<=3;k++)
					{
						for (l=0;l<=3;l++)
						{
							for (p=0;p<=3;p++)
							{
								if (j!=l&&k!=p&&j!=k)
								{
									dp[i][j][k]=(dp[i][j][k]+dp[i-1][l][p])%mod;
								}
							}
						}
					}
				}
			}
		}
		else
		{
			for (j=1;j<=3;j++)
			{
				k=j;
				for (l=0;l<=3;l++)
				{
					for (p=0;p<=3;p++)
					{
						if (j!=l&&k!=p)
						{
							dp[i][j][k]=(dp[i][j][k]+dp[i-1][l][p])%mod;
						}
					}
				}
			}
		}
	}
	for (i=1;i<=3;i++)
	{
		for (j=1;j<=3;j++)
		{
			ans=(ans+dp[st1.length()-1][i][j])%mod;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
/*
g++ -std=c++11 -o2 -Wall ABC101C.cpp -o ./out/ABC101C.out
./out/ABC101C.out
*/

#include <bits/stdc++.h>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define tr(c, i) for (iter(c) != (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define mp make_pair

typedef long long ll;

int a[100001];

int main(){
//    freopen("./input/input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    int ans = 0;
    int nn = n;
    bool f = false;
    while (nn > 0) {
      if (f) ++nn;
      f = true;
      ++ans;
      nn -= k;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 640
from collections import deque

s = deque(list(input()))
n = int(input())
h = 1
hantensuu = 0

def change(flag):
    if flag==1:
        return 2
    else:
        return 1

for i in range(n):
    inputs = list(input().split())
    t = int(inputs[0])

    if len(inputs) == 3:
        f = int(inputs[1])
        c = inputs[2]
    if t == 1:
        h = change(h)
        hantensuu += 1
    if t == 2:
        if (f == 1 and h == 1) or (f==2 and h==2):
            s.appendleft(c)
        if (f == 2 and h == 1) or (f==1 and h ==2):
            s.append(c)
    
if hantensuu%2 !=0:
    s.reverse()

print("".join(s))

Measured memory_bytes: 8676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[][] array = new int[3][3];
		int n = sc.nextInt();
		int m = sc.nextInt();
		int gu = (n*(n-1))/2;
		int ki = (m*(m-1))/2;
		//System.out.println(gu);
		//System.out.println(ki);
		//System.out.println(4*3/2);
		System.out.println(gu+ki);
	}
}

Measured memory_bytes: 21588
h,w = map(int,input().split())
a = [list(input()) for i in range(h)  ]
lsti = []
lstj = []

for i in range(h):
    if "#" not in a[i]: lsti.append(i)

for j in range(w):
    for i in range(h):
        if a[i][j] == "#":
            break
    else:
        lstj.append(j)

for i in range(h):
    for j in range(w):
        if i not in lsti and j not in lstj:
            print(a[i][j],end = "")
    else:
        if i not in lsti:
            print("")

Measured memory_bytes: 4596
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll fun(ll x){
	if(x<0)return 0;
	if(x%4==0)return x;
	else if(x%4==1)return 1;
	else if(x%4==3)return 0;
	else if(x%4==2)return x+1;
}
int main(){
	ll l,r;cin>>l>>r;
	cout<<(fun(r)^fun(l-1))<<endl;
}

Measured memory_bytes: 256
n, q = map(int, input().split(" "))
parent = [i for i in range(n)]
rank = [0] * len(parent)

def root(s):
    if parent[s] == s:
        return s
    else:
        parent[s] = root(parent[s])
        return parent[s]

def same(s1, s2):
    if root(s1) == root(s2):
        print("1")
    else:
        print("0")

def unite(s1, s2):
    s1 = root(s1)
    s2 = root(s2)

    if s1 == s2:
        return

    if rank[s1] < rank[s2]:
        parent[s1] = s2
    else:
        parent[s2] = s1
        if rank[s1] == rank[s2]:
            rank[s1] += 1

for i in range(q):
    query, item1, item2 = input().split(" ")
    item1, item2 = int(item1), int(item2)

    if query == "0":
        unite(item1, item2)
    else:
        same(item1, item2)

Measured memory_bytes: 8052
N = int(input())
A = list(map(int,input().split()))

Ans = 0
sub = 1
for i in range(N-1):
    if A[i]==A[i+1]:
        sub += 1
    else:
        Ans += sub//2
        sub = 1
else:
    Ans += sub//2

print(Ans)


Measured memory_bytes: 3316
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def count(tsum, l, r):

    return tsum[r][r] - tsum[l - 1][r] - tsum[r][l - 1] + tsum[l - 1][l - 1]


def main():
    N, M, Q = in_nn()
    t = in_na()
    t = list(zip(t, t))
    L = t[:M]
    p = t[M:]

    tsum = np.zeros((N + 1, N + 1), np.int32)
    for i in range(M):
        a, b = L[i]
        a, b = a, b
        tsum[a][b] += 1

    tsum = np.cumsum(tsum, axis=0)
    tsum = np.cumsum(tsum, axis=1)

    for i in range(Q):
        l, r = p[i]
        print(count(tsum, l, r))


if __name__ == '__main__':
    main()


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

typedef long long ll;
const int N = 1e5 + 10, OO = 0x3f3f3f3f, mod = 100000007;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
#define sc1(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d %d", &a, &b)
#define vi vector<int>
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2};
//int dy[] = {1, 2, 2, 1, -1, -2, -2, -1}; //Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int x , y;

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


    cin >> x >> y;
    set < int > g1 = {1, 3 , 5, 7 , 8 , 10 , 12};
    set < int > g2 = {4 , 6 , 9 , 11};
    set < int > g3 = {2};
    if(g1.find(x) != g1.end() && g1.find(y) != g1.end())
        cout << "Yes\n";
    else if(g2.find(x) != g2.end() && g2.find(y) != g2.end())
        cout << "Yes\n";
    else if(g3.find(x) != g3.end() && g3.find(y) != g3.end())
        cout << "Yes\n";
    else
        cout << "No\n";


    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

// string => int
int s_to_i(const string& s){
	bool is_negative = false;
	int n = 0;
	for(int i=0 ; i < s.size() ; i++ ){
		if( i == 0 && s[i] == '-' ){
			is_negative = true;
			continue;
		}
		n = n * 10 + s[i] - '0';
	}
	return is_negative? -n : n ;
}

const int MAX_V = 300;
const int INF = 1e+8;
map<string,int> h;
int V = 0;
int G[MAX_V][MAX_V];

void init(){
	h.clear();
	V = 0;
	for(int i=0 ; i < MAX_V ; i++ ){
		for(int j=0 ; j < MAX_V ; j++ ){
			G[i][j] = (i == j)? 0 : INF ;
		}
	}
}

void add_edge(string A, string B, int cost){
	int u, v;
	if( h.count(A) ){
		u = h[A];
	}else{
		h[A] = V++;
		u = h[A];
	}
	if( h.count(B) ){
		v = h[B];
	}else{
		h[B] = V++;
		v = h[B];
	}
	G[u][v] = cost;
	G[v][u] = -cost;
}

int main(){
	int n;
	while( cin >> n , n ){
		// テ・ツ按敕ヲツ慊淌・ツ個?
		init();
		
		for(int i=0 ; i < n ; i++ ){
			string one, A, equal, x, B;
			cin >> one >> A >> equal >> x >> B;
			x = x.substr(3);
			add_edge(A, B, s_to_i(x));
		}
		
		for(int k=0 ; k < V ; k++ ){
			for(int i=0 ; i < V ; i++ ){
				for(int j=0 ; j < V ; j++ ){
					G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
				}
			}
		}
		bool ans = true;
		for(int i=0 ; i < V ; i++ ){
			if( G[i][i] < 0 ) ans = false;
		}
		cout << (ans? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 1588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    int s[H+2][W+2],vi[H+2][W+2];
    ll dp[H+2][W+2];
    REP(i,H+2) REP(l,W+2){
        s[i][l] = -1;
        dp[i][l] = MOD;
        vi[i][l] = 0;
    }

    for(ll i = 1; i <= H ;i++){
        for(ll l = 1; l <=W ;l++){
            char tmp;
            cin >> tmp;
            if(tmp == '.'){
                s[i][l] = 0;
            }else{
                s[i][l] = 1;
            }
        }
    }

    queue<pair<int, int> > q;
    q.push(make_pair(1,1));
    dp[1][1] = 0;

    // while(!q.empty()){
    for(ll i = 1; i < H+1;i++){
        for(ll l = 1; l < W+1;l++){
            pair<int,int> now = make_pair(i,l);
            q.pop();
            if(vi[now.first][now.second] == 0 ){
                vi[now.first][now.second] = 1;

                if(s[now.first+1][now.second] != -1){
                    q.push(make_pair(now.first+1,now.second));
                    if(s[now.first+1][now.second] != s[now.first][now.second]){
                        if(s[now.first][now.second] == s[1][1]){
                            dp[now.first+1][now.second] = min(dp[now.first][now.second]+1,dp[now.first+1][now.second]);
                        }else{
                            dp[now.first+1][now.second] = min(dp[now.first][now.second],dp[now.first+1][now.second]);
                        }
                    }else{
                        dp[now.first+1][now.second] = dp[now.first][now.second];
                    }
                    
                }if(s[now.first][now.second+1] != -1){
                    q.push(make_pair(now.first,now.second+1));
                    if(s[now.first][now.second+1] != s[now.first][now.second]){
                        if(s[now.first][now.second] == s[1][1]){
                            dp[now.first][now.second+1] = min(dp[now.first][now.second]+1,dp[now.first][now.second+1]);
                        }else{
                            dp[now.first][now.second+1] = min(dp[now.first][now.second],dp[now.first][now.second+1]);
                        }
                        
                    }else{
                        dp[now.first][now.second+1] = min(dp[now.first][now.second],dp[now.first][now.second+1]);
                    }
                }
            }
        }
    }
    ll ans = 0;
    ans = dp[H][W] >= 0 ? dp[H][W]:0;
    if(s[1][1] == 1 && s[H][W] == 1) ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            int min = Integer.MAX_VALUE;
            int ans = 0;
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                x -= m;
                ans++;
                if (m < min) {
                    min = m;
                }
            }
            ans += x / min;

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
  int n;cin>>n;
  int m=mod;
  ll sum=0;
  rep(i,n){
    int a,b;cin>>a>>b;
    if(a>b){
      chmin(m,b);
    }
    sum+=a;
  }
  if(m==mod)cout<<0<<endl;
  else cout<<sum-m<<endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(A: int, B: int):
    A -= 1
    B -= 1
    print(-(-A // 50 + -B // 50) * 2 + 2, 100)
    while A:
        print("#" * 100)
        n = min(A, 50)
        print(".#" * n + "##" * (50 - n))
        A -= n
    print("#" * 100)
    print("." * 100)
    while B:
        n = min(B, 50)
        print(".#" * n + ".." * (50 - n))
        B -= n
        print("." * 100)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define ifl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i++)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


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

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

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

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

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

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

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

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

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

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


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


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    string s;
	    cin>>s;
	    if(s[1]=='B')
	    cout<<"ARC"<<bn;
	    else
	    cout<<"ABC"<<bn;
	   
	   
	   
	    
	}
	
	return 0;
}


Measured memory_bytes: 3604
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sat = b[a[0]-1]
for i in range(1,len(a)):
    sat += b[a[i]-1]
    
    if a[i] - a[i-1] == 1:
        sat += c[a[i-1]-1]
        
print(sat)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int n;
    char in[200];
    while (~scanf("%s", in+1)) {
        n = strlen(in+1);
        int cnt=15-n;
        REP(i,1,n) if(in[i]=='o') cnt++;
        puts(cnt>=8 ? "YES" : "NO");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll X; cin >> X;
  ll ans = 0;
  ll cur = 100;
  while(cur < X){
    cur = cur * 1.01;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

string N;
int K;
long long dp[111][10][5][2];

int main(void) {
    cin >> N >> K;
    const int L = N.length();

    dp[0][0][0][0] = 1;
    REP(i, L) {
        const int d = N[i] - '0';
        REP(cur_d, 10) {
            REP(not_zero_cnt, 4) {
                REP(less_than, 2) {
                    REP(nxt_d, (less_than ? 10 : d + 1)) {
                        dp[i + 1][nxt_d][not_zero_cnt + (nxt_d != 0)][less_than || (nxt_d < d)] += dp[i][cur_d][not_zero_cnt][less_than];
                    }
                }
            }
        }
    }

    LL ans = 0;
    REP(i, 10) {
        REP(j, 2) ans += dp[L][i][K][j];
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<long long> B(N + 1, 0); //累積和テーブル
	int mod = 1000000007;
 
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		B[i + 1] = B[i] + A[i];
	}
 
	long ans = 0;
 
	//i について全探索する
	for (int i = 0; i < N; i++)
	{
		//累積和を使ってA[i+1] + ... + A[N] を求める
		long long sum = (B[N] - B[i + 1]) % mod;
 
		ans += A[i] * sum;
		ans %= mod;
	}
 
	cout << ans << endl;
}

Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

int main() {
  int n;
  std::cin >> n;
  std::vector< std::pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    int j;
    std::cin >> j;
    a[i] = std::make_pair(i, j);
  }
  std::sort(a.begin(), a.end(),
            [](const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) {
              return lhs.second > rhs.second;
            }
  );
  for (int i = 0; i < n; i++) {
    if (a[0].first == i) {
      std::cout << a[1].second << "\n";
    } else {
      std::cout << a[0].second << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
using namespace std;
typedef long long ll;

const int M=620,M2=310;
int h,w,a[M][M],b[M][M];

ll f(int B){
	ll res=0;
	for(int i=0;i<M;i++) for(int j=1;j<M;j++) b[i][j]=a[i][j]+b[i][j-1];
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) if(a[i][j]){
		for(int k=j+1;k<M;k++) if(a[i][k]){
			int d=k-j;
			if(i+d<M) res+=b[i+d][k-B]-b[i+d][j-1+B];
			if(d<=i) res+=b[i-d][k-B]-b[i-d][j-1+B];
		}
	}
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) b[M-j-1][i]=a[i][j];
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) a[i][j]=b[i][j],b[i][j]=0;
	return res;
}

int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		char c;
		cin>>c;
		if(c=='#') a[i+j+1][i-j+M2+1]++;
	}
	cout<<f(0)+f(1)<<endl;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int w, n;
	cin >> w;
	cin >> n;
	vector<P> Vec(n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d,%d", &Vec[i].first, &Vec[i].second);
	}
	vector<int> Answer(w + 1);
	int pos;
	for(int i = 1; i <= w; ++i)
	{
		pos = i;
		for(int j = 0; j < n; ++j)
		{
			if(pos == Vec[j].first)
			{
				pos = Vec[j].second;
			}
			else if(pos == Vec[j].second)
			{
				pos = Vec[j].first;
			}
		}
	Answer[pos] = i;
	}
	for(int i = 1; i <= w; ++i)
	{
		cout << Answer[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main() {
  int S;
  cin>>S;
  int h=0;
  int m=0;
  int second=0;
  h=S/3600;
  m=(S-3600*h)/60;
  second=S-3600*h-60*m;
  cout <<h<<":"<<m<<":"<<second<<endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N = 3;
	VL a(3);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	SORT(a);
	LL ans = LINF;
	do {
		LL ret = 0;
		FOR(i, 0, 2) {
			ret += abs(a[i] - a[i + 1]);
		}
		ans = min(ans, ret);
	} while (next_permutation(ALL(a)));
	
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));

		String input = sc.nextLine();
		char s[] = input.toCharArray();
		if(s[2] == s[3] && s[4] == s[5])
			System.out.println("Yes");
		else
			System.out.println("No");
		
		out.close();
	}

	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

}


Measured memory_bytes: 22612
using System;
using System.Linq;

namespace ABC048
{
    class C
    {
        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = input[0];
            long x = input[1];

            long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long count = 0;
            long xSum = 0;
            for (int i = 0; i < N - 1; i++)
            {
                if (x < a[i + 1] + a[i])
                {
                    xSum = (a[i + 1] + a[i]) - x;
                    count += xSum;

                    if (xSum <= a[i + 1])
                    {
                        a[i + 1] -= xSum;
                    }
                    else
                    {
                        xSum -= a[i + 1];
                        a[i + 1] = 0;
                        //a[i] = 
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 31452
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; itr++)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; i--)
#define reprev(itr, end) reprrev(i, 0, end)
#define all(container) container.begin(), container.end()
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807i64
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };
struct edge { ll to; ll cost; };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    for (T& x : vec) os << x << " ";
    return os;
}

// ***<ここから>****************************************************************

ll Pow(ll a, ll n) {
	ll x = 1;
	while (n > 0) {
		if (n & 1) x = x * a;
		a = a * a;
		n = n >> 1;
	}
	return x;
}

int main(void) {

    ll n, m, d;
    cin >> n >> m >> d;

    ll all_path = Pow(n, 2);
    ll point_path = (d == 0) ? n : 2 * d + 2 * (n - 2 * d);
    ll m1 = m - 1;

    double ans = point_path * m1 / double(all_path);
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
from fractions import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
a = 0
for i in range(N):
    a = gcd(a, A[i])
if K % a == 0 and K <= A[-1]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 16296
#include <bits/stdc++.h>
using namespace std;
# define ll  long long int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
	int n;
	cin >> n;
	vector<int> arr;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		arr.pb(x);
	}
	sort(arr.begin(), arr.end());
	int cnt = 0;
	for(int i = 2; i < n; i++){
		for(int j = i - 1; j >= 0; j--){
			for(int k = 0; k < j; k++){
				if(arr[j] + arr[k] > arr[i] && arr[j] != arr[k] && arr[j] != arr[i])
					cnt++;
			}
		}
	}
	cout << cnt;
}

int  main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("output.txt", "w", stdout);
    #endif
     IOS
     int t = 1;
     //cin >> t;
     while(t--){
     	solve();
     }
     return 0;
}

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

using namespace std;
#define forr(i, n) for(ll i = n-1; i >= 0; i--)
#define forn(i, n) for(ll i = 0; i < n; i++)
#define forab(i, a, n) for(ll i = a; i < n; i++)
#define forabr(i, a, b) for(ll i = a; i >= b; i--)
#define endl '\n'
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(7); cout.setf(ios::fixed);
#define fale_io ifstream fin("grants.in"); ofstream fout("grants.out");
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

typedef long long ll;
typedef string S;

const ll mod = 1e9 + 7;
const ll Inf = LONG_LONG_MAX;
const double long PI = 3.1415926535;

ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll max(ll a, ll b){if(a > b)return a;return b;}
ll gcd (ll a, ll b) {while (b) {a %= b;swap (a, b);}return a;}
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }

int x, y, a, b, c, n;
ll ans;

int main() {
    fast_io;
    cin >> x >> y >> a >> b >> c;
    vector<int> r(x+y+c), ra(a), rb(b);
    forn(i, a)cin >> ra[i];
    forn(i, b)cin >> rb[i];
    sort(rall(ra));
    sort(rall(rb));
    forn(i, x)r[i] = ra[i];
    forn(i, y)r[i+x] = rb[i];
    forn(i, c)cin >> r[i+x+y];
    sort(rall(r));
    forn(i, x+y)ans += r[i];
    cout << ans;
}


Measured memory_bytes: 2176
S = gets.to_i
MOD = 10**9+7

ar = [0,0,0,1]
sum = [0,0,0,1]
if S < 3
    puts 0
    exit
elsif S == 3
    puts 1
    exit
end

4.upto(S) do |i|
    ar[i] = (1 + sum[i-3]) % MOD
    sum[i] = (sum[i-1] + ar[i]) % MOD
end

puts ar[S]

Measured memory_bytes: 14356
def sei(a):
  v=[]
  for i in a.split():
    v+=[int(i)]
  return v
a=sei(input())
b=sei(input())
ans=0
for i in range(a[0]):
  xx=a[2]
  lis=sei(input())
  for s in range(len(lis)):
    xx+=b[s]*lis[s]
  if xx>0:
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    vector<int> a(3); rep(i,3) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[2]*10+a[1]+a[0] << endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int len = S.length();
    int ans = 0;

    for(int i = 0; i < (len+1)/2; ++i){
        if(S[i] != S[len-i-1]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
H, W, M = map(int,input().split())
Bomb = []
for _ in range(M):
    hi, wi = map(lambda x: int(x) - 1, input().split())
    Bomb.append((hi, wi))

counterH = [0] * H
counterW = [0] * W

for (hi, wi) in Bomb:
    counterH[hi] += 1
    counterW[wi] += 1

# 最大のところを選ぶ
max_h = max(counterH)
max_w = max(counterW)

count = 0
for (hi, wi) in Bomb:
    if counterH[hi] == max_h and counterW[wi] == max_w:
        count += 1

# 共通部分を確認 (-1)
ans = max_h + max_w
if count == counterH.count(max_h) * counterW.count(max_w):
    ans -= 1
print(ans)


Measured memory_bytes: 109404
package main

import "fmt"

func main() {
  var a string
  fmt.Scan(&a)
  halfLength := len(a) / 2
  length := len(a)
  count := 0
  for index := 0; index < halfLength; index++ {
	  first := a[index:index + 1]
	  last := a[length - index - 1:length - index]
	  if first != last {
		count += 1
	  }
  }
  fmt.Println(count)
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;

namespace ALDS1_8_A
{
    class Program
    {
        const int NIL = -1;
        static StringBuilder sbi;
        static StringBuilder sbp;
        class node
        {
            public int key; public int left; public int right;
            public node(int key)
            {
                this.key = key; left = NIL; right = NIL;
            }
        }
        static void Main(string[] args)
        {
            int m = int.Parse(Console.ReadLine());
            var T = new List<node>();
            int listnum = 0;
            for (int i = 0; i < m; i++)
            {
                var a = Console.ReadLine().Split(' ');
                if (a[0] == "insert")
                {
                    insert(T, int.Parse(a[1]), listnum++);
                }
                else
                {
                    sbi = new StringBuilder();
                    sbp = new StringBuilder();
                    inorder(T, 0);
                    Console.WriteLine(sbi);
                    preorder(T, 0);
                    Console.WriteLine(sbp);
                }
            }
           
        }
        static void insert(List<node> T, int z,int listnum)
        {
            int y = NIL;
            T.Add(new node(z));
            if (listnum == 0) return;
            int x = 0;
            while (x != NIL)
            {
                y = x;
                if (z < T[x].key) x = T[x].left;
                else x = T[x].right;
            }
            if (z < T[y].key) T[y].left = listnum;
            else T[y].right = listnum;

        }
        static void preorder(List<node> T, int i)
        {
            sbp.Append(" " + T[i].key);
            if (T[i].left != NIL) preorder(T, T[i].left);
            if (T[i].right != NIL) preorder(T, T[i].right);
        }
        static void inorder(List<node> T, int i)
        {
            if (T[i].left != NIL) inorder(T, T[i].left);
            sbi.Append(" " + T[i].key);
            if (T[i].right != NIL) inorder(T, T[i].right);
        }
    }
}

Measured memory_bytes: 68900
N=int(input())
T=[list(map(int,input().split())) for i in range(N)]
for i in range(N):
    t=T[i][0]
    j=T[i][1]+T[i][2]
    if t<j or (t+j)%2:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 27300
#include<stdio.h>

int main(void){
	int n,m,i,j=0;
	int a[100][100]={{0}};
	int b[100],c[100]={0};
	
	scanf("%d %d",&n,&m);
	for(j=0;j<n;j++){
		for(i=0;i<m;i++){
			if(i>0)scanf(" ");
			scanf("%d",&a[j][i]);
		}
	}
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	for(j=0;j<n;j++){
		for(i=0;i<m;i++){
			c[j]=c[j]+(a[j][i]*b[i]);
		}
	}
	for(i=0;i<n;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}


Measured memory_bytes: 2100
S = input()

fstrs = ['dreamer', 'eraser', 'dream', 'erase']

flag = True
while flag:
    for fstr in fstrs:
        result = S.rfind(fstr)
        if result >= 0 and result == len(S) - len(fstr):
            # print('found: {} in {} ({})'.format(fstr, S, result))
            S = S[0:result]
            flag = True
            break
        else:
            # print('not found: {} in {}'.format(fstr, S))
            flag = False
    if len(S) == 0:
        break

if len(S) > 0:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3188
#include<stdio.h>
int main(void){

	int i,max,a[100];

	scanf("%d",&max);

	for(i=0;i<max;i++)scanf("%d",&a[i]);

	for(i=max-1;i>0;i--)printf("%d ",a[i]);

	printf("%d\n",a[0]);

	return 0;

}

Measured memory_bytes: 596
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	ans := max(max(a*c, a*d), max(b*c, b*d))
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1772
import math
a=int(input())
ans=a
ct=0
while ct<=(math.sqrt(a)-1):
    ct+=1
    if a%ct==0:
        if ans>=((a/ct)+ct):
            ans=((a/ct)+ct)
if a==ans:
    ans+=1
if a==4:
    ans=4
print(int(ans-2)) 

Measured memory_bytes: 3064
#include <stdio.h>
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
void dfs(void);
void visit(int);

int G[N][N],d[N],f[N],n,color[N],time;
int main(){

  int i,j,y,b,k;

  for(i=1;i<=100;i++){
    for(j=1;j<=100;j++){
      G[i][j]=0;
    }
  }
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&y,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&b);
      G[y][b]=1;
    }
  }

  dfs();

  for(i=1;i<=n;i++)
    printf("%d %d %d\n",i,d[i],f[i]);

  return 0;
}

void dfs(){
  int i;
  for(i=1;i<=n;i++)
    color[i]=WHITE;
  time=0;

  for(i=1;i<=n;i++){
    if(color[i]==WHITE)
      visit(i);
  }
}

void visit(int u){
  int i;
  color[u]=GRAY;
  d[u]=++time;
  for(i=1;i<=n;i++){
    if(G[u][i]!=0){
    if(color[i]==WHITE)
      visit(i);
    }}
  color[u]=BLACK;
  f[u]=++time;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,a=0,M,j=0;
 cin >> N;
  M=N;
  for(int i=0;i<3;i++)
  {
    while(j<i){
     j++;
     M=M/10;
    }
   M=M%10;
  if(M==7){
    a=1;
    break;
  }
  M=N;
  j=0;
  }
  if(a==1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3624
import heapq

def makeSet(x):
    p[x] = x
    rank[x] = 0

def union(x, y):
    link(findSet(x), findSet(y))

def link(x, y):
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1

def findSet(x):
    if x != p[x]:
        p[x] = findSet(p[x])
    return p[x]



v,e = map(int, input().split())
edge = [[] for _ in range(v)]

p = [0]*v
rank = [0]*v
for x in range(v):
    makeSet(x)

S = []
ans = 0
for _ in range(e):
    s,t,w = map(int, input().split())
    heapq.heappush(S, [w, s, t])
    
while S:
    w,s,t = heapq.heappop(S)
    if findSet(s) != findSet(t):
        union(s,t)
        ans += w
print(ans)



Measured memory_bytes: 25780
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

struct data{
  int a;
  int b;
  data(int a, int b) : a(a), b(b){}
  data() : a(0), b(0){}
};

bool comp(data d1, data d2){
  if(d1.b == d2.b)
    return d1.a <= d2.a;
  else
    return d1.b <= d2.b;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<data> D(M);
  for(int i=0; i<M; i++)
    cin >> D[i].a >> D[i].b;
  sort(D.begin(), D.end(), comp);
  int ans = 0;
  int prev = -1;
  for(int i=0; i<M; i++){
    if(!(D[i].a <= prev)){
      ans++;
      prev = D[i].b - 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
package main

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

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (int, int) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines

	return scanInt(sc), scanInt(sc)
}

func resolve(n, m int) int {
	l := m / n
	for i := l; i <= i; i-- {
		if (m-n*i)%i == 0 {
			return i
		}
	}
	// no path
	return 0
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

int ah,as;
int bh,bs;

signed main()
{
	cin>>ah>>as>>bh>>bs;
	
	for (int i=1;i<=1000000;i++)
	{
		if (i%2==1)  bh-=as;
		else if (i%2==0)  ah-=bs;
		
		if (ah<=0)  return cout<<"No"<<endl,0;
		if (bh<=0) return cout<<"Yes"<<endl,0;
	}
	return 0;
}

Measured memory_bytes: 3636