akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
//rep(i, v.size()) v[i]=i;
//#define int long long
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>

using namespace std;

signed main(){
  int A, B;
  cin >> A >> B;

  if(A == 1 && B == 2)cout << 3 << endl;
  if(A == 1 && B == 3)cout << 2 << endl;
  if(A == 2 && B == 3)cout << 1 << endl;
  if(A == 2 && B == 1)cout << 3 << endl;
  if(A == 3 && B == 1)cout << 2 << endl;
  if(A == 3 && B == 2)cout << 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define pli pair<LL, int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

void gg() {
	puts("-1");
	exit(0);
}

int n, siz[MAXN];
pli p[MAXN];
vector<int> e[MAXN];
LL sum[MAXN];

void DFS1(int u) {
	for (auto v : e[u]) {
		DFS1(v);
		sum[u] += sum[v] + siz[v];
	}
}

void DFS2(int u) {
	for (auto v : e[u]) {
		sum[v] = sum[u] + n - siz[v] * 2;
		DFS2(v);
	}
}

void init() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(p[i].fi);
		p[i].se = i;
	}
	sort(p + 1, p + n + 1);
}

void solve() {
	for (int i = n; i > 1; --i) {
		int u = p[i].se;
		siz[u] += 1;
		LL fd = p[i].fi - (n - siz[u] * 2);
		int j = lower_bound(p + 1, p + n + 1, MP(fd, 0)) - p;
		if (j >= i || p[j].fi != fd) gg();
		int fa = p[j].se;
		siz[fa] += siz[u];
		e[fa].push_back(u);
	}
	siz[p[1].se] += 1;
	DFS1(p[1].se);
	DFS2(p[1].se);
	for (int i = 1; i <= n; ++i) {
		if (sum[p[i].se] != p[i].fi) gg();
	}
	for (int u = 1; u <= n; ++u) {
		for (auto v : e[u]) {
			printf("%d %d\n", u, v);
		}
	}
}

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



Measured memory_bytes: 11904
#include<stdio.h>

int main(void){
  
  int x = 0, y = 0, z = 0;
  scanf("%d%d", &x, &y);
  
  while(1){

    if(x % y == 0){
      break;
    }

    if(x >= y){
      z = x % y;
      x = y;
      y = z;
      continue;
    }

    if(x < y){
      z = x;
      x = y;
      y = z;
      continue;
    }
  }
  printf("%d\n", y);
  return 0;
}



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

using namespace std;

int dp[201][201];


void build() {
	for (int i=1; i<=200; i++) 
		for (int j=1; j<=i; j++)
				dp[i][j] = __gcd(i,j);
}


int main() {
	
	int k;
	cin >> k;
	long ans = 0;
	  memset(dp, 0, sizeof(dp));
  build(); 
	for (int i=1; i<=k; i++)
		for (int j=1; j<=k; j++)
			for (int h=1; h<=k; h++) {
				int a = i;
				int b = j;
				int c = h;

				int x = dp[max(a,b)][min(a,b)]; 
				int y = dp[max(x,c)][min(x,c)]; 

				ans = ans + y;	
			}
	cout << ans << endl; 
}


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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



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

    string ACGT = "ACGT";

    int m = 0;
    int cn = 0;
    REP(i,s.length()){
        bool is = false;
        REP(j,ACGT.length()){
            if(s[i] == ACGT[j]){
                is = true;
                break;
            }
        }
        if(is){
            cn++;
            m = max(cn,m);
        }else{
            cn = 0;
        }
    }
    
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

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

        for(int i=X; i<(X*2); i++){
            if(IsPrime(X)){
                ans=X;
                break;
            }
            for(int j=2; j<=X; j++){
                if(i%j==0){
                    break;
                }
                if(j==X){
                    ans=i;
                    break;
                }
            }
            if(ans!=0){
                break;
            }
        }

        System.out.println(ans);
    }

    static boolean IsPrime(int n) {
        if (n < 2) return false;
        else if (n == 2) return true;
        else if (n%2 == 0) return false;
        double sqrtNum = Math.sqrt(n);
        for (int i=3; i<=sqrtNum; i+=2) {
            if (n%i == 0) {return false;}
        }
        return true;
    }
}


Measured memory_bytes: 23764
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

#define int ll

//get vector of prime numbers which is lower than or equal n
vector<int> get_primes(int n)
{
    vector<bool> is_prime(n + 1, true);
    vector<int> res;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i])
        {
            res.push_back(i);
            for (int j = 2 * i; j < is_prime.size(); j = j + i)
            {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

vector<pair<int, int>> factorize(int n)
{
    vector<pair<int, int>> res;
    for (int i = 2; i * i <= n; i++)
    {
        int tmp = 0;
        while (n % i == 0)
        {
            tmp++;
            n /= i;
        }
        res.push_back(make_pair(i, tmp));
    }
    if (n != 1)
    {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int mpow(int x, int n)
{
    int res = 1;
    while (n != 0)
    {
        if (n & 1)
            res = res * x % INF;
        x = x * x % INF;
        n = n >> 1;
    }
    return res;
}

//mod frac
vector<int> mfrac;
void set_mfrac(int n)
{
    if (mfrac.size() == 0)
    {
        mfrac.push_back(1);
    }
    for (int i = mfrac.size(); i <= n; i++)
    {
        mfrac.push_back((i * mfrac[i - 1]) % INF);
    }
}

//get nCm mod INF
int mcomb(int n, int m)
{
    if (mfrac.size() <= n)
    {
        set_mfrac(n);
    }
    int res = mfrac[n];
    res = res * mpow(mfrac[m], INF - 2) % INF;
    res = res * mpow(mfrac[n - m], INF - 2) % INF;
    return res;
}

vector<int> get_gcd(int n)
{
    vector<int> res;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (i * i == n)
            {
                res.push_back(i);
            }
            else
            {
                res.push_back(i);
                res.push_back(n / i);
            }
        }
    }
    return res;
}

signed main()
{
    int ans = 1;
    int N, M;

    cin >> N >> M;
    auto gcd = get_gcd(M);
    sort(gcd.begin(), gcd.end());
    for (int i = 0; gcd[i] * N <= M && i < gcd.size(); i++)
    {
        ans = max(ans, gcd[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 (b<a) { a=b; return 1; } return 0; }

int N,ans=0,temp;

int main(){
    cin>>N;
    int A[N];
    rep(i,N)cin>>A[i];
    rep(i,N){
        for(int j=N-1;j>0;j--){
            if(A[j]<A[j-1]){
                temp=A[j];
                A[j]=A[j-1];
                A[j-1]=temp;
                ans++;
            }
        }
    }
    rep(i,N){
        if(i>0)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    out(ans);
}



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

const int INF = 100000000;

int dp[500005][2][2];

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = '0' + s + '0' + '0';
    n += 3;
    for(int i = 0; i < n; i++) dp[i][0][0] = dp[i][0][1] = dp[i][1][0] = dp[i][1][1] = -INF;
    dp[0][0][0] = 0;
    for(int i = 1; i < n; i++){
        if(s[i] == '0'){
            dp[i][0][0] = max(dp[i - 1][0][0], dp[i - 1][0][1]);
            if(s[i - 1] == '1' && s[i + 1] == '1'){
                dp[i][1][0] = dp[i - 1][1][0] + 1;
                dp[i][1][1] = dp[i - 1][0][1] + 1;
            }
        }
        else{
            dp[i][0][0] = dp[i - 1][1][1];
            if(s[i - 1] == '0') dp[i][0][0] = max(dp[i][0][0], dp[i - 1][1][0]);
            dp[i][0][1] = max(dp[i - 1][0][0], dp[i - 1][0][1]);
            if(s[i - 1] == '1') dp[i][1][0] = max(dp[i - 1][0][1], dp[i - 1][1][0]) + 1;
            if(s[i + 1] == '1') dp[i][1][1] = dp[i - 1][1][1] + 1;
        }
    }
    cout << dp[n - 1][0][0] << endl;
}


Measured memory_bytes: 11656
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

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

		for (int i=0; i<N; i++){
			H[i] = sc.nextInt();
		}

		for (int i=1; i<N; i++){
			if (i == 1){
				H[0]--;
			} else {
				if (H[i-1] -1 >= H[i-2]){
					H[i-1]--;
				}
			}
		}
		int[] H1 = H.clone();
		Arrays.sort(H);
		if (Arrays.equals(H, H1)){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, m;
    cin >> n >> m;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a.push_back(INF);
    sort(all(a));
    Int ng = 0;
    Int ok = 2e5 + 1;
    while (abs(ok - ng) > 1) {
        Int mid = (ok + ng) / 2;
        Int cnt = 0;
        for (Int i = 0; i < n; i++) {
            cnt += n - (lower_bound(all(a), mid - a[i]) - a.begin());
        }
        if (cnt <= m) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    // dump(ok);
    // cout << m << " " << tmp << endl;
    Int cnt = 0;
    for (Int i = 0; i < n; i++) {
        cnt += n - (lower_bound(all(a), ok - a[i]) - a.begin());
    }
    vector<Int> b(n + 1, 0);
    for (Int i = 0; i < n; i++) {
        b[i + 1] = b[i] + a[n - i - 1];
    }
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        Int index = lower_bound(all(a), ok - a[i]) - a.begin();
        res += b[n - index] + (n - index) * a[i];
    }
    if (cnt == m) {
        dump(res);
    } else {
        dump(res + ng * (m - cnt));
    }
    return 0;
}

Measured memory_bytes: 1804
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

const li mod = 1e9 + 7;

int main() {
    li n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(a + b - n, 0LL) << endl;
    return 0;
}


Measured memory_bytes: 764
#include<stdio.h>

int main(void) {

    int W,H,x,y,r,flg=0;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

    if ((x-r)>=0 && (x+r)<=W) flg++;
    if ((y-r)>=0 && (y+r)<=H) flg++;

    if (flg==2) {
        printf("Yes\n");
    } else printf("No\n");

    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

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

    s.erase(s.size()-1);
    
    if(s.size()%2 != 0){
        s.erase(s.size()-1);
    }

    while(true){
    //偶数なら半分に切って、その2つの文字列が一致していたら表示してbreak
    //不一致だった場合、最後の文字を消去する。
        half = s.size()/2;
        string ch1 = s.substr(0, half);
        string ch2 = s.substr(half, half);
        if(ch1 == ch2){
            break;
        }
        s.erase(s.size()-2);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Submitted With (^^) by -> Hossam ^_^
 _____________________
|     ___     ___     |
|    (^_^)   (^_^)    |
|   /( | )\_/( | )\   |
|_____|_|_____|_|_____|
*/

#include <bits/stdc++.h>

using namespace std;

inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define X first
#define Y second
#define ll long long
#define inf (0x7fffffffffffffff)
#define all(x) x.begin(), x.end()

const int mod = (int)1e9 + 7;
const int MX = (int)2e5 + 1;

int main()
{
    prep();

    int n;
    cin >> n;

    ll c;
    cin >> c;

    vector<pair<ll, ll>> v(n + 1);
    vector<ll> fwacc(n + 1), bcacc(n + 1);

    v[0] = make_pair(0, 0);

    //input
    for(int i = 1; i <= n; ++i){
        cin >> v[i].X >> v[i].Y;
    }

    //patial_forward
    for(int i = 1; i <= n; ++i){
        fwacc[i] = v[i].Y + fwacc[i - 1];
    }

    //partial_backward
    bcacc[n] = v[n].Y;
    for(int i = n - 1; i > 0; --i){
        bcacc[i] = bcacc[i + 1] + v[i].Y;
    }

    ll res = 0;

    vector<int> bst_idx(n + 1);
    vector<int> bst_idx2(n + 1);
    int idx = 0;
    ll bst = 0;

    //only forward
    for(int i = 1; i <= n; ++i){
        bst = fwacc[i] - v[i].X;
        if(bst > res){
            res = bst;
            idx = i;
        }
        bst_idx[i] = idx;
    }

    // v.push_back({c, 0});

    bst = 0;
    idx = n;
    // backward only
    for(int i = n; i > 0; --i){
        ll cur = bcacc[i] - (c - v[i].X);
        if(cur > bst){
            bst = cur;
            idx = i;
        }
        bst_idx2[i] = idx;
    }
    bst_idx2[0] = idx;

    res = max(res, bst);

    // combined
    for(int bc_idx = n; bc_idx > 1; --bc_idx){        
        int fw_idx = bst_idx[bc_idx - 1];
        ll dist_bc = c - v[bc_idx].X;
        ll dist_fw = v[fw_idx].X;
        res = max(res, bcacc[bc_idx] + fwacc[fw_idx] - (2 * min(dist_fw, dist_bc) + max(dist_fw, dist_bc)));
    }

    for(int fw_idx = 1; fw_idx < n; ++fw_idx){
        int bc_idx = bst_idx2[fw_idx + 1];
        ll dist_fw = v[fw_idx].X;
        ll dist_bc = c - v[bc_idx].X;
        res = max(res, bcacc[bc_idx] + fwacc[fw_idx] - (2 * min(dist_fw, dist_bc) + max(dist_fw, dist_bc)));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4224
#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()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int n, p;
    cin >> n >> p;
    
    bool even = true;
    rep(i, n){
        int a;
        cin >> a;
        if(a % 2 == 1){
            even = false;
        }
    }

    if(even){
        if(p == 0){
            ll ans = pow(2, n);
            cout << ans << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        ll ans = pow(2, n-1);
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 256
H, W, h, w = map(int, input().split())

if H % h == 0 and W % w == 0:
    print("No")
    quit()

print("Yes")

def solve(H, W, h, w):
    S = [0] * (W + 1)
    S[W % w] = 1 + W // w
    for i in range(w, W + 1):
        S[i] = S[i - w] - 1
    return [[S[i + 1] - S[i] for i in range(W)]] * H

if W % w != 0:
    A = solve(H, W, h, w)
else:
    A = [r for r in zip(*solve(W, H, w, h))]

for a in A:
    print(*a)

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

int main() {
	int K, A, B;
	cin >> K >> A >> B;

	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}


	cout << "NG" << endl;

}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
#define PI 3.1415926535897932384626433832795
using namespace std;

int main()
{
	int64 nn, sum = 0;
	cin >> nn;
	vector<int64> bb(nn - 1);
	for(int64 ii = 0;ii < nn - 1;ii++)
	{
		cin >> bb[ii];
	}
	sum += bb[0];
	for(int64 ii = 1;ii < nn - 1;ii++)
	{
		sum += min(bb[ii], bb[ii - 1]);
	}
	sum += bb[nn - 2];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3628
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        String[] input = new String[n];
        
        for(int i = 0; i < n; i++){
            input[i] = br.readLine();
        }
        
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        
        for(int i = 0; i < n; i++){
            switch(input[i]){
		        case "AC" :
		            ac++;
		            break;
		    
		        case "WA" :
		            wa++;
		            break;
		    
		        case "TLE" :
		            tle++;
		            break;
		    
		        case "RE" :
		            re++;
		            break;
		        
		        default : 
		            break;
            }
        }
        
        out.println("AC x " + ac);
        out.println("WA x " + wa);
        out.println("TLE x " + tle);
        out.println("RE x " + re);
         
        out.close();
        
    }
}

Measured memory_bytes: 43160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void solve()
{
    ll n;
    cin>>n;
    ll ans=expo(10,n,hell);
    ans=(ans-(2*expo(9,n,hell))%hell+hell)%hell;
    ans=(ans+expo(8,n,hell))%hell;
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
using namespace std;
#define N 100100
long long sel[N], cnt[N];
long long x, i, n, m, acc, penalty;
string s;
int main()
{
    cin >> n >> m;
    for (i = 0; i < m; ++i){
        cin >> x >> s;
        if (s[0] == 'W'){
            ++cnt[x];
        }
        else{
            if (!sel[x]){
                sel[x] = 1;
                penalty += cnt[x];
                ++acc;
            }
        }
    }
    cout << acc << " " << penalty;
    return 0;
}


Measured memory_bytes: 1664
taro_score = 0
hanako_score = 0

for i in range(int(input())):
    taro,hanako = input().split()
    if taro < hanako:
        hanako_score += 3
    elif taro > hanako:
        taro_score += 3
    else:
        taro_score += 1
        hanako_score += 1
        
print(str(taro_score),str(hanako_score))

Measured memory_bytes: 7656
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

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

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = getLine >>= putStrLn . which "Yes" "No" . ( /= 1 ) . length . group

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    int fclass = N%10;
    if(fclass == 3){
        cout << "bon" << endl;
    }else if(fclass == 0 || fclass == 1 || fclass == 6 || fclass == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int a[2002], n, d[2][2002];

int f(int t, int k) {
	int res=abs(a[k]-a[n-1]);
	if(d[t][k]>=0) return d[t][k];
	for(int i=k+1;i<n-1;i++) {
		if(t==0) res=max(res,f(1,i));
		else res=min(res,f(0,i));
	}
	return d[t][k]=res;
}

int main() {
	int z, w;
	scanf("%d %d %d",&n,&z,&w);
	a[0]=w;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	n++;
	memset(d,-1,sizeof(d));
	printf("%d\n",f(0,0));
	return 0;
}

Measured memory_bytes: 256
n=int(input())
x=0
y=0
c=0
if n%2==0:
  lists=[n,n,n//2]
  print(*lists)
elif n%4==3:
  lists=[(n+1)//4,n*(n+1)//2,n*(n+1)//2]
  print(*lists)
else:
  for a in range(2,3501,2):
    for b in range(a,3501,2):
      if 4*a*b>(b+a)*n and (a*b*n)%(4*a*b-(b+a)*n)==0:
            x=a
            y=b
            c=(a*b*n)//(4*a*b-(b+a)*n)
            break
  lists=[x,y,c]
  print(*lists)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;



/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

const int N = 3010;
int dp[N][N];

int calc(int l , int r , int turn , vector<int> &a){

	if(l > r)
		return 0;

	int &ans = dp[l][r];
	if(ans!=-1)
		return ans;

	int val = 0;
	//debug(l , r);
	if(turn ==0)
		return dp[l][r] = max(a[l] + calc(l+1 , r , turn^1 , a) , a[r] + calc(l , r-1 , turn^1 , a));
	else return dp[l][r] = min(calc(l+1 , r , turn^1 , a) , calc(l , r-1 , turn^1 , a));
}

void solve(){

	int n;
	cin>>n;
	vector<int> a(n);
	int sum = 0;
	for(int i = 0 ; i < n ; ++i){

		cin>>a[i];
		sum += a[i];
	}

	memset(dp , -1 , sizeof dp);

	int x = calc(0 , n-1 , 0 , a);
	int y = sum - x;
	//debug(x);
	cout<<x - y<<endl;
}

signed main(){

    fast;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}






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

#define MAX 100
#define THOU 1000
#define FIVEMAX 100000
#define NINEMAX 1000000000
#define TWEMAX 1000000000000
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define arep(i,a,n) for(int i=a;i<n;i++)

int main(){
 int a[2*FIVEMAX],b[2*FIVEMAX-1];
 
 string str;
 vector<int>v;
 vector<string>s;
 map<string,int>m;
 pair<int,int>p;
 int n;
 cin>>n;
 rep(i,n)cin>>a[i];
 long long ans=0;
 arep(i,1,n){
     if(a[i-1]<=a[i])b[i]=0;
     else {
         b[i]=a[i-1]-a[i];
         a[i]+=b[i];
     }
     ans+=b[i];
 }
 

 

cin.tie(0);
ios::sync_with_stdio(false);
cout<<ans<<endl;
return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n;

int main() {
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}


Measured memory_bytes: 3588
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		double r, l, s;
		
		r = sc.nextDouble();
		
		l = 2 * r * Math.PI;
		s = r * r * Math.PI;
		
		System.out.printf("%.5f %.5f\n", s, l);
	}
}

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

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 >= 22){
        cout << "bust" << endl;
    }  
    else{
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
A,B,C,X,Y=map(int,input().split())

ooiXY=max(X,Y)
sukunaiXY=min(X,Y)
ans1=C*ooiXY*2
ans2=A*X+B*Y
ans3=C*sukunaiXY*2+A*(X-sukunaiXY)+B*(Y-sukunaiXY)

print(min(ans1,ans2,ans3))

Measured memory_bytes: 3060
N = int(input())
A_list = list(map(int, input().split()))

def gcd(v1, v2):
    if v2 == 0:
        return v1
    return gcd(v2, v1%v2)

tmp = A_list[0]
for a in A_list:
    tmp = gcd(tmp, a)

print(tmp)

Measured memory_bytes: 15020
#include <cstdio>
int n,a,d,t[1000003],maxa=-(1<<30);
//maxa保存a的最大值，也是因子的最大值，t[i]表示因子i有多少个，d为n个数的最大公因数
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
void fj(int x){//分解质因数
    for(int i=2;i*i<=x;){
        if(!(x%i)){
            ++t[i];//用桶记下来
            while(!(x%i)) x/=i;
        }
        else ++i;
    }
    if(x>1) ++t[x];//不要忘了这一句
}
int main(){
    scanf("%d%d",&n,&a);
    d=a;//d初始值为a
    for(int i=2;i<=n;i++){
        scanf("%d",&a);
        if(maxa<a) maxa=a;//更新maxa
        d=gcd(d,a);//求n个数的公因数可以这么做
        fj(a);//对a分解质因数
    }
    if(d==1){
        for(int i=2;i<=maxa;i++)
            if(t[i]>1) return puts("setwise coprime"),0;
            //t[i]>1说明有几个数有相同的因子，则肯定有一对数不互质
        return puts("pairwise coprime"),0;
    }
    else return puts("not coprime"),0;
    return 0;
}



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

//リストの最大個数
#define MAXLIST 2000000
//コマンドの長さ
#define CMDLENGTH 20

//リストの構造体
typedef struct {
	//キー
	int data;
	//次のアドレス
	int next_key;
	//前のアドレス
	int back_key;
}List;

void insert_key(List list[MAXLIST], int *first_point, int data);
void delete_key(List list[MAXLIST], int *first_point, int *last_point, int data);
void delete_first_key(List list[MAXLIST], int *first_point, int data);
void delete_last_key(List list[MAXLIST], int *last_point, int data);

int main(void)
{
	//リストの生成
	static List list[MAXLIST] = { -1, 1, -1 };
	int i, n;
	//first_pointはリストの先頭を、last_pointはリストの最後尾を格納
	int data, first_point, last_point;
	char cmd[CMDLENGTH];

	//命令の数を入力
	scanf("%d", &n);

	first_point = last_point = 0;

	for (i = 0; i < n; i++) {
		//命令を入力
		scanf("%s", cmd);

		//コマンド毎に関数を呼び出す
		if (!strcmp(cmd, "insert")) {
			//挿入するキーを入力
			scanf("%d", &data);
			insert_key(list, &first_point, data);
		}
		else if (!strcmp(cmd, "deleteFirst")) {
			delete_first_key(list, &first_point, data);
		}
		else if (!strcmp(cmd, "deleteLast")) {
			delete_last_key(list, &last_point, data);
		}
		else if (!strcmp(cmd, "delete")) {
			//削除するキーを入力
			scanf("%d", &data);
			delete_key(list, &first_point, &last_point, data);
		}
	}

	//先頭から最後尾まで結果を出力
	first_point -= 1;
	printf("%d", list[first_point].data);
	i = list[first_point].back_key;
	while (i >= last_point) {
		printf(" %d", list[i].data);
		i = list[i].back_key;
	}
	printf("\n");

	return 0;
}

//キーを挿入
void insert_key(List list[MAXLIST], int *first_point, int data)
{
	int key;

	key = *first_point;
	
	//現在のセルにキーを挿入
	list[*first_point].data = data;
	//次のアドレスを挿入
	list[*first_point].next_key = *first_point + 1;

	//先頭を一つ進める
	*first_point += 1;
	//前のアドレスを挿入
	list[*first_point].back_key = key;
}

//キーを削除
void delete_key(List list[MAXLIST], int *first_point, int *last_point, int data)
{
	int i, next_key, back_key;

	//先頭から最後尾まで繰り返す
	for (i = (*first_point - 1); i >= *last_point; i--) {
		//データが一致する場合
		if (list[i].data == data) {
			//先頭にあれば先頭のキーを削除する関数を呼び出す
			if (i == *first_point - 1) {
				delete_first_key(list, first_point, data);
			}
			//最後にあれば最後のキーを削除する関数を呼び出す
			else if (i == *last_point) {
				delete_last_key(list, last_point, data);
			}
			//それ以外の場合
			else {
				//削除するセルの次のアドレスと前のアドレスを保存
				next_key = list[i].next_key;
				back_key = list[i].back_key;
				//データを削除
				list[i].data = -1;

				//アドレスを更新
				list[back_key].next_key = next_key;
				list[next_key].back_key = back_key;
			}
			//削除したらループ終了
			break;
		}
	}
}

//リストの先頭を削除する
void delete_first_key(List list[MAXLIST], int *first_point, int data)
{
	*first_point -= 1;

	//データを削除し、先頭アドレスを更新する
	list[*first_point].data = -1;
	*first_point = list[*first_point].back_key + 1;
}

//リストの最後尾を削除する
void delete_last_key(List list[MAXLIST], int *last_point, int data)
{
	//データを削除し、最後尾のアドレスを更新する
	list[*last_point].data = -1;
	*last_point = list[*last_point].next_key;
}


Measured memory_bytes: 13404
def dfs(i,ls):
    if i == 10:
        return len(ls) == n and sum(ls) == s
    return dfs(i + 1,ls) + dfs(i + 1,ls + [i])

while True:
    n,s = map(int,input().split())
    if n == 0:
        break
    print(dfs(0,[]))

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

int main() {
  int N;
  cin >> N;
  vector<vector<int64_t>> vec(N,vector<int64_t>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
    swap(vec.at(i).at(0),vec.at(i).at(1));
  }
  sort(vec.begin(),vec.end());
  
  int64_t deadline = 0;
  int64_t work = 0;
  bool done = true;
  
  for(int i=0; i<N; i++){
    work += vec.at(i).at(1);
    deadline = vec.at(i).at(0);
    if(work > deadline){
      done = false;
    }
  }
  if(done){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 11136
#include <stdio.h>
int main(void){
  int a;
  int b;
  int h;
  int c;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&h);
  c=(a+b)*h/2;
  
  printf("%d\n",c);
  
  return 0;
}

Measured memory_bytes: 128
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    long x;
    scan(x);

    bool check(long y) {
        long c = 11 * (y / 2);
        if (y % 2) c += 6;
        return c >= x;
    }
    
    long ng = 0, ok = x;
    while (abs(ok - ng) > 1) {
        auto md = (ok + ng) / 2;
        (check(md) ? ok : ng) = md;
    }
    auto ans = ok;
    writeln(ans);
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<ll,ll>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 10000000007;



int main() {

	ll k;
	cin >> k;

	ll a = 7;
	if (a % k == 0) {
		cout << 1 << endl;
		return 0;
	}

	FOR(i, 2, k * 2 + 1) {
		a *= 10;
		a += 7;
		a %= k;
		if (a == 0) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;


	return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string s;
    cin>>s;
    int n=s.size();
    int guu0=0,ki0=0,guu1=0,ki1=0;
    rep(i,n){
        if(i%2==0){
            if(s[i]-'0') guu1 ++;
            else guu0 ++;
        }
        else{
            if(s[i]-'0') ki1 ++;
            else ki0 ++;
        }
    }
    int ans=0;
    ans=guu1+ki0;
    ans =min(ans,guu0+ki1);
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>
long long a[90] = {2,1};
int main()
{
	int n,i;
	scanf("%d", &n);
	if(n == 0)
	{
		printf("2\n");
	}
	if(n == 1)
	{
		printf("1\n");
	}
	if(n >=2)
	{
		for(i = 2; i <= n ;i++)
		{
			a[i] = a[i - 1] + a[i - 2];
		}
		printf("%lld\n",a[n]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int x,y;
	cin >> x >> y;
	if(y%2==0 && y<=4*x && y>=2*x)std::cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}


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

struct pos {
    int x;
    int y;
};

int main() {
    int N;
    cin >> N;
    pos p[N];
    for(int i = 0;i < N;i++) {
        cin >> p[i].x >> p[i].y;
    }

    int max_count = 0;

    for(int i = 0;i < N;i++) {
        int x1 = p[i].x;
        int y1 = p[i].y;
        for(int j = 0;j < N;j++) {
            int x2 = p[j].x;
            int y2 = p[j].y;

            int dx = x2 - x1;
            int dy = y2 - y1;

            int count = 0;

            for(int k = 0;k < N;k++) {
                for(int l = 0;l < N;l++) {
                    if(k == l)continue;

                    if(p[k].x + dx == p[l].x && p[k].y + dy == p[l].y) {
                        count++;
                    }
                }
            }
            max_count = max(count, max_count);
        }
    }

    cout << N - max_count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  map<int,int> mp;
  REP(i,n) {
    int a;
    cin >> a;
    REP(j,a) { int b; cin >> b; mp[b-1]++; }
  }
  int cnt = 0;
  for(auto p : mp) {
    int f = p.first;
    int s = p.second;
    if(s == n) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,ans=0;
    string s;
    map<string,lli> mp;
    
    for(i=0;i<n;i++)
    {
        cin>>s;
        if(mp[s]==0)
        {
            mp[s]=1;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 19284
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007


int N,u,v;
int A[100005],B[100005];

struct dijkstra_normal{
    int V;
    vector<pair<int,int> > *edges;
    dijkstra_normal(int N): V(N){
        edges=new vector<pair<int,int> > [N];
    }
    void push(int a,int b, int c){
        edges[a].pb( mp(b,c) );
    }
    int *solve(int start){
        int *d; 
        d=new int[V];
        priority_queue< pair<int,int> , vector< pair<int,int> >, greater< pair<int,int> > > q;
        fill(d, d + V, LLINF);
        q.push(mp(0,start));
        d[start]=0;
        while(!q.empty()){
            pair<int,int> p=q.top();q.pop();
            int now=p.second;int cost=p.first;
            if(d[now]<cost)continue;
            rep(e,edges[now].size()){
                int to=edges[now][e].first;int cst=edges[now][e].second;
                if(d[to]>d[now]+cst){
                    d[to]=d[now]+cst;
                    q.push(mp(d[to],to));
                }
            }
        }
        return d;
    }
    void clear(){
        delete[] edges;
    }
};

signed main(){
    scanf("%lld %lld %lld",&N,&u,&v);u--;v--;
    dijkstra_normal dijk(N);
    rep(i,N-1){
        scanf("%lld %lld",&A[i],&B[i]);A[i]--;B[i]--;
        dijk.push(A[i],B[i],1);dijk.push(B[i],A[i],1);
    }
    int ans=0;
    int *d=dijk.solve(v);
    int *d2=dijk.solve(u);
    rep(i,N){
        if(d[i]>=d2[i])ans=max(ans,d[i]);
        //printf("%lld %lld %lld\n",i,d[i],d2[i]);
    }
    printf("%lld\n",ans-1);
    return 0;
}


Measured memory_bytes: 11548
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a;
  cin>>n>>a;
  int g=a;
  int l=a;
  for(int i=1;i<n;i++){
    cin>>a;
    g=max(g,a);
    l=min(l,a);
  }
  cout<<g-l<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////



int main() {

	ll N;
	cin >> N;
	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	ll ans = 1;
	ll od = 1;
	repn(i, N) {
		if (A[i] % 2 == 0) { od *= 2; }
		ans *= 3;
	}
	
	cout << ans - od;
	
	

	system("PAUSE");
}


Measured memory_bytes: 504
while True:
    a,op,b = [i for i in input().split()]
    a = int(a)
    b = int(b)

    if op == "+" :
        print(a+b)

    elif op == "-"   :
        print(a-b)

    elif op == "*"   :
        print(a*b) 

    elif op == "/"   :
        print(a//b)

    elif op == "?"       :
        break
        


Measured memory_bytes: 5604
import re
import functools

class IO_for_Contest(object):
    @staticmethod
    def my_input():
        #return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        n, m = IO_for_Contest.read_n_int(2)
        x, y = [], []
        for i in range(m):
            xx, yy = IO_for_Contest.read_n_int(2)
            x.append(xx)
            y.append(yy)
        return n, x, y

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(int, re.split('\W+', IO_for_Contest.my_input().strip())))[ : n]

def solve():
    n, x, y = IO_for_Contest.read_from_input()
    m = len(x)
    print(count_boxes_can_have_red_ball(n, m, x, y))

def count_boxes_can_have_red_ball(n, m, x, y):
    """
    >>> n, m, x, y = 3, 2, [1, 2], [2, 3]
    >>> count_boxes_can_have_red_ball(n, m, x, y)
    2
    """
    balls = [0]
    red_ball_can_exist = [None]
    for i in range(n):
        if i == 0:
            red_ball_can_exist.append(True)
        else:
            red_ball_can_exist.append(False)
        balls.append(1)
    for i in range(m):
        f, t = x[i], y[i]
        balls[f] -= 1
        balls[t] += 1
        if red_ball_can_exist[f]:
            if balls[f] <= 0:
                red_ball_can_exist[f] = False
            red_ball_can_exist[t] = True
        else:
            pass
        #print('{0:d}, {1:s}, {2:s}'.format(i, str(balls), str(red_ball_can_exist)))
    return red_ball_can_exist.count(True)

if __name__ == '__main__':
    #import doctest
    #doctest.testmod()
    solve()

Measured memory_bytes: 13372
k=int(input())
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])

Measured memory_bytes: 61716
#include<iostream>
using namespace std;
int main() {
	string x, y;
	cin >> x >> y;
	int a=0, b=0;
	if (x == "A")a = 10;
	if (x == "B")a = 11;
	if (x == "C")a = 12;
	if (x == "D")a = 13;
	if (x == "E")a = 14;
	if (x == "F")a = 15;
	if (y == "A")b = 10;
	if (y == "B")b = 11;
	if (y == "C")b = 12;
	if (y == "D")b = 13;
	if (y == "E")b = 14;
	if (y == "F")b = 15;

	if (x == y)cout << "=" << endl;
	else if (a > b)cout << ">" << endl;
	else cout << "<" << endl;
}

Measured memory_bytes: 256
S = input()
if S == 'SUN':
    print(7)
    exit(0)
if S == 'MON':
    print(6)
    exit(0)
if S == 'TUE':
    print(5)
    exit(0)
if S == 'WED':
    print(4)
    exit(0)
if S == 'THU':
    print(3)
    exit(0)
if S == 'FRI':
    print(2)
    exit(0)
if S == 'SAT':
    print(1)
    exit(0)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
void countingsort(int A[],int B[],int k,int n){
    int C[k+1];
    for(int i=0;i<=k;i++){
        C[i]=0;
    }
    for(int j=1;j<=n;j++){
        C[A[j]]=C[A[j]]+1;
    }
    for(int i=1;i<=k;i++){
        C[i]=C[i]+C[i-1];
    }
    for(int j=n;j>=1;j--){
        B[C[A[j]]]=A[j];
        C[A[j]]=C[A[j]]-1;
    }
}
int main(){
    int A[2000000]={},B[2000000]={};
    int n,k=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>A[i];
        if(k<A[i]){
            k=A[i];
        }
    }
    countingsort(A,B,k,n);
    for(int i=1;i<n;i++){
        cout<<B[i]<<" ";
    }
    cout<<B[n]<<endl;
    return 0;
}


Measured memory_bytes: 18756
<?php
fscanf(STDIN, "%s", $in_n);

$amari = $in_n % 10;

if($amari == 3){
    $ans = "bon";
}elseif(($amari == 0) || ($amari == 1) || ($amari == 6) ||($amari == 8)){
    $ans = "pon";
}else{
    $ans = "hon";
}

echo "$ans\n";


Measured memory_bytes: 16128
s = input()
n = len(s) + 1
v = [0]*n

for i in range(n-1):
    if s[i] == "<":
        v[i+1] = v[i] + 1

for j in range(n-1):
    if s[-j-1] == ">":
        if v[-j-2] <= v[-j-1]:
            v[-j-2] = v[-j-1] + 1

print(sum(v))

Measured memory_bytes: 46320