akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,m,c=0;
cin >> n >> m;
int a[m],b[m]; 
for(int i=0;i<m;i++){
   cin >> a[i]  >> b[i];
}

for(int i=0;i<n;i++){
   for(int j=0;j<m;j++){
      if(a[j]==i+1){
         c++;
      }    
      if(b[j]==i+1){
         c++;
      }
   }
   cout << c << endl;
   c = 0;
}
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa=[]
bb=[0]*n
bb[0]=a[0]+b[0]
for i in range(n):
	aa.append(sum(a[:i+1]))
for i in range(1,n):
	bb[i]=max(bb[i-1],aa[i])+b[i]
print(bb[n-1])



Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
const int INF=100100100;
using namespace std;
int n,m;
int K[32][32];

int main(){

  scanf("%d%d", &n,&m);
  

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      K[i][j]=INF;
    }
  }
  int a,b,c,d;
  for(int i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    K[a][b]=c;
    K[b][a]=d;
  }
  int start,goal,inp,val;
  scanf("%d,%d,%d,%d",&start,&goal,&inp,&val);
  for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	if(K[i][j] > K[i][k]+K[k][j]){
	  K[i][j]=K[i][k]+K[k][j];
	}
      }
    }
  }
  int ans=inp-val-K[start][goal]-K[goal][start];
  printf("%d\n",ans);
}

  
  
    

  

Measured memory_bytes: 1192
#include <iostream>
using namespace std;
int main(){
  int n,m,p;

  while( cin>>n>>m>>p && n|m|p ){
    m--;
    int x,y=0, z=0;
    for( int i=0;i<n;i++ ){
      cin >> x;
      y+=x;
      if( i==m ) z=x;
    }
    if( z==0 )
      x=0;
    else{
      y = y*(100-p);// / 100;
      x = y/z;// * 100;
    }
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int si1[200005],vis1[200005],vis2[200005],si2[200005];
vector<int> fir[200005],sec[200005],v[200005];
void bfs1(int m,int col)
    {
    int total = 0;
    queue<int> q;
    q.push(m);
    vis1[m] = col;
    int i,l,x,cur;
    while(!q.empty())
        {
        total++;
        cur = q.front();
        q.pop();
        l = v[cur].size();
        for(i=0;i<l;i++)
            {
            x = v[cur][i];
            if(vis1[x]==0)
                {
                vis1[x] = col;
                q.push(x);
            }
        }
    }
    si1[col] = total;
    }
void bfs2(int m,int col)
    {
    int total = 0;
    queue<int> q;
    q.push(m);
    vis2[m] = col;
    int i,l,x,cur;
    while(!q.empty())
        {
        total++;
        cur = q.front();
        q.pop();
        l = v[cur].size();
        for(i=0;i<l;i++)
            {
            x = v[cur][i];
            if(vis2[x]==0)
                {
                vis2[x] = col;
                q.push(x);
            }
        }
    }
    si2[col] = total;
    }
int main(){
    int n,m,l;
    scanf("%d%d%d",&n,&m,&l);
    int i;
    int x,y;
    for(i=1;i<=m;i++)
        {
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for(i=1;i<=n;i++)
        if(vis1[i]==0)
        bfs1(i,i);
        for(i=1;i<=n;i++)
        {
        v[i].clear();
    }
    for(i=1;i<=l;i++)
        {
         scanf("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
     for(i=1;i<=n;i++)
        if(vis2[i]==0)
        bfs2(i,i);
     map< pair<int,int> ,int> cnt;
    for(i=1;i<=n;i++)
        cnt[make_pair(vis1[i],vis2[i])] ++;
    for(i=1;i<=n;i++)
        printf("%d ",cnt[make_pair(vis1[i],vis2[i])]);
    return 0;
}


Measured memory_bytes: 33196
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,a=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<SZ(s);i++)
    {
        a^=s[i];
    }
    if(a==0)
    {
        cout<<"Yes"<<NL;
        return 0;
    }
    cout<<"No"<<NL;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>

typedef long long ll;

#define debug(x) cout << #x << "=" << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << " "
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)

using namespace std;

struct UnionFind{
    vector<int> parent;

    UnionFind(int N): parent(N){
        loop(i, N) parent[i] = i;
    }

    int root(int x){
        if(parent[x] == x)return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        parent[rx]= ry;
        return;
    }

    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m,k,a,b,c,d;
    cin >>n >>m >>k;

    vector<int> blockFriend(n,0),groupMember(n,0), FriendNum(n,0);
    UnionFind tree(n);
    loop(i, m){
        cin >>a >>b;
        tree.unite(a-1,b-1);
        FriendNum[a-1] ++;
        FriendNum[b-1] ++;
    }
    
    loop(i,n){
        int ri = tree.root(i);
        groupMember[ri] ++;
    }

    loop(i, k){
        cin >>c >>d;
        if(tree.same(c-1,d-1)){
            blockFriend[c-1]++; 
            blockFriend[d-1]++;
        }
    }

    loop(i,n){
        int ri = tree.root(i);
        cout << groupMember[ri] - blockFriend[i] - FriendNum[i] - 1 << endl;
    }

    return 0;

}

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    string a, b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		String S = sc.next();
		char[] charList = S.toCharArray();
		int n = S.length();

        boolean condition = false;

        String left = S.substring(0, (n-1)/2-1);
        String right = S.substring((n-1)/2+1, n-1);
        if(left.equals(right))
        {
        	if(charList[0] == charList[((n-1)/2)-1])
        	{
        		if(charList[((n+3)/2)-1] == charList[n-1])
        		{
        			condition = true;
        		}
        	}
        }

        if(condition)
        	System.out.println("Yes");
        else
        	System.out.println("No");
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
    ll n; cin >> n;
    map<ll,ll> a;
    rep(i,n){
        ll b; cin >> b;
        a[b]++;
    }
    ll sum = 0;
    for(auto it : a){
        if(it.first > it.second)sum += it.second;
        if(it.first < it.second)sum += it.second - it.first;
    }
    print(sum);
}


Measured memory_bytes: 6272
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

type sword struct {
	a, b int
}

type swordList []sword

func (a swordList) Len() int           { return len(a) }
func (a swordList) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a swordList) Less(i, j int) bool { return a[i].b > a[j].b }

func main() {
	sc.Split(bufio.ScanWords)

	N, H := scanInt(), scanInt()
	L := make(swordList, N)
	for i := 0; i < N; i++ {
		L[i].a, L[i].b = scanInt(), scanInt()
	}
	sort.Sort(L)

	amax := 0
	for _, l := range L {
		if l.a >= amax {
			amax = l.a
		}
	}

	ans := 0
	for i := 0; i < N; i++ {
		if L[i].b >= amax {
			H -= L[i].b
			ans++
		}
		if H <= 0 {
			break
		}
	}
	if H > 0 {
		p, r := H/amax, H%amax
		ans += p
		if r > 0 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5852
n =gets.to_i
as=gets.strip.split(/ /).collect{|x| x.to_i}
ts=[0]
n.times{|i|
    ts<<(ts[-1]+as[i])
}
ts.sort!
ts<<'end'
def c(n)
    if n>1
        n*(n-1)/2
    else
        0
    end
end
t=ts[0]
i=0
sum=0
(1...(n+2)).each{|j|
if ts[j]!=t
    sum+=c(j-i)
    i=j
    t=ts[j]
end
}
puts sum


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

int main() {
	short n,count=0;
	cin>>n;
	char str[n];
	for(short i=0;i<n;i++)
	cin>>str[i];

	if(n%2!=0)
	cout<<"No";
	
	else{
	for(short i=0;i<n/2;i++){
	if(str[i]!=str[n/2+i]){
	count++;
	break;
		}
	}
	if(count==0)
	cout<<"Yes";
	else
	cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= print . length . filter ( == 8 ) . map num_divisor . ( flip takeWhile ) [ 1, 3 .. ] . ( >= )

num_divisor a = length $ filter ( == 0 ) $ map ( a `mod` ) [ 1 .. 200 ]

Measured memory_bytes: 508
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

long double dist(long double a, long double b, long double c, long double d) {
	long double l = sqrtl((a - c) * (a - c) + (b - d) * (b - d));
	return l;
}

int main() {
	int n;
	long double s = 0;
	cin >> n;
	vector<vector<long double>> twn(n, vector<long double>(2));
	rep(i, n) rep(j, 2) cin >> twn.at(i).at(j);
	rep(i, n) {
		rep(j, n) {
			long double t = dist(twn.at(i).at(0), twn.at(i).at(1), twn.at(j).at(0), twn.at(j).at(1));
			s += t;
		}
	}
	cout << fixed << setprecision(7) << s/ n;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG aising/draft.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;
int h, w;
char m[405][405];
char m2[1000000];

ll parent[1000000];
ll nb[1000000];
ll nw[1000000];
ll visited[1000000];

void init(int n){// 初期化．全てのnodeで親を自分自身に，tree_rankを0にする．nもらわなくてもv.size()でいける
    rep(i, n){
        parent[i] = i;
        if(m2[i] == '#'){
            nb[i] = 1;
            nw[i] = 0;
        }else{
            nb[i] = 0;
            nw[i] = 1;
        }
    }
}

int root(int x){// node xのrootを返す．parent[x] = root(parent[x])で親をrootにつなぎ替える
    return x == parent[x] ? x : parent[x] = root(parent[x]);
}

bool same(int x, int y){// 同じ木に属するかどうか判定する
    return root(x) == root(y);
}

void unite(int x, int y){// xの属する木とyの属する木を連結する．rankができるだけ低くなるように処理を行う
    x = root(x);
    y = root(y);

    if(x != y){
        parent[y] = x;
        nb[x] += nb[y];
        nw[x] += nw[y];
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする

    cin >> h >> w;
    int cnt = 0;
    rep(i, h){
        rep(j, w){
            cin >> m[i][j];
            m2[cnt] = m[i][j];
            cnt++;
        }
    }

    init(h * w);

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(i != h - 1){
                if(m[i][j] != m[i+1][j]){
                    unite(i * w + j, (i+1) * w + j);
                }
            }
            if(j != w - 1){
                if(m[i][j] != m[i][j+1]){
                    unite(i * w + j, i * w + j + 1);
                }
            }
        }
    }

    rep(i, h * w){
        visited[i] = 0;
    }

    ll ans = 0;
    rep(i, h * w){
        int k = root(i);
        if(visited[k] == 0){
            ans += nb[k] * nw[k];
            visited[k] = 1;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 14080
(defparameter tbl (make-hash-table :test 'equal))

(defmacro maxs (a b)
  `(setq ,a (max ,a ,b)))

(defun main ()
  (let* ((n (read)) (mx 0) (sol '()))
    (loop for i from 1 to n do
         (maxs mx (incf (gethash (read-line) tbl 0))))
    (loop for k being the hash-key using (hash-value v) of tbl do
         (when (= v mx) (push k sol)))
    (loop for s in (sort sol 'string-lessp) do
         (write-line s))))

(main)


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

ll cnt[100005];

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

    ll n;
    cin >> n;

    vector<ll> a;
    for(int i=0; i<n; i++){
        ll t;
        cin >> t;
        a.pb(t);
        cnt[t]++;
        cnt[t+1]++;
        cnt[t+2]++;
    }

    ll ma = -1;
    for(int i=0; i<100003; i++){
        ma = max(ma, cnt[i]);
    }

    cout << ma << endl;


    
    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

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

int main() {
    double a,b,c;
    int ret = 0;
    while(cin >> a >> b >> c) {
        if(a == 0 && b == 0 && c == 0) break;
        rep(i,1,1000) {
            rep(j,1,1000) {
                int x,y;
                x = (double)i * (100.0+a) / 100.0;
                y = (double)j * (100.0+a) / 100.0;

                if(x+y != c) continue;
                x = (double)i * (100.0+b) / 100.0;
                y = (double)j * (100.0+b) / 100.0;
                ret = max(ret, x+y);
            }
        }
        cout << ret << endl;
        ret = 0;
    }
}

Measured memory_bytes: 1220
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,B;

signed main(){
	cin>>A>>B;
	cout<<ceil2(A,B)<<endl;
	return 0;
}


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

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

int main(){
    ll A, B, G;
    cin >> A >> B;
    G = gcd(A, B);

    map<ll, int> M;
    for(ll i = 2; i * i <= G; i++){
        while(G % i == 0){
            M[i]++;
            G /= i;
        }
    }
    if(G > 1) M[G]++;
    cout << M.size() + 1 << endl;
}

Measured memory_bytes: 384
import math
n,a,b=map(int, input().split())
cnt = 0
mode = 0
if a == 0:
    cnt = 0
elif a+b == n:
    cnt = a
else:
    roop = math.floor(n / (a+b))
    anc_a = a*roop
    n_b = n-(roop*(a+b))
    while True:
        if n_b >= a and mode == 0:
            n_b = n_b - a
            cnt += a
            mode = 1
        elif mode == 1:
            n_b = n_b-b
            mode = 0
        elif n_b < a and mode == 0:
            cnt += n_b
            n_b = n_b -a
        if n_b <= 0:
            break
    cnt += anc_a 
print(cnt)
    
    


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

int main()
{
	int N;
	cin >> N;

	vector<int> a(N), b(N), c(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<vector<int>> dp(N, vector<int>(3));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			if (j == 0) dp[i][j] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
			if (j == 1) dp[i][j] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
			if (j == 2) dp[i][j] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
		}
	}

	cout << max(dp[N-1][0],max(dp[N - 1][1], dp[N - 1][2])) << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,M; cin>>N>>M;
	vector<ll> x(13,0);
	x[4]=x[6]=x[9]=x[11]=1;
	x[2]=2;
	if(x[N]==x[M]) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;
    string tmp;
    map<string, int>mp;
    long long cnt=0;
    for(int i=0;i<n;i++){cin>>tmp;sort(tmp.begin(),tmp.end());cnt+=mp[tmp];mp[tmp]++;}
    cout<<cnt<<endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

struct store {
	long A;
	int B;
};

bool cmp(const store &left, const store &right) {
	if (left.A < right.A) {
		return true;
	}
	else {
		return false;
	}
}

int main(void)
{
	int N, M;
	int i, tmp;
	int need;
	long ans = 0;

	cin >> N >> M;
	store *input = new store[N + 1];

	for (i = 0; i < N; i++) {
		cin >> input[i].A >> input[i].B;
	}
	input[N].A = 1000000001;
	input[N].B = 1;

	sort(input, input+N, cmp);
	
	need = M;
	for (i = 0; i < N; i++) {
		if (input[i].B >= need) {
			ans = ans + input[i].A * need;
			cout << ans << endl;
			return 0;
		}
		else {
			need = need - input[i].B;
			ans = ans + input[i].A*input[i].B;
		}
	}


	delete[] input;

	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
int main(){
  int a,b;scanf("%d%d",&a,&b);
  if(a<=0&&0<=b){
    printf("Zero\n");
  }else if(a>0)printf("Positive\n");
  else{
    if((b-a+1)&1)printf("Negative\n");
    else printf("Positive\n");
  }
  return 0;
}


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

int N;
vector<int> x, rx;
int L;

vector<vector<int>> dp, rdp;

void init() {
  rx = x;
  reverse(rx.begin(), rx.end());

  int latte = rx[0];
  for (int i = 0; i < N; ++i) {
    rx[i] = latte - rx[i];
  }

  dp.assign(17, vector<int>(N));
  rdp.assign(17, vector<int>(N));

  for (int l = 0, r = 0; l < N; ++l) {
    while (r < N && x[r] - x[l] <= L) r++;
    dp[0][l] = r - 1;
  }

  for (int l = 0, r = 0; l < N; ++l) {
    while (r < N && rx[r] - rx[l] <= L) r++;
    rdp[0][l] = r - 1;
  }

  for (int i = 0; i + 1 < 17; ++i) {
    for (int j = 0; j < N; ++j) {
      dp[i + 1][j] = dp[i][dp[i][j]];
      rdp[i + 1][j] = rdp[i][rdp[i][j]];
    }
  }
}

int ans(int a, int b) {
  if (a < b) {
    a--, b--;
    int res = 0;
    while (a < b) {
      for (int i = 16; i >= 0; --i) {
        if (dp[i][a] < b || !i) {
          a = dp[i][a];
          res += (1 << i);
          break;
        }
      }
    }

    return res;
  } else {
    a = N - a;
    b = N - b;

    int res = 0;
    while (a < b) {
      for (int i = 16; i >= 0; --i) {
        if (rdp[i][a] < b || !i) {
          a = rdp[i][a];
          res += (1 << i);
          break;
        }
      }
    }

    return res;
  }
}

int main() {
  cin >> N;

  x.resize(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }

  cin >> L;
  init();

  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    cout << ans(a, b) << endl;
  }
}


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

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> a(100001);
  vector<pair<int,int>> b(100001);
  for(int i=0;i<=100000;i++){
    a[i].second=i;
    b[i].second=i;
  }
  
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    if(i%2) a[x].first++;
    else b[x].first++;
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  
  if(a[0].second!=b[0].second) cout << n-a[0].first-b[0].first << endl;
  else cout << n-a[0].first-max(a[1].first,b[1].first) << endl;
} 

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

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

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

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    ll ans = 2*MOD;
    ll tmp = 0;
    rep(i, n-1){
        tmp += a[i];
        ans = min(ans, abs(2*tmp - sum));
        //cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}


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

long long gcd(long long a, long long b)
{
    long long M = std::max(a, b);
    long long m = std::min(a, b);
    if (M % m == 0)
        return m;
    return gcd(m, M % m);
}

int main()
{
    bool sieve[1000002];
    long long a, b;
    std::cin >> a >> b;

    long long g = gcd(a, b);
    long long p = 2;
    bool end = false;
    long long ans = 1;
    while (p < 1000001 && !end && g != 1) {

        if (g % p == 0)
            ans++;
        while (g % p == 0) {
            g /= p;
        }
        for (int i = p * 2; i < 1000002; i += p) {
            sieve[i] = true;
        }
        for (int i = p + 1; i < 1000002; i += 1) {
            if (!sieve[i]) {
                p = i;
                break;
            }
            if (i == 1000001)
                end = true;
        }
    }
    if (g != 1)
        ans++;
    std::cout << ans << "\n";
    return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const ll MOD=1e9+7;
const int MAX=1e7+100;

int main() {
  vector<string> tmp(3);
  REP(i,3) cin>>tmp[i];
  sort(ALL(tmp), greater<string>());
  string f = tmp[0]+tmp[1];
  OUT(stoi(f)+stoi(tmp[2]));

  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val s = readLine()!!
    val n = s.length
    var ans = true

    val s2 = s.substring(0, (n-1)/2)
    val s3 = s.substring((n+3)/2-1, n)

    ans = ans && chk(s)
    ans = ans && chk(s2)
    ans = ans && chk(s3)

    if (ans) println("Yes")
    else println("No")
}

fun chk(s: String):Boolean {
    val n = s.length
    val arr = s.toCharArray()
    var ret = true
    repeat(n/2) {
        if (arr[it] != arr[n-it-1]) ret = false
    }
    return ret
}


Measured memory_bytes: 33992
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
using namespace std;

int main() {
	uint64_t h, w;
	cin >> h >> w;

	uint64_t ans = 0;

	uint64_t h_e, h_o, w_e, w_o;
	if (h % 2 == 0) {
		h_e = h / 2;
		h_o = h / 2;
		if (w % 2 == 0) {
			w_e = w / 2;
			w_o = w / 2;
		}
		else if (w % 2 == 1) {
			w_o = w / 2 + 1;
			w_e = w / 2;
		}
	}
	else if (h % 2 == 1) {
		h_e = h / 2;
		h_o = h / 2 + 1;
		if (w % 2 == 0) {
			w_e = w / 2;
			w_o = w / 2;
		}
		else if (w % 2 == 1) {
			w_o = w / 2 + 1;
			w_e = w / 2;
		}
	}
	ans = h_e * w_e + h_o * w_o;
	if (w == 1 || h == 1) {
		ans = 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 100010;
int root[MX], pos[MX];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m; cin >> n >> m;
	vector<vi> v(n);
	rep(i, n){
		root[i] = i;
		v[i].pb(i);
	}
	
	rep(i, m){
		int a, b, c; cin >> a >> b >> c; a--; b--;
		if(root[a] == root[b]){
			if(pos[b] - pos[a] != c){
				cout << "No" << endl;
				return 0;
			}
			continue;
		}
		if(v[root[a]].size() < v[root[b]].size()){
			swap(a, b);
			c *= -1;
		}
		int ofs = pos[a] - pos[b] + c;
		vi &vv = v[root[b]];
		for(int i : vv){
			v[root[a]].pb(i);
			pos[i] += ofs;
			root[i] = root[a];
		}
		vv.clear();
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 10236
n = int(input())
a_list = list(map(int, input().split()))

count_list = []
for a in a_list:
    count = 0
    q,mod = divmod(a,2)
    while True:
        if mod != 0:
            break
        else:
            q,mod = divmod(q,2)
            count += 1
    count_list.append(count)
print(min(count_list))

Measured memory_bytes: 3060
import numpy as np
from numba import jit

n, k = map(int, input().split())

tmp=[]
for i in range(n+1):
    tmp.append(i)
ary = np.array(tmp)
#print(ary)

@jit
def lr(l,r): # 等差数列の'l'から'r'の和_mean*number
    return (l+r)*(r-l+1)//2

ans = 0
for j in range(k,n+2):
    l = lr(0, j-1)
    r = lr(n+1-j, n)
    ans += r-l+1
    ans %= 10**9+7
    
print(ans)


Measured memory_bytes: 116860
def solve():
    from heapq import heapify, heappush, heappop

    N = int(input())
    A = list(map(int, input().split()))

    before = A[:N]
    after = [-n for n in A[N * 2:]]
    bes = sum(before)
    afs = sum(after)
    
    heapify(before)
    heapify(after)
    
    result = [0] * (N + 1)
    result[0] = bes
    result[-1] = afs
    
    for i in range(N, N * 2):
        a = A[i]
        heappush(before, a)
        k = heappop(before)
        bes += a - k
        result[i-N+1] += bes
    
    for i in range(N * 2 - 1, N - 1, -1):
        # print(i, i - N)
        a = -A[i]
        heappush(after, a)
        k = heappop(after)
        afs += a - k
        result[i - N] += afs

    return max(result)

print(solve())


Measured memory_bytes: 121488
while True:
    
    H,W=map(int,input().split())
    
    if H==0 and W==0:
        break
    
    for i in range(H):
        for j in range(W):
            
            if i==0 or j==0 or i==H-1 or j==W-1:
                print('#',end='')
                
            else :
                print('.',end='')
        print()
    
    print()


Measured memory_bytes: 7000
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<map>
#include<cctype>
#include<sstream>
using namespace std;
#define N 1000000000
int main()
{
	int a,b;
	while (cin>>a>>b)
	{
		long long int ans;
		long long int road;
		road = a + b - 1;
		ans = a * b - road;
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
# coding:utf-8
import collections

n = int(input())
a = list(map(int, input().split()))
q = int(input())
sum_a = sum(a)
count = collections.Counter(a)


for i in range(q):
    b, c = map(int, input().split())
    diff = (c - b) * count[b]
    sum_a += diff
    count[c] += count[b]
    count[b] = 0

    print(sum_a)


Measured memory_bytes: 24184
/*I know about "bits/stdc++.h" 
But I am not using it for some technical issue*/

#include "iostream"
#include "algorithm"
#include "iomanip"
#include "vector"
#include "set"
#include "sstream"
#include "fstream"
#include "cstring"
#include "cmath"
#include "utility"
#include "map"
#include "bitset"
#include "cassert"
#include "deque"

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define mod (int)1e9 + 7
#define For(i,a,n) for(i=a;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x,i,n; cin>>x>>n; set<int> ar;
	For(i,0,n){
		int r; cin>>r;
		ar.insert(r);
	}
	For(i,0,101){
	 	if(!ar.count(x-i)){
	 		cout<<x-i; return 0;
	 	}
	 	if(!ar.count(x+i)){
	 		cout<<x+i; return 0;
	 	}
	}
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
// priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
priority_queue<ll> PQ;

int main(){
  ll n;
  int i,j;
  ll a[200006];

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

  sort(a,a + n);
  reverse(a,a + n);
  ll ans = a[0];
  ll t;
  j = 1;
  for(i = 2;i < n;i++){
    t = a[j++];
    ans += t;
    if(i < n - 1){
      i++;
      ans += t;
    }
  }

  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll K, A, B;
    cin >> K >> A >> B;
    if (B % K == 0 || A % K == 0)
    {
        cout << "OK" << endl;
        return 0;
    }
    if (B - A >= K - 1)
    {
        cout << "OK" << endl;
        return 0;
    }
    if (B % K < A % K)
    {
        cout << "OK" << endl;
        return 0;
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int n,m,ans=300;
int a[305][305],c[305];
bool s[305];
int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
            a[i][j]--;
        }
    }
    for(int i=0;i<m;i++)s[i]=true;
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++)c[j]=0;
        for(int j=0;j<n;j++){
            for(int k=0;k<m;k++){
                if(s[a[j][k]]){
                    c[a[j][k]]++;
                    break;
                }
            }
        }
        int d=0,e=0;
        for(int j=0;j<m;j++){
            if(d<c[j]){
                d=c[j];
                e=j;
            }
        }
        s[e]=false;
        ans=min(ans,d);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

ll n,pos;
char s[20][20];

ll f(){
	ll len=strlen(s[pos]);
	char c=s[pos][len-1];
	if('0'<=c&&c<='9')return c-'0';
	ll ans=(c=='+'?0:1);
	while(strlen(s[pos+1])>len){
		pos++;
		ll temp=f();
		ans=(c=='+'?ans+temp:ans*temp);
	}
	return ans;
}

int main(){
	while(scanf("%lld",&n),n){
		rep(i,0,n)scanf(" %s",s[i]);
		s[n][0]=0;
		pos=0;
		printf("%lld\n",f());
	}
}


Measured memory_bytes: 2040
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x_min = 0;
		int x_max = sc.nextInt();
		int y_min = 0;
		int y_max = sc.nextInt();
		int n = sc.nextInt();
		int x, y, a;
		for(int i = 0; i < n; i++) {
			x = sc.nextInt();
			y = sc.nextInt();
			a = sc.nextInt();
			if(a == 1 && x > x_min)
				x_min = x;
			else if(a == 2 && x < x_max)
				x_max = x;
			else if(a == 3 && y > y_min)
				y_min = y;
			else if(a == 4 && y < y_max)
				y_max = y;
		}
		int result = (x_max - x_min)*(y_max - y_min);
		if(x_min > x_max)
			result = 0;
		else if(y_min > y_max)
			result = 0;
		System.out.println(String.valueOf(result));
	}
}

Measured memory_bytes: 10324
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      	int total = sc.nextInt();
      	int once = sc.nextInt();
      	int time = sc.nextInt();
      	int count = 0;
      
		while(total > 0) {
        	total -= once;
      		count++;    	
        }
      	System.out.println(count * time);
    
    
    }
}

Measured memory_bytes: 35636
from typing import List, Tuple


def actual(N: int, D: List[Tuple[int, int]]) -> str:
    rep_digit_rolls: List[bool] = [d1 == d2 for d1, d2 in D]

    three_straights: List[bool] = [all(rep_digit_rolls[i:i + 3]) for i in range(len(rep_digit_rolls) - 2)]

    if any(three_straights):
        return 'Yes'
    else:
        return 'No'

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

print(actual(N, D))

Measured memory_bytes: 10312
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define mxn 1007
#define mxv 100007
#define INF 1<<30
lld dp[mxn][mxv];
lld val[mxn];
lld wt[mxn];
int main()
{
	lld n,w;
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		lld vi,wi;
		cin>>wi>>vi;
		val[i] = vi;
		wt[i] = wi;
	}
	for(int j=1;j<mxv;j++)
	{
		dp[0][j] = (val[0]>=j)?wt[0]:INF;
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<mxv;j++)
		{
			dp[i][j] = dp[i-1][j];
			if(j-val[i] >= 0)
			{
				dp[i][j] = min(dp[i][j],dp[i-1][j-val[i]]+wt[i]);
			}
		}
	}
	int ans = 0;
	for(int j=1;j<mxv;j++)
	{
		if(dp[n-1][j]<=w)
		{
			ans = j;
		}
	}
	cout<<ans<<"\n";
	return 0;
}
		

Measured memory_bytes: 80128
n = int(input())
class Node(object):
    def __init__(self, p, l, r):
        self.p = p
        self.l = l
        self.r = r

nodes = [Node(None, None, None) for i in range(n)]

for i in range(n):
    id, left, right = map(int, input().split())
    nodes[id].l = left
    nodes[id].r = right
    if left != -1:
        nodes[left].p = i
    if right != -1:
        nodes[right].p = i

def pre(node,path):
    path.append(node)
    if nodes[node].l != -1:
        pre(nodes[node].l,path)
    if nodes[node].r != -1:
        pre(nodes[node].r,path)

def ino(node,path):
    if nodes[node].l != -1:
        ino(nodes[node].l,path)
    path.append(node)
    if nodes[node].r != -1:
        ino(nodes[node].r,path)

def post(node,path):
    if nodes[node].l != -1:
        post(nodes[node].l,path)
    if nodes[node].r != -1:
        post(nodes[node].r,path)
    path.append(node)

for ind, n in enumerate(nodes):
    if n.p == None:
        root = ind
        break
print('Preorder')
l = []
pre(root, l)
print(' ' +  ' '.join(map(str, l)))
print('Inorder')
l = []
ino(root, l)
print(' ' +  ' '.join(map(str, l)))
print('Postorder')
l = []
post(root,l)
print(' ' + ' '.join(map(str, l)))

Measured memory_bytes: 7840
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		Long[] pa = new Long[a];
		Long[] pb = new Long[b];
		Long[] pc = new Long[c];
		for (int i = 0; i < a; i++) {
			pa[i] = sc.nextLong();
		}
		for (int i = 0; i < b; i++) {
			pb[i] = sc.nextLong();
		}
		for (int i = 0; i < c; i++) {
			pc[i] = sc.nextLong();
		}

		Arrays.sort(pa, (v, w) -> Long.compare(w, v));
		Arrays.sort(pb, (v, w) -> Long.compare(w, v));
		Arrays.sort(pc, (v, w) -> Long.compare(w, v));
		PriorityQueue<Long> pq = new PriorityQueue<>();
		long answer = 0;
		for (int i = 0; i < x; i++) {
			pq.offer(pa[i]);
			answer += pa[i];
		}
		for (int i = 0; i < y; i++) {
			pq.offer(pb[i]);
			answer += pb[i];
		}

		int ci = 0;
		while (ci < pc.length) {
			long z = pq.peek();
			if (z > pc[ci]) break;
			pq.poll();
			answer += pc[ci] - z;
			pq.offer(pc[ci++]);
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 105080
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> a(n+1,0);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)a[i]+=a[i-1];
    vector<int> v;
    for(int i=0;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            v.push_back(a[j]-a[i]);
        }
    }
    int res=0;
    for(int bit=60;bit>=0;bit--){
        int cnt=0;
        int now=(1ll<<bit);
        for(auto it:v){
            if(it&now)cnt++;
        }
        if(cnt>=k){
            //cout<<bit<<endl;
            res+=now;
            vector<int> vv;
            for(auto it:v){
                if(it&now)vv.push_back(it);
            }
            v=vv;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string s,t;
  cin >> s >> t;
  int count = 0;
  rep(i,3){
    if(s.at(i) == t.at(i)){
      count++;
    }
  }
  cout << count << endl;
}

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

int n;
char s[100003];

bool check(bool first, bool second){
    bool is_sp[100001] = {0, first, second};
    if(first){
        if(s[1] == 'o'){
            is_sp[0] = second;
        }else{
            is_sp[0] = !second;
        }
    }else{
        if(s[1] == 'o'){
            is_sp[0] = !second;
        }else{
            is_sp[0] = second;
        }
    }
    
    int i;
    for(i = 2; i < n; i++){
        if(is_sp[i]){
            if(s[i] == 'o'){
                is_sp[i + 1] = is_sp[i - 1];
            }else{
                is_sp[i + 1] = !is_sp[i - 1];
            }
        }else{
            if(s[i] == 'o'){
                is_sp[i + 1] = !is_sp[i - 1];
            }else{
                is_sp[i + 1] = is_sp[i - 1];
            }
        }
    }
    
    if(is_sp[0] != is_sp[n]){
        return false;
    }
    
    if(is_sp[n]){
        if(!((s[n] == 'o' && is_sp[1] == is_sp[n - 1]) || (s[n] == 'x' && is_sp[1] != is_sp[n - 1]))){
            return false;
        }
    }else{
        if(!((s[n] == 'o' && is_sp[1] != is_sp[n - 1]) || (s[n] == 'x' && is_sp[1] == is_sp[n - 1]))){
            return false;
        }
    }
    
    for(i = 1; i <= n; i++){
        if(is_sp[i]){
            cout << "S";
        }else{
            cout << "W";
        }
    }
    cout << endl;
    return true;
}

int main(void){
    cin >> n;
    cin >> &s[1];
    
    if(check(true, true)){
        return 0;
    }else if(check(true, false)){
        return 0;
    }else if(check(false, true)){
        return 0;
    }else if(check(false, false)){
        return 0;
    }
    
    cout << -1 << endl;
    
    return 0;
}


Measured memory_bytes: 512
/* A - Plural Form */

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

int main(){
  string S;
  cin >> S;
  int len = S.size();
  if(S.at(len - 1) == 's'){
    cout << S << "es" << endl;
  }else{
    cout << S << "s" << endl;
  }
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize "03"
#pragma GCC target("sse4")
 
#define ll long long int
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FRE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define f(i,n) for(ll i=0;i<n;i++)
#define fa(i,a,n) for(ll i=a;a<n?i<n:i>=n;a<n?i+=1:i-=1)
#define loop(i,a, n) for(ll i = a; i <= n; i++)
#define loopb(i,a, n) for(ll i = a; i >= n; i--)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define setmem(x, k) memset(x, k, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define MOD 1000000007
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int>	vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<vector<ll>> matrix;
const ll N = 1e5+5;
// ll a[N], b[N], dp[N], level[N], vis[N], in[N], out[N];
vl g[N];
ll n, m;

ll dp[N];

ll dfs(ll u){
	if(dp[u] != -1){
		return dp[u];
	}
	ll mx = 0;
	for(ll v: g[u]){
		mx = max(mx, 1 + dfs(v));
	}
	return dp[u] = mx;
}
 
void solve() {
	ll t, k, x, y, u, v, p, q;
	cin >> n >> m;
	f(i, m) cin >> u >> v, g[u].pb(v);
	setmem(dp, -1);
	ll mx = 0;
	loop(i, 1, n){
		mx = max(mx, dfs(i));
	}
	cout << mx << endl;
}
 
int32_t main() {
	IOS
	ll T;
	// cin >> T;
	// while (T--)
	solve();
	cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'; 
	return 0;
}

Measured memory_bytes: 8064