akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
vll to[2505];
vll rto[2505];
bool from1[2505];
bool fromn[2505];
void dfs(ll v){
  if(from1[v]) return ;
  from1[v]=true;
  for(auto p:to[v]){
    dfs(p);
  }
}
void rdfs(ll v){
  if(fromn[v]) return ;
  fromn[v]=true;
  for(auto p:rto[v]){
    rdfs(p);
  }
}
int main(){
  ll n,m,p;
  cin>>n>>m>>p;
  vector<tuple<ll,ll,ll>> edges;
  rep(i,m){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    c-=p;
    c*=-1;
    edges.emplace_back(a,b,c);
    to[a].pb(b);
    rto[b].pb(a);
  }
  dfs(0);
  rdfs(n-1);
  bool ok[2505];
  rep(i,n) ok[i]=from1[i]&fromn[i];
  vll d(n,INF);
  d[0]=0;
  bool udt=true;
  ll cu=0;
  while(udt){
    udt=false;
    rep(i,m){
      ll a,b,c;
      tie(a,b,c)=edges[i];
      if(!ok[a]||!ok[b]) continue;
      if(d[a]+c<d[b]){
        d[b]=d[a]+c;
        udt=true;
      }
    }
    cu++;
    if(cu>n){
      COUT(-1);
      return 0;
    }
  }
  COUT(max(-d[n-1],0LL));
}
  


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = sc.nextInt();
		int x = -1;
		int y = -1;
		int z = -1;
		for(int i = 0; i <= n; i++){
			for(int j = n - i; j >= 0; j--){
				int tmp = sum -(i * 10000 + j * 5000);
				int tmpn = (n - i - j) * 1000;
				if(tmp == tmpn){
					x = i;
					y = j;
					z = n - i - j;
					j = -1;
					i = n;
				}
			}
		}
		System.out.println(x + " " + y + " " + z);
	}

}

Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.equals("Sunny"))System.out.println("Cloudy");
		else if(s.equals("Cloudy")) System.out.println("Rainy");
		else System.out.println("Sunny");

		sc.close();
	}

}

Measured memory_bytes: 22996
n, m = map(int, input().split())
x_list = tuple(map(int, input().split()))
y_list = tuple(map(int, input().split()))

mod = 10 ** 9 + 7

x_sum = 0
for i in range(1, n + 1):
    x_sum += ((i - 1) * x_list[i - 1] - (n - i) * x_list[i - 1]) % mod
y_sum = 0
for i in range(1, m + 1):
    y_sum += ((i - 1) * y_list[i - 1] - (m - i) * y_list[i - 1]) % mod

print(x_sum * y_sum % mod )


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d%d",&a[i],&b[i]);

	lint cnt=0;
	for(int i=n-1;i>=0;i--){
		cnt+=(b[i]-(a[i]+cnt)%b[i])%b[i];
	}
	printf("%lld\n",cnt);

	return 0;
}


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

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    int A,B; cin >> A >> B;
    cout << max(A+B,max(A-B,A*B)) << endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;

ull n,a,b,x[111111],ans;
int main()
{
	cin >> n >> a >> b >> x[0];
	for(int i=1;i<n;i++)
	{
		cin >> x[i];
		ull dis = a*(x[i]-x[i-1]);
		if(dis<b) ans += dis;
		else ans+=b;
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

typedef long long ll;

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

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

	string s;
	cin >> s;

	cout << s.substr(0, 3) << endl;
}


Measured memory_bytes: 3548
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int length=scan.nextInt();
        int[] a=new int[length];
        for(int i=0;i<length;i++){
            a[i]=scan.nextInt();
        }
        int flag=1;
        int count=0;
        while(flag==1){
            flag=0;
            for(int j=length-1;j>=1;j--){
                if(a[j]<a[j-1]){
                    int tmp=a[j];
                    a[j]=a[j-1];
                    a[j-1]=tmp;
                    flag=1;
                    count++;
                }
            }
        }
        for(int i=0;i<length;i++){
            if(i!=length-1) System.out.printf("%d ",a[i]);
            else System.out.printf("%d",a[i]);
        }
        System.out.println();
        System.out.println(count);
    }
}


Measured memory_bytes: 26636
#!/usr/bin/ruby
require 'mathn'
h={};2.step(36){|i|h[i]=i.prime_division}
while(l=gets.split)!=["0","0"]	
	n=l[0].to_i;m=l[1].to_i(n)
	if n==0 then break end
	p h[n].map{|a,b|
		z=m;r=0
		while z>0 do r+=(z=z.div a) end
		r.div b
	}.min
end

Measured memory_bytes: 3936
n=int(input())
da=list(map(int,input().split()))

def bina(x,ok,ng):
    global da
    while ng-ok!=1:
        mi=(ok+ng)//2
        if da[mi]<x:
            ok=0
            ok+=mi
        else:
            ng=0
            ng+=mi
    return ok


ans=0
da=sorted(da)
for i in range(1,n-1):
    for j in range(i):
        ans+=bina(da[i]+da[j],i,n)-i
print(ans)

Measured memory_bytes: 42588
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
using namespace std; vector<int> p(110000);
vector<int> q(50000);
int main()
{
    int n, r; cin >> n; int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    cin >> r;
    for (int i = 0; i < r; i++) {
        cin >> q[i];
    }
    int ri, le, mid, count;
    ri = n - 1; le = 0; mid = (ri + le) / 2;
    for (int i = 0; i < r; i++) {
        ri = n; le = 0; ;
        while (le < ri) {
            mid = (ri + le) / 2;
            if (p[mid] == q[i]) {
                sum += 1; break;
            }
            else if (p[mid] > q[i])
                ri = mid;
            else
                le = mid + 1;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3400
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i64 = read();
    let m: i64 = read();
    let ans = if n * 2 >= m {
        m / 2
    } else {
        n + (m - 2 * n) / 4
    };
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>

using namespace std;

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define INF 1000000000
#define mod 1000000007
#define MAX5 100001

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

int gcd(int a, int b){
	int old_a, old_b;
	while(a % b != 0){
		old_a = a;
		old_b = b;

		a = old_b;
		b = old_a % old_b;
	}

	return b;
}

int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	
	// auto l = [] () -> bool {
	// 	cout << "Hello, lamda function!" << endl;
	// 	return 2 > 1;
	// };
	// cout << l() << endl;

	string s;
	cin >> s;

	if(s[1] == 'R')
		cout << "ABC" << endl;
	else
		cout << "ARC" << endl;
	
	return 0;
}

/*
11 
4 4 
-2 -2 
-3 -4 
-1 3 
2 3 
-4 0 
1 1 
-1 -1 
3 -1 
-4 2 
-2 4
*/

















Measured memory_bytes: 3596
import java.util.Scanner;

/**
 * Main
 */
public class Main {

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[M];

        int rest = N;
        for(int i = 0; i < M; i++){
            A[i] = sc.nextInt();
            rest -= A[i];
        }

        if(rest < 0){
            System.out.println(-1);
        }else{
            System.out.println(rest);
        }
    }
}

Measured memory_bytes: 39372
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

const int INF=10000000;

int minPen=INF;
int leftCards;
int field[10][10];

vector<int> dy;
vector<int> dx;

void dfs(){
	if(minPen==0)
		return;
	if(leftCards==0){
		minPen=0;
		return;
	}
	int prv[10][10];
	memset(prv,0,sizeof(prv));
	int left=0;
	for(int i = 0; i < 5; i++){
		for(int j = 0; j < 4; j++){
			prv[i][j]=field[i][j];
			left+=field[i][j];
		}
	}
	bool f=false;
	bool rec=false;
	for(int i = 0; i < 5; i++){
		for(int j = 0; j < 4; j++){
			if(field[i][j]==0){
				f=true;
				break;
			}
			else{
				// SûüÌyAð·
				for(int k = 0; k < dy.size(); k++){
					int ny=i+dy[k];
					int nx=j+dx[k];
					if(ny>=0&&nx>=0&&nx<4&&ny<5){
						if(field[ny][nx]==field[i][j]){
							// æè¢ÄÄA
							rec=true;
							field[ny][nx]=0;
							field[i][j]=0;
							for(int l = 0; l < 5; l++){
								for(int m = 0; m < 4; m++){
									if(l*4+m<i*4+j)
										continue;
									if(l*4+m<ny*4+nx-1){
										int xx=m+1;
										int yy=l;
										if(xx>=4){
											xx=0;
											yy++;
										}
										field[l][m]=field[yy][xx];
									}
									else{
										int xx=m+2;
										int yy=l;
										if(xx==5){
											xx=1;
											yy++;
										}
										else if(xx==4){
											xx=0;
											yy++;
										}
										field[l][m]=field[yy][xx];
									}
								}
							}
							leftCards-=2;
							dfs();
							leftCards+=2;
							for(int l = 0; l < 5; l++){
								for(int m = 0; m < 4; m++){
									field[l][m]=prv[l][m];
								}
							}
						}
					}
				}
			}
		}
		// TõI¹
		if(f)
			break;
	}
	// êxàæè¯È©Á½ê
	if(!rec){
		minPen=min(minPen,leftCards);
	}
}

int main(){

	for(int i = -1; i <= 1; i++){
		for(int j = -1; j <= 1; j++){
			if(i==0&&j==0)
				continue;
			dx.push_back(j);
			dy.push_back(i);
		}
	}

	int n;
	cin>>n;
	for(int l = 0; l < n; l++){
		memset(field,0,sizeof(field));
		for(int i = 0; i < 5; i++){
			for(int j = 0; j < 4; j++){
				cin>>field[i][j];
			}
		}
		minPen=INF;
		leftCards=20;
		dfs();
		cout<<minPen<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
S=input()

W=""
ans=0
P=0
for i in range(len(S)):
    if P<=len(S)-1:
        if S[P]!=W:
            ans+=1
            W=S[P]
            P+=1
        else:
            if P+1<=len(S)-1:
                ans+=1
                W=S[P]+S[P+1]
                P+=2
    else:
        break
    #print(W)
print(ans)

Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) cout << c << endl;
  else if (a == c) cout << b << endl;
  else cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	string s; cin >> s;
	ll a, b;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			a = i; break;
		}
	}
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'Z') {
			b = i; break;
		}
	}

	cout << b - a + 1 << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
  { 
    int n,r,s,b;
    scanf("%d %d",&n,&r);
    if(n<10)
      { 
         s=100*(10-n);
         b=r+s;
         printf("%d",b);
      }
  else
    printf("%d",r);
  return 0;
  }
         
        


Measured memory_bytes: 128
from operator import itemgetter

while 1:
    n = int(input())
    if n == 0:
        break
    t_w = []
    for _ in range(n):
        m, a, b = map(int, input().split())
        t_w.append((a, m, 5))
        t_w.append((b, -m, 3))
        t_w.sort(key=itemgetter(0, 2))
        ans, cur = 'OK', 0
        for t, w, pri in t_w:
            cur += w
            # print('t', t, 'w', w, 'cur', cur)
            if cur > 150:
                ans = 'NG'
                break
    print(ans)



Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< ll , string > P;

int main(){
	int n;
	int max=0;
	cin>>n;

	map <string, int> s; 
	rep(i,n){
		string t;
		cin>>t;
		s[t]+=1;
		if(s[t]>max) max=s[t];
	}
	
	for(auto p : s){	
		if(p.second==max) cout<<p.first<<endl;
	}
	
}


Measured memory_bytes: 25216
import std.stdio, std.string, std.conv, std.math;

void main() {
	auto ip = readln.split.to!(int[]);
	if(0 <= (ip[1] - ip[2])){
		writeln("delicious");
	} else if(ip[0] + 1 > abs(ip[1] - ip[2])){
		writeln("safe");
	} else {
		writeln("dangerous");
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    ll i,j,k,l,r,x,y,N,M,D; string s;
    bool exit = false;
    cin >> N >> M >> D;
    cout<<fixed;
    if (D==0)
        cout<<setprecision(10)<<(N-D)*1.0*(M-1)/N/N<<endl;
    else
        cout<<setprecision(10)<<(N-D)*2.0*(M-1)/N/N<<endl;    
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int n;
vector<vector<pair<int, int>>> li;

bool judge(int bit) {
    for (int i = 0; i < n; i++) {
        if (!(bit & (1 << i))) continue;
        for (pair<int, int> xy : li[i]) {
            if (xy.second == 1 && !(bit & (1 << xy.first))) return false;
            if (xy.second == 0 && (bit & (1 << xy.first))) return false;
        }
    }
    return true;
}

int main() {
    cin >> n;
    li.resize(n);
    rep(i, n) {
        int a;
        cin >> a;
        li[i].resize(a);
        rep(j, a) {
            cin >> li[i][j].first >> li[i][j].second;
            li[i][j].first--;
        }
    }

    int maxCnt = 0;
    for (int bit = 0; bit < (1<<n); bit++) {
        if (judge(bit)) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (bit & (1 << i)) cnt++;
            }
            maxCnt = max(maxCnt, cnt);
        }
    }

    cout << maxCnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 250

int main(){
  int i,H;
  int heap[MAX];
  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&heap[i]);

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,heap[i]);
    if(i!=1) printf("parent key = %d, ",heap[i/2]);
    if(2*i<=H) printf("left key = %d, ",heap[2*i]);
    if(2*i+1<=H) printf("right key = %d, ",heap[2*i+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
n = int(input())
S = list(map(int,input().split()))
M = 10**9 + 1
def merge(A, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = A[left:left + n1]
    R = A[mid:mid + n2]
    L.append(M)
    R.append(M)
    i = 0
    j = 0
    for k in range(left,right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

count = 0
mergeSort(S,0,len(S))
print(*S)
print(count)

Measured memory_bytes: 63864
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N;
    cin >> N;
    
    string S1, S2;
    cin >> S1 >> S2;

    long long ans = 1;
    bool f = true;

    for (int i = 0; i < S1.length(); i++){
        if (f == true){
            if (S1[i] == S2[i]){
                if (i == 0){
                    ans = ans * 3;
                }else{
                    ans = ans * 2;
                }
            }else{
                f = false;
                if (i == 0){
                    ans = ans * 6;
                }else{
                    ans = ans * 2;
                }
                i++;
            }
        }else{
            if (S1[i] == S2[i]){
                f = true;
            }else{
                ans = ans * 3;
                i++;
            }
        }
        ans = ans % 1000000007;
    }
    

    cout << ans << endl;
    

    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define val p[i].y
using namespace std;

struct P{
	int x,y;
}st,en,p[201000],tmp;
int n=0,m,fl,c[201000],tot=0,pos;
double ans,pi=atan2(0,-1);

bool cmp(P p1,P p2){
	return p1.x<p2.x;
}

int main(){
	scanf("%d%d%d%d",&st.x,&st.y,&en.x,&en.y);
	if (st.x>en.x) swap(st,en);
	if (st.y>en.y) swap(st.y,en.y),fl=1;
	
	for (scanf("%d",&m);m--;){
		scanf("%d%d",&tmp.x,&tmp.y);
		if (tmp.x>=st.x&&tmp.x<=en.x&&tmp.y>=st.y&&tmp.y<=en.y)
			p[++n]=tmp;
	}
	if (fl) for (int i=1;i<=n;i++) p[i].y=(1e8)-p[i].y;
	sort(p+1,p+n+1,cmp);
	
	for (int i=1;i<=n;i++){
		if (val>c[tot]){
			c[++tot]=val;
		}else{
			pos=lower_bound(c,c+tot+1,val)-c;
			c[pos]=val;
		}
	}
	ans=((double)en.x-st.x+en.y-st.y)*100.0-tot*(20.0-5.0*pi);
	if (tot==en.x-st.x+1||tot==en.y-st.y+1) ans+=5.0*pi;
	printf("%.15lf",ans);
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(){
        int N;
        int a[120],counter[120]={0};
        cin >> N;
        for(int i=0 ; i<N ; i++ ){
                cin >> a[i];
                counter[a[i]]++;
        }
        int c=0;
        for(int i=100 ; i>0 ; i-- ){
                for(int j=0 ; j<counter[i] ; j++ ){
                        a[c]=i;
                        c++;
                }
        }
        int num1=0,num2=0;
        for(int i=0 ; i<N ; i++ ){
                if(i%2)
                        num1+=a[i];
                else
                        num2+=a[i];
        }
        cout << num2-num1 << endl;
        return 0;
}



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

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

    if ((a * b) % 2 != 0)
    {
        cout << 2 << endl;
    }
    else if (a == 1 || b == 1)
    {
        cout << 3 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
}


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

using namespace std;

int main() {
  int n, m, l;
  int64_t A[100][100] = {0};                                                                                                                                              
  int64_t B[100][100] = {0};                                                                                                                                              

  cin >> n >> m >> l;

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

  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < l; ++j)
      cin >> B[i][j];
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < l; ++j) {
      int64_t c = 0;
      for (int k = 0; k < m; ++k)
        c += A[i][k] * B[k][j];

      if (j > 0)
        printf(" ");
      printf("%lld", c);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 3368
//#pragma GCC optimize(2)
#include<set>
#include<map>
#include<stack>
#include<ctime>
#include<cstdio>    
#include<queue>    
#include<cmath>    
#include<vector>    
#include<cstring>   
#include<climits>    
#include<iostream>   
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
int read(){
    int f=1,x=0;char c=getchar();
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
    return f*x;
}
#define MAXN 300000
#define INF 0x3f3f3f3f
#define Mod (int)(1e9+7)
char S[MAXN+5];
int f[MAXN+5][3][3];
int Add(int x,int y){x+=y;return x>=Mod?x-Mod:x;}
int main(){
	scanf("%s",S+1);
	int n=strlen(S+1);
	f[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++){
				if(S[i+1]!='0'){//+1
					if(k)
						f[i+1][j][k-1]=Add(f[i+1][j][k-1],f[i][j][k]);
					else f[i+1][min(2,j+1)][k]=Add(f[i+1][min(2,j+1)][k],f[i][j][k]);
				}
				if(S[i+1]!='1'){//+0
					if(k==2)
						f[i+1][j][1]=Add(f[i+1][j][1],f[i][j][k]);
					else 
						f[i+1][j][k+1]=Add(f[i+1][j][k+1],f[i][j][k]);
				}
			}
	int ans=0;
	for(int j=0;j<3;j++)
		for(int k=0;k<=j;k++)
			ans=Add(ans,f[n][j][k]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int n, a[200000], b[200000];

	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a+n);

	for(int i=0; i<n; i++){
		if(b[i] != a[n-1]){
			cout << a[n-1] << endl;
		}else{
			cout << a[n-2] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<pair<i64, i64>> X;
  rep(i,0,N) {
    i64 a, b;
    cin >> a >> b;
    X.push_back({ a, b });
  }
  sort(all(X));
  vector<i64> A(N), B(N + 1);
  rep(i,0,N) {
    A[i] = X[i].first;
    B[i] ^= X[i].second;
    B[i + 1] ^= X[i].second;
  }
  vector<i64> L(M), R(M);
  rep(i,0,M) {
    i64 l, r;
    cin >> l >> r;
    L[i] = lower_bound(all(A), l) - begin(A);
    R[i] = lower_bound(all(A), r + 1) - begin(A);
  }
  vector<vector<pair<i64, i64>>> G(N + 1);
  rep(i,0,M) {
    G[L[i]].push_back({ R[i], i });
    G[R[i]].push_back({ L[i], i });
  }
  vector<bool> vis(N + 1, false);
  vector<i64> ans;
  
  auto dfs = [g=[&](auto f, i64 v) -> void {
    for(auto e: G[v]) {
      i64 to = e.first;
      i64 idx = e.second;
      if(vis[to]) continue;
      vis[to] = true;
      f(f, to);
      if(B[to]) {
        ans.push_back(idx);
        B[to] ^= 1;
        B[v] ^= 1;
      }
    }
  }](auto&&... args) {
    return g(g, std::forward<decltype(args)>(args)...);
  };

  rep(i,0,N + 1) {
    if(vis[i]) continue;
    vis[i] = true;
    dfs(i);
    if(B[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  sort(all(ans));
  cout << ans.size() << endl;
  rep(i,0,ans.size()) {
    cout << ans[i] + 1 << " \n"[i + 1 == ans.size()];
  }
}



Measured memory_bytes: 24688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,q;cin >> n >> q;
	string s;cin >> s;
	vector<int> sum(n+1);
	for(int i=1;i<n;++i){
		if(s.substr(i-1,2)=="AC") sum.at(i+1)++;
	}
	rep(i,n) sum.at(i+1)+=sum.at(i);
	rep(i,q){
		int l,r;cin >> l >> r;
		cout << sum.at(r)-sum.at(l) << endl;
	}
}

Measured memory_bytes: 1488
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

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

int main()
{
	#ifdef waltz
		freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	ll ans=min(min(ll(b)*c*(a&1),ll(a)*c*(b&1)),ll(a)*b*(c&1));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int zoro(int n){
  return 100*n+10*n+n;
}
int main(){
  int N;
  cin >> N;

  int k = 0;
  while(zoro(k)<N) k++;

  cout << zoro(k) <<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0; i<n; ++i)
using namespace std;
typedef string str;
template<class T> using vec = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T, class S> using umap = unordered_map<T, S>;
template<class T> using pqueue =  priority_queue<T>;
template<class T> using flist = forward_list<T>;
const int mbs = sizeof(bitset<1>)*8;
template<int N> using bits = bitset<mbs*((N+mbs-1)/mbs)>;

const int MOD = 1000000007; // 10^9 + 7
const double PI = 3.14159265358979323846;
const int N = 1000000; // 10^6

main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int a;
 	cin>>a;
  	cout<<a+a*a+a*a*a;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    using Point = pair<double, double>;
    function<vector<Point>(int, Point, Point)> f =
        [&f](int d, Point p1, Point p2) -> vector<Point> {
        if (d == 0) {
            return {};
        }

        auto s = Point((p1.first * 2.0 + p2.first) / 3.0,
                       (p1.second * 2.0 + p2.second) / 3.0);
        auto t = Point((p1.first + p2.first * 2.0) / 3.0,
                       (p1.second + p2.second * 2.0) / 3.0);
        auto u = Point((t.first - s.first) * cos(M_PI / 3.0) -
                           (t.second - s.second) * sin(M_PI / 3.0) + s.first,
                       (t.first - s.first) * sin(M_PI / 3.0) +
                           (t.second - s.second) * cos(M_PI / 3.0) + s.second);

        vector<Point> r;
        {
            auto rr = f(d - 1, p1, s);
            r.insert(end(r), begin(rr), end(rr));
        }
        r.push_back(s);
        {
            auto rr = f(d - 1, s, u);
            r.insert(end(r), begin(rr), end(rr));
        }
        r.push_back(u);
        {
            auto rr = f(d - 1, u, t);
            r.insert(end(r), begin(rr), end(rr));
        }
        r.push_back(t);
        {
            auto rr = f(d - 1, t, p2);
            r.insert(end(r), begin(rr), end(rr));
        }
        return r;
    };

    int n;
    cin >> n;

    auto r = f(n, Point(0.0, 0.0), Point(100.0, 0.0));
    r.insert(begin(r), Point(0.0, 0.0));
    r.emplace_back(100.0, 0.0);
    for (auto&& i : r) {
        cout << setprecision(8) << fixed << i.first << ' ' << i.second << endl;
    }
}

Measured memory_bytes: 3320
s = input()
l=len(s)
flag = 1
#print(s)
for i in range(l):
    if i%2==0:####i
        if s[i] =='L':
            flag =0
            #rint(i,s[i])

    elif i%2==1:
        if s[i] =="R" :
            flag = 0
            #rint(i,s[i])

if flag == 1:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long

void test_case()
{
    long n;
    cin>>n;
    long h[n];
    for(long i=0;i<n;i++)
        cin>>h[i];
    long dp[n]={};
    dp[1]=abs(h[1]-h[0]);
    for(long i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 1792
function main(arg) {
    var num1 = parseInt(arg.split(/\s+/g)[0]);
    var num2 = parseInt(arg.split(/\s+/g)[1]);
    var seki = num1*num2;
    if(num1<10&&num2<10&&num1>0&&num2>0){
    	console.log(seki);
    }else{
    	console.log(-1);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
    char S[20],W[100],s[10],X,Y;
   scanf("%d %d %d",&A,&B,&C);
   if((A+B==C)||(A+C==B)||(B+C==A)){
       printf("Yes");
   }else{
       printf("No");
   }
   
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int N=200005,md=1000000007;
vector<int> vct[N];
int n,i,j,k,a[N],p[N],d[N],fa[N],ans=1,cnt,size[N],huan[N],f[N],c[N],num[N],head[N],adj[N],nxt[N],pre[N],u[N];
bool oh[N],v[N];
int find(int x)
{
	return !fa[x]?x:fa[x]=find(fa[x]);
}
void dfs(int x)
{
	v[x]=true;
	p[++cnt]=x;
	if(!v[a[x]])
		dfs(a[x]);
	else
	{
		int i;
		for(i=cnt;i>=1;--i)
			if(p[i]==a[x])
				break;
		if(i>=1)
		{
			int fst=0,lst=0,st=i;
			while(i<=cnt)
			{
				if(d[p[i]]>1)
				{
					if(!fst)
						fst=i;
					pre[p[i]]=i-lst;
					lst=i;
				}
				oh[p[i]]=true;
				huan[find(x)]++;
				++i;
			}
			pre[p[fst]]=fst-st+1+cnt-lst;
		}
	}
}
int work(int x)
{
	int rtn=1;
	for(int y=head[x];y;y=nxt[y])
		if(!oh[adj[y]])
			rtn+=work(adj[y]);
	return rtn;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",a+i);
		adj[i]=i;
		nxt[i]=head[a[i]];
		head[a[i]]=i;
		++d[a[i]];
		if(find(i)!=find(a[i]))
			fa[find(i)]=find(a[i]);
	}
	for(i=1;i<=n;++i)
		vct[find(i)].push_back(i);
	for(i=1;i<=n;++i)
		if(d[i]>2)
		{
			printf("0");
			return 0;
		}
	for(i=1;i<=n;++i)
	{
		size[find(i)]++;
		if(!v[i])
		{
			cnt=0;
			dfs(i);
		}
	}
	for(i=1;i<=n;++i)
		if(!oh[i]&&d[i]>1)
		{
			printf("0");
			return 0;
		}
	for(i=1;i<=n;++i)
		if(d[i]>1)
			c[find(i)]++;
	for(i=1;i<=n;++i)
		if(d[i]>1)
			u[i]=work(i)-1;
	for(i=1;i<=n;++i)
		if(d[i]>1)
		{
			if(u[i]<pre[i])
				ans=ans*2%md;
			else if(u[i]>pre[i])
			{
				printf("0");
				return 0;
			}
		}
	for(i=1;i<=n;++i)
		if(find(i)==i)
		{
			if(c[i]==0)
				++num[size[i]];
		}
	for(i=1;i<=n;++i)
		if(num[i])
		{
			f[0]=1,f[1]=(i==1?1:i&1?2:1);
			for(j=2;j<=num[i];++j)
				f[j]=(1ll*f[j-1]*(i==1?1:i&1?2:1)%md+1ll*(j-1)*f[j-2]%md*i%md)%md;
			ans=1ll*ans*f[num[i]]%md;
		}
	printf("%d",ans);
	return 0;
}


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

const int MAX_V=2500;
const int INF=10000;
vector<int> dx={0,1,0,-1};
vector<int> dy={1,0,-1,0};

struct edge{
  int to;
  int cost;
};

typedef pair<int,int> P;

vector<edge> G[MAX_V];
int d[MAX_V];
int V;

void dijkstra(int s){

  priority_queue<P,vector<P>,greater<P>> que;
  fill(d,d+V,INF);
  d[s]=0;
  que.push(P(0,s));

  while(!que.empty()){
    P p=que.top();
    que.pop();
    int v=p.second;

    if(d[v]<p.first) continue;
    for(int i=0;i<G[v].size();++i){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }

}


int main(){

  int H,W;
  cin>>H>>W;
  V=H*W;

  int cnt=0;
  vector<vector<char>> color(H,vector<char>(W));
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      cin>>color[i][j];
      if(color[i][j]=='.') ++cnt;
    }
  }

  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      for(int k=0;k<4;++k){
      int ni=i+dx[k],nj=j+dy[k];
      if(ni<0 || ni>=H || nj<0 || nj>=W) continue;
      if(color[i][j]=='.' && color[ni][nj]=='.'){
        G[j+i*W].push_back((edge){nj+ni*W,1});
        G[nj+ni*W].push_back((edge){j+i*W,1});
      }
      }
    }
  }

  dijkstra(0);

  if(d[V-1]==INF) cout<<-1<<endl;
  else cout<<cnt-d[V-1]-1<<endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  long long cnt = 0;
  rep(i,n) {
    string s;
    cin >> s;
    sort(all(s));
    mp[s]++;
  }

  

  for (auto tmp : mp){
    long long x = tmp.second;
    cnt += x * (x - 1) / 2;
  }

  cout << cnt << endl;
  // for( auto i = mp.begin(); i != mp.end() ; ++i ) {
  //     std::cout << i->first << " " << i->second << "\n";
  // }

  // for( auto i = mp.begin(); i != mp.end() ; ++i ) {
  //     std::cout << i->first << " " << i->second << "\n";
  // }
  return 0;
}

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

int main(){
   long int a, b, c, d, max;
   long int ac, ad, bc, bd;
    cin >> a >> b >> c >> d;

    ac = a * c;
    ad = a * d;
    bc = b * c;
    bd = b * d;

    max = ac;

    if (ad >= max){
        max = ad;
    }
    if (bc >= max){
        max = bc;
    }
    if (bd >= max){
        max = bd;
    }
    cout << max;
}


Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <type_traits>
#include <limits>
#include <random>
#include <iomanip>

using namespace std;

using ll = long long;

typedef pair<int, int> P;

#define rep(i,N) for(long long i = 0;i < (long long)N; ++i)

static int mod = 1000000007;
static int large_int = 1000000000;
static ll large_ll = 1000000000000000000;

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

int H, W;

int w, h;

int main() {
	cin >> H >> W;
	cin >> h >> w;

	cout << H * W - h * W - w * H + h * w << endl;
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env pypy3

#import numpy as np
#import scipy, scipy.special

# Python 3 modules: https://docs.python.org/3/library/

import sys
import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
# Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
# Before Python 3.5
from fractions import gcd

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

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

sys.setrecursionlimit(30000)

N = int(input())
#U = []
#V = []
#W = []
# Vertex i connects to vertex M[i,x][0] and the weight is M[i,x][1]
M = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = input_ints()
    u -= 1
    v -= 1
    w &= 1
    M[u].append((v, w))
    M[v].append((u, w))

WHITE = 0
BLACK = 1
UNK = -1
C = [UNK for i in range(N)]

def dfs(n):
    for t in M[n]:
        if C[t[0]] == UNK:
            C[t[0]] = int(not C[n]) if t[1] else C[n]
            dfs(t[0])

C[0] = WHITE
dfs(0)
for c in C:
    print(c)


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    double r;
    cin >> r;
    cout << setprecision(20) << M_PI * 2 * r << "\n";
    
    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL calc(LL h){
	if(h==1)return 1;
	return calc(h/2)*2+1;
} 
int main(){
	LL h;scanf("%lld",&h);
	printf("%lld",calc(h));
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,K,l[51],res=0;
  cin >> N >> K;
  REP(i,N)cin >> l[i];
  sort(l,l+N);
  REP(i,K){
    res += l[N-1-i];
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(){
	int i,s1,s2,t1,t2;
	cin>>s1>>s2>>t1>>t2;
	for(i=1;i<=t2-s2;i++)  cout<<"U";
	for(i=1;i<=t1-s1;i++) cout<<"R";
	for(i=1;i<=t2-s2;i++)  cout<<"D";
	for(i=1;i<=t1-s1;i++) cout<<"L";
	cout<<"L";
	for(i=1;i<=t2-s2+1;i++)  cout<<"U";
	for(i=1;i<=t1-s1+1;i++) cout<<"R";
	cout<<"D";
	cout<<"R";
	for(i=1;i<=t2-s2+1;i++)  cout<<"D";
	for(i=1;i<=t1-s1+1;i++) cout<<"L";
	cout<<"U";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){int h,w;cin>>h>>w;string a[h];
           for(int i=0;i<h;i++)cin>>a[i];
           for(int i=0;i<h;i++){for(int j=0;j<w;j++){
if(a[i].at(j)=='.'){int x=0;
if(i&&a[i-1].at(j)=='#')x++;
if(h-1-i&&a[i+1].at(j)=='#')x++;
if(j&&a[i].at(j-1)=='#')x++;
if(j&&i&&a[i-1].at(j-1)=='#')x++;
if(j&&h-1-i&&a[i+1].at(j-1)=='#')x++;
if(w-1-j&&a[i].at(j+1)=='#')x++;
if(w-1-j&&i&&a[i-1].at(j+1)=='#')x++;
if(w-1-j&&h-1-i&&a[i+1].at(j+1)=='#')x++;
a[i].at(j)=48+x;}}cout<<a[i]<<endl;}}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
      int n ;
      scanf("%d", &n) ;
      int D1[n], D2[n] ;
      for(int i=0; i<n; i++)
            scanf("%d%d", &D1[i], &D2[i]) ;
      int ans = 0 ;
      for(int i=0; i<n-2; i++) 
      {
              if(D1[i]==D2[i]&&D1[i+1]==D2[i+1]\
              &&D1[i+2]==D2[i+2])
              {
                    ans = 1 ;
                    break ;
              }
      }
      if(ans == 0)
            printf("No") ;
      else 
            printf("Yes") ;
      return 0 ;
}


Measured memory_bytes: 1728
import sys
input = sys.stdin.readline
import bisect

a, b, q = map(int, input().split())
S = [int(input()) for _ in range(a)]
T = [int(input()) for _ in range(b)]

for _ in range(q):
  x = int(input())
  s_bi = bisect.bisect_right(S, x)
  t_bi = bisect.bisect_right(T, x)
  s_left = S[s_bi-1] if s_bi>0 else -float("inf")
  s_right = S[s_bi] if s_bi<a else float("inf")
  t_left = T[t_bi-1] if t_bi>0 else -float("inf")
  t_right = T[t_bi] if t_bi<b else float("inf")
  c = x - min(s_left, t_left)
  d = max(s_right, t_right) - x
  e = t_right - s_left + min(x-s_left, t_right-x)
  f = s_right - t_left + min(x-t_left, s_right-x)
  ans = min(c, d, e, f)
  print(ans)

Measured memory_bytes: 12196
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m) = get!(u32, u32);
    println!("{}", (1900 * m + 100 * (n-m)) * 2_u32.pow(m));
}

Measured memory_bytes: 2136
#include<iostream>
#include<vector> 
int main(){
    int A, B, K;
    std::cin >> A >> B >> K;

    int len;
    if(A >= B)len = B;
    else len = A;

    std::vector<int> ans;
    for(int i = 1; i <= len; i++){
        if((A%i + B%i) == 0){
            ans.push_back(i);
        }
    }

    std::cout << ans[ans.size() - K];

    return 0;
}

Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_A
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    private final static String SPACE = " ";
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int[] an = null;
            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2?????????????????????
                if (stdReader.getLineNumber() == 2) {
                    String[] inputs = sStr.split(" ");
                    int i = 0;
                    an = new int[n];
                    for (String input : inputs) {
                        an[i] = Integer.parseInt(input);
                        i++;
                    }
                    break;
                }
            }

            for (int i=n-1; i>=0; i--) {
                System.out.print(an[i]);
                if (i != 0) System.out.print(SPACE);
            }
            System.out.println();

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
}

Measured memory_bytes: 24332