akhauriyash/Code-Regression huggingface dataset:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main() {
    string S, T;
    int A, B;
    string U;
    cin >> S >> T >> A >> B >> U;

    if(U == S) {
        cout << A - 1 << ' ' << B << endl;
    } else {
        cout << A << ' ' << B - 1 << endl;
    }
    return 0;
}


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

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  int count = 0;
  for (int i = 0; i<N; i++) {
    cin >> A.at(i);
    count += A.at(i);
  }
  if (H <= count) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
import math
def cmb(n,r):
  return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
n=int(input())
a=list(map(int,input().split()))
a.sort()
ls=[0]
cnt=0
for i in range(1,2**n):
  if a[i]>a[i-1]:
    cnt+=1
  ls.append(cnt)
lmt = []
for i in range(n+1):
  lmt.extend([i]*cmb(n,i))
bias = ls[-1]-lmt[-1]
jdg = 0
ulmt = 0
for i in range(n):
  jdg += ls.count(i)
  ulmt += 2**(n-i-1)
  if jdg > ulmt:
    print("No")
    exit()
for x,l in zip(ls,lmt):
  if x-l > bias:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 34256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(m+1);
    int ans=0;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int i=0;i<k;i++){
            int b;
            cin>>b;
            a[b]++;
        }
    }
    for(int i=1;i<=m;i++){
        if(a[i]==n)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    if(S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> S(n);
    vector<map<char,int>> ss(n);
    map<char,int> rs;

    rep(i,n)
        cin >> S.at(i);

    rep(i,n)
        rep(j, S.at(i).size()) {
            char c = S.at(i).at(j);
            if(ss.at(i).count(c))
                ss.at(i).at(c)++;
            else
                ss.at(i)[c] = 1;
        }


    for(auto p : ss.at(0))
        rs[p.first] = p.second;
    
    rep(i, n-1)
        for(auto p : rs)
            if(ss.at(i+1).count(p.first))
                rs.at(p.first) = min(rs.at(p.first), ss.at(i+1).at(p.first));
            else
                rs.erase(p.first);
    
    for(auto p : rs)
        rep(i, p.second)
            cout << p.first;
    cout << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = [int(x) for x in input().split()]
pair = []
c = Counter(A)
for x,cnt in c.items():
  pair += [x]*(cnt//2)

pair.sort()

answer = 0
if len(pair)>= 2:
  answer = pair[-1] * pair[-2]

print(answer)


Measured memory_bytes: 18600
def is_unique(seq):
    return len(seq) == len(set(seq))


n = int(input())
w = []
for i in range(n):
    w.append(input())

first = w[0][-1]
result = "Yes"
if not is_unique(w):
    result = "No"
else:
    for i in range(1,len(w)):
        if not w[i][0] == first:
            result = "No"
            break
        first = w[i][-1]

print(result)


Measured memory_bytes: 3060
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#n, m, k = 3, 4, 730
#a = [60, 90, 120]
#b = [80, 150, 80, 150]

a = [0] + a
for i in range(n):
    a[i + 1] = a[i] + a[i + 1]

b = [0] + b
for i in range(m):
    b[i + 1] = b[i] + b[i + 1]
    
ans = 0
for i in range(n + 1):
    for j in range(max(0, ans - i + 1), m + 1):
        if a[i] + b[j] <= k:
            ans = i + j
        else:
            break

print(ans)

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    char c;
    cin >> c;
    for (char ch = 'A'; ch <= 'Z'; ch++) {
        if (c == ch) {
            cout << "A\n";
            return;
        }
    }
    cout << "a\n";
}

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


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

def max2(x,y):
    return x if x > y else y

def min2(x,y):
    return x if x < y else y

N, K = map(int, input().split())
H = [0] + list(map(int, input().split()))

dp = [[10**9*N for _ in range(N-K+1)] for _ in range(N+1)]

dp[0][0] = 0
for i, h in enumerate(H[1:], start=1):
    for k in range(1, min2(i+1, N-K+1)):
        dp[i][k] = min(dp[j][k-1] + max2(0, h-H[j]) for j in range(i))
print(min(d[-1] for d in dp))

Measured memory_bytes: 69068
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){
   if(a==0) return b;
   else if(a<b){a^=b;b^=a;a^=b;}
   return a%b?gcd(b,a%b):b; 
}
int main() {
  int n,b=0,ans;
  cin>>n;
  int a[n],v[n+1];
  v[0]=0;
  rep(i,n)
  {
     cin>>a[i];
     v[i+1]=gcd(v[i],a[i]);
  }
  ans=v[n-1];
  for(int i=n-1;i>=1;i--){
      ans=max(ans,gcd(v[i-1],b=gcd(b,a[i])));
  }
  cout<<ans;
}

Measured memory_bytes: 1024
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    printf("%d %d %d\n", z, x, y);
}


Measured memory_bytes: 888
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e17
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    V<int>b(n);
    for(int i=0;i<n;i++)cin>>b[i];
    if(n==1&&b[0]==1){
        cout<<1<<endl;
        return 0;
    }

    vector<int>ans;
    bool color[101];
    memset(color,0,sizeof(color));
    for(int i=0;i<n;i++){
        for(int j=n-1;j>=0;j--){
            if(color[j]==1)continue;
            int cnt=0;
            for(int z=0;z<j;z++){
                if(color[z]==1)cnt++;
            }
            if(b[j]==j+1-cnt){
                //cout<<b[j]<<endl;
                ans.pb(b[j]);
                color[j]=1;
                break;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(color[i]==0)
        {
            cout<<-1<<endl;
            return 0;
        }
    }
    reverse(all(ans));
    if(ans.size()<n){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 256
def main(argv)
  s = gets.chomp
  k = gets.chomp.to_i

  ts = []
  t = s[0]
  (1...s.size).each do |i|
    if t[0] == s[i] then
      t += s[i]
    else
      ts.push(t)
      t = s[i]
    end
  end
  ts.push(t)

  if ts.size == 1 then
    puts ((s.size * k) / 2).to_s
  else
    c = ts.map{|t| t.size / 2}.reduce(:+) * k
    if ts[0][0] == ts[ts.size - 1][0] then
      a = ts[0].size
      b = ts[ts.size - 1].size
      c -= ((a / 2) + (b / 2) - ((a + b) / 2)) * (k - 1)      
    end
    puts c.to_s
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

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

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int gcd(int a, int b) { return b?gcd(b,a%b):a;}

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

  int K;
  cin >> K;
  vector<vector<int>> gcd_box(201, vector<int>(201, 1));
  rep(i, 201) {
    srep(j, i, 201) {
      gcd_box[i][j] = gcd(i, j);
      gcd_box[j][i] = gcd_box[i][j];
    }
  }

  ull answer {};
  srep(i,1,K+1) {
    srep(j,1,K+1) {
      int c = gcd_box[i][j];
      srep(k,1,K+1) {
        answer += gcd_box[c][k];
      }
    }
  }
  cout << answer << '\n';
}


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

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


Measured memory_bytes: 3656
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll n; 
    stack<ll> num;
    cin >> n;
    while(n != 1 && n != 0){
        if(n & 1){
            num.push(1);
            n--;
            n /= -2;
        } else {
            num.push(0);
            n /= -2;
        }
    }
    if(n==1) num.push(1);
    else num.push(0);
    while(num.size()) {
        cout << num.top();
        num.pop();
    }
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 3520
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の標準入力
		int n = sc.nextInt();
		List<String> wordsList = new ArrayList<String>();
		Set<String> checkHash = new HashSet<String>();
		// 整数値の数だけ文字列を標準入力
		for(int i = 0; i < n; i++) {
			wordsList.add(sc.next());
			if(i >= 1) {
				// 文字列の先頭文字と1つ前の文字列の末尾文字を比較
				if(!(wordsList.get(i).substring(0, 1).equals(wordsList.get(i - 1).substring(wordsList.get(i - 1).length() - 1)))) {
					System.out.println("No");
					System.exit(0);
				}
			}
		}
		// 重複している文字列が存在するか
		for(String str : wordsList) {
			if(checkHash.contains(str)) {
				System.out.println("No");
				System.exit(0);
			} else {
				checkHash.add(str);
			}
		}
		System.out.println("Yes");
		sc.close();
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

int X;
void input() {
  cin>>X;
  ;
  ;
}
void solve() {
  rep(a,-1e3,1e3){
    rep(b,-1e3,1e3){
      if (a*a*a*a*a - b*b*b*b*b == X){
        cout<<a<<" "<<b<<endl;return;
      }
    }
  }
  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define pii pair<int, int>
typedef long long ll;

int main(){
    int N; cin >> N;
    vector<pair<double,double> > P(N);
    rep(i, 0, N) cin >> P[i].first >> P[i].second;

    double ans = 0;
    vector<int> v(N);
    rep(i, 0, N) v[i] = i;
    do {
        for(int i = 1; i < N; i++){
            ans += sqrt(pow((P[v[i]].first - P[v[i-1]].first), 2) +  pow((P[v[i]].second - P[v[i-1]].second), 2));
        }
    } while (std::next_permutation(v.begin(), v.end()));
    double sum = 1;
    rep(i, 1, N + 1) sum *= i;
    cout << setprecision(10) << fixed << ans / sum << endl;
}

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

int main() {
  int N; cin >> N;
  vector<int> C(N-1), S(N-1), F(N-1);
  for (int i = 0; i < N-1; i++) cin >> C.at(i) >> S.at(i) >> F.at(i);
  for (int i = 0; i < N-1; i++) {
    int ans = 0;
    ans += S.at(i) + C.at(i);
    for (int j = i+1; j < N-1; j++) {
      if (ans >= S.at(j)) {
        if ((ans - S.at(j)) % F.at(j) == 0) ans += C.at(j);
        else ans += F.at(j) - (ans - S.at(j)) % F.at(j) + C.at(j);
      }
      else ans = S.at(j) + C.at(j);
    }
    cout << ans << endl;
  }
  cout << 0 << endl;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		
		int[] bukaArr = new int[n+1];
		for(int i = 0; i < n-1;i++) {
			bukaArr[fs.nextInt()]++;
		}
		
		for(int i = 1; i < n+1; i++) {
			System.out.println(bukaArr[i]);
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 56616
N, K = map(int, input().split())
j = 0
ls1 = []
ls2 = []

for i in range(1, K+1):
    d = int(input())
    ls1.append(input().split())
for i in range(len(ls1)):
    for j in ls1[i]:
        ls2.append(j)
        x = set(ls2)
print(N - len(x))



Measured memory_bytes: 9652
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, b) for (int i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(n) scanf("%d", &n);
#define pcl(n) printf("%d\n", n)
#define pcl1(n) printf("%lld ", n)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
bool comp(ppi a, ppi b)
{
    return a.first < b.first;
}
int a[102];
vector<int>v;
int main()
{
    FastRead;
    int x, n,i = 0;
	bool cnt=0,cnt1=0;
    cin >> x >> n;
    while (i < n)
    {
        int p;
        cin >> p;
        a[p] = p;
        i++;
    }
    for (int j = 0; j <=101; j++)
    {
		if(a[j]==0) 
		{
			v.pb(j);
			if(j==x) cnt1=1;
		}
    }
	int px=lower_bound(v.begin(),v.end(),x)-v.begin()-1;
	int qx=upper_bound(v.begin(),v.end(),x)-v.begin();
	//cout<<v[px]<<" "<<v[qx]<<endl;
	if(n==0 || cnt)
	{
		cout<<x<<endl;
		return 0;
	}
	else if (cnt1)
	{
		cout<<x<<endl;
	}
    else if(abs(v[qx]-x)<abs(v[px]-x)) 
	{
			cout<<v[qx]<<endl;
	}
	else cout<<v[px]<<endl;		
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll L, R, d;
    cin >> L >> R >> d;

    put(R/d - (L-1)/d);
}
signed main(){ Main();return 0;}

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

int main() {
    long long n, x[110], y[110], sum;
    double D;
    cout << fixed << setprecision(12);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> y[i];
    }
    // p = 1
    sum = 0, D = 0;
    for (int i = 0; i < n; ++i) {
        D += abs(x[i] - y[i]);
    }
    cout << D << endl;
    // p = 2
    sum = 0, D = 0;
    for (int i = 0; i < n; ++i) {
        sum += pow(x[i] - y[i], 2);
    }
    D = sqrt(sum);
    cout << D << endl;
    // p = 3
    sum = 0, D = 0;
    for (int i = 0; i < n; ++i) {
        sum += pow(abs(x[i] - y[i]), 3);
    }
    D = cbrt(sum);
    cout << D << endl;
    // p = inf
    sum = 0, D = 0;
    for (int i = 0; i < n; ++i) {
        D = max(D, (double)abs(x[i] - y[i]));
    }
    cout << D << endl;
    
    return 0;
}


Measured memory_bytes: 3476
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

int main()
{
	//freopen("B.in","r",stdin);
	ll n,a,b,c,d;
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	for (ll i=0;i<n;i++)
	{
		ll lb = i*c - (n-1-i)*d;
		ll ub = i*d - (n-1-i)*c;
		if (b-a >= lb && b-a<=ub) 
		{
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Ans = [0] * (N+1)
mod = 1000000007
Ans[0] = 3
ans = 1
for a in A:
    a += 1
    ans *= Ans[a-1]
    ans %= mod
    Ans[a-1] -= 1
    Ans[a] += 1

print(ans % mod)





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

int main(){
  int N;
  int64_t K;
  cin >> N >> K;
  vector<int> v(N+1);
  for(int i=1;i<=N;i++){
    int A;
    cin >> A;
    v.at(i)=A;
  }
  int cycle=0;
  vector<int> ans;
  int x=1;
  ans.push_back(1);
  vector<int> num(N+1,-1);
  num.at(1)=0;
  int s;
  for(int i=1;;i++){
    int y=v.at(x);
    if(num.at(y)!=-1){
      cycle=i-num.at(y);
      s=num.at(y);
      break;
    }
    num.at(y)=i;
    ans.push_back(y);
    x=y;
  }
  if(s>=K){
    cout << ans.at(K) << endl;
  }else{
    cout << ans.at((K-s)%cycle+s) << endl;
  }
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int r;
	cin >> r;
	cout << r * r << endl;
    
    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
        int a;
        cin >> a;
        return a;
};

void inputArray(int * p, int a){
        rep(i, a){
                cin >> p[i];
        }
};

void inputVector(vector<int> * p, int a){
        rep(i, a){
                int input;
                cin >> input;
                p -> push_back(input);
        }
}

template <typename T>
void output(T a, int precision) {
        if(precision > 0){
                cout << setprecision(precision)  << a << "\n";
        }
        else{
                cout << a << "\n";
        }
}

int main(int argc, const char * argv[]) {

        // source code
        int r,D,x,xi;
        r=inputValue();
        D=inputValue();
        x=inputValue();

        rep(i,10)
        {
                xi = r*x-D;
                output<int>(xi,0);
                x=xi;
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int x;
    cin >> x;
    int best = 1;
    rep(b_, sqrt(x)) {
        int b = b_ + 1;
        rep(p_, 1000) {
            int p = p_ + 2;
            int v = 1;
            rep(i, p) v *= b;
            if (v > x) {
                break;
            }
            // put(b)
            // put(p)
            // put(v)
            // put("--")
            best = max(best, v);
        }
    }
    put(best)
    return 0;
}

Measured memory_bytes: 3620
# 尺取かと思ったけど実装できんな
# あれ？過半数だから成立する場合は3文字だけを抜き取ったどこかで必ず成立するのでは
s = input()
if len(s) == 2:
    if s[0] == s[1]:
        print(1, 2)
    else:
        print(-1, -1)
    exit()
for i in range(len(s) - 3):
    target = s[i : i + 3]
    if target[0] == target[1] or target[1] == target[2] or target[2] == target[0]:
        print(i + 1, i + 3)
        exit()
print(-1, -1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int h[N];
  rep(i, N){
    cin >> h[i];
  }

  int ans = 0;
  int active = 0;

  rep(i, N){
    if(active >= h[i]){
      active = h[i];
    }
    else{
      ans += h[i] - active;
      active = h[i];      
    }
  }
  cout << ans << endl;


  /*  int st[100]={1};
  int st_tmp[100]={1};
  int ed[100]={1};
  int ed_tmp[100]={1};
  st[0] = 0;
  ed[0] = N-1;*/

  //範囲最小値を持ってくる
  //最小値前後で区間を分ける。
  //複数あるなら区間も複数
  //分けた区間で要素がなくなるまでこれを繰り返す。

  //今ある各区間で次の区間を決めるための探索をする。
  /*  REP(J,N){
    IF(ST[J] != -1){
      IF(ST[)
      FOR(INT I= ST[J]; I<ED[J]; I++){
	IF(LOW[0].FIRST >  H[I]){
	  LOW.CLEAR();
	  LOW.PUSH_BACK(MAKE_PAIR(H[I],I));
	}
	ELSE IF(LOW[0].FIRST ==  H[I]){
	  LOW.PUSH_BACK(MAKE_PAIR(H[I],I));
	}	
      }
      IF(LOW.SIZE() == 1){
	ST_TMP[K] = MAX(ST[J], LOW[0].SECOND+1);
	ED_TMP[K] = MIN(ED[J], LOW[0].SECOND-1);
	K++;
      }
      ELSE{
	REP(L,LOW.SIZE()){
	  ST_TMP[K] = MAX(ST[J], LOW[L].SECOND+1);
	  ED_TMP[K] = MIN(ED[J], LOW[L].SECOND-1);
	  K++;
	}
        K++;
      }


    }
    
    }*/
  return 0;
    

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x[5];
    for(int i = 0; i < 5; i++) {
        cin >> x[i];
    }

    for(int i = 0; i < 5; i++) {
        if(x[i] == 0) {
            cout << i+1 << endl;
            break;
        }
    }

    return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, d, x;
int a[N];

int main()
{
    cin >> n >> d >> x;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];

        int t = 0;
        while(t * a[i] + 1 <= d)
        {
            x++;
            t++;
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll X,Y;
int main() {
    cin>>X>>Y;
    ll L=0;
    while(X<=Y){
    	X*=2;
    	L++;
    }
    cout<<L<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

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

    if(a > b){
        cout << 0 << endl;
        return 0;
    }
    if(n == 1 && a != b){
        cout << 0 << endl;
        return 0;
    }
    int min = a;
    int max = b;
    if(n > 1){
        min += b + (n - 2) * a;
        max += a + (n - 2) * b;
    }

    cout << max - min + 1 << endl;

    return 0;
}


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

int main() {
  string S;
  cin >>S;
  int N = S.size();
  int a=0,b=0;
  
  //1010101010.....
  for(int i=0;i < N;i++){
    if(i%2 == 0){
      if(S[i] == '0'){
        a++;
      }
    }
    if(i%2 == 1){
      if(S[i] == '1'){
        a++;
      }
    } 
  }
  
  //010101010101......
  for(int j=0;j < N;j++){
    if(j%2 == 0){
      if(S[j] == '1'){
        b++;
      }
    }
    if(j%2 == 1){
      if(S[j] == '0'){
        b++;
      }
    } 
  }
  
  cout << min(a,b) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
using ll = long long;
int main(){
    int N; cin>>N;
	vector<int> Ans(N);
	rep(i,N-1){
		ll a=0;
		cin>>a;
		Ans[a-1]++;
	}
	
	rep(i,N){
		cout<<Ans[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4052
/**
*    author:  Dooloper
*    created: 29.06.2020 05:40:09
**/

#include <bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;

ll f(ll n){ return n*(n+1)/2;}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    ll r = n/i;
    ans += f(r) * i;
  }
  cout << ans << endl;
  return 0;
}

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

int main(int argc, char const *argv[])
{
    int x,y;
    while(1){
        cin >> x >> y;
        if(x==0 && y==0) break;
        if (x<y) cout << x <<  " " << y << endl;
        else    cout << y <<  " " << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define me(a,b) memset(a,b,sizeof(a))
int main(){
	int a,b,c;
	cin>>a>>b;
	if(a==1&&b==2||a==2&&b==1)
	cout<<3<<endl;
	if(a==1&&b==3||a==3&&b==1)
	cout<<2<<endl;
	if(a==3&&b==2||a==2&&b==3)
	cout<<1<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque

n, m = map(int,input().split())
path = [[] for i in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    path[a-1].append(b-1)
    path[b-1].append(a-1)

ans = [-1]*n
ans[0] = 0

q = deque([0])
while q:
    now = q.popleft()
    for v in path[now]:
        if ans[v] == -1:
            ans[v] = now
            q.append(v)
print('Yes')
for i in ans[1:]:
    print(i+1)


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

//Please copy under code!

template<typename T>
struct Dinic {
        struct Edge {
                int to, rev;
                T cap;
                Edge () {}
                Edge (int to, int rev, T cap) : to(to), rev(rev), cap(cap) {}
        };

        vector<vector<Edge>> G;
        vector<int> level, itr;
        const T INF;
        int timestamp;
        int V;

        Dinic(int size) : V(size), INF(numeric_limits<T>::max()), timestamp(0) {
                G.resize(size);
        }

        void add_edge(int from, int to, T cap) {
                G[from].emplace_back(to, (int)G[to].size(), cap);
                G[to].emplace_back(from, (int)G[from].size() - 1, 0);
        }

        void bfs(int s) {
                level.assign(V, -1);
                queue<int> que;

                level[s] = 0; que.push(s);
                while (!que.empty()) {
                        int v = que.front(); que.pop();
                        for (auto &e : G[v]) {
                                if (e.cap > 0 && level[e.to] == -1) {
                                        level[e.to] = level[v] + 1;
                                        que.push(e.to);
                                }
                        }
                }
        }

        T dfs(int v, int t, T flow) {
                if (v == t) return (flow);
                for (int& i = itr[v]; i < (int)G[v].size(); i++) {
                        Edge &e = G[v][i];
                        if (e.cap > 0 && level[e.to] > level[v]) {
                                T d = dfs(e.to, t, min(flow, e.cap));
                                if (d > 0) {
                                        e.cap -= d;
                                        G[e.to][e.rev].cap += d;
                                        return (d);
                                }
                        }
                }
                return (0);
        }

        T max_flow(int s, int t) {
                T flow = 0, f;
                while (bfs(s), level[t] >= 0) {
                        itr.assign(V, 0);
                        while ((f = dfs(s, t, INF)) > 0) flow += f;
                }
                return (flow);
        }
};

//Please copy above code!

//verify用のソースコードはei1333さんのものを借りました
int main() {
        int V, E;
        scanf("%d %d", &V, &E);
        Dinic< int > g(V);
        for(int i = 0; i < E; i++) {
                int a, b, c;
                scanf("%d %d %d", &a, &b, &c);
                g.add_edge(a, b, c);
        }
        printf("%d\n", g.max_flow(0, V - 1));
}



Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
  long long n;
  cin>>n;
   long long*arr=new long long [n];
   long long temp=0;
   for(int i=0;i<n;i++)
   {
   	cin>>arr[i];
   	temp=temp^arr[i];
   }
   for(int i=0;i<n;i++)
   {
   	cout<<(temp^arr[i])<<" ";
   }
 
  
}


Measured memory_bytes: 5188
def parent(num):
    return int(num/2)

def left(num):
    return int(num*2)

def right(num):
    return int(num*2)+1

if __name__ == "__main__":    
    n = int(input())
    h_list = [-1] + list(map(int, input().split()))
    for i in range(1, n+1):
        sentence = 'node {0}: key = {1}, '.format(i, h_list[i])
        if parent(i) > 0:
            sentence += 'parent key = {0}, '.format(h_list[parent(i)])
        if left(i) <= n:
            sentence += 'left key = {0}, '.format(h_list[left(i)])
        if right(i) <= n:
            sentence += 'right key = {0}, '.format(h_list[right(i)])
        print(sentence)



Measured memory_bytes: 5628
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

int pri[60];
int n;

bool prime(int x)
{
    int i,t=0;
    for(i=2;i<sqrt(x);i++)
    {
        if(x%i==0)
        {
            t++;
            break;
        }
    }
    if(t!=0)
    return false;
    return true;
}

int main()
{
    int a,i;
    while(scanf("%d",&n)!=EOF)
    {
        a=3;
        for(i=1;i<55;i++)
        {
            a=a+10;
            while(!prime(a))
            {
                a=a+10;
            }
            pri[i]=a;
        }
        pri[0]=2;
        for(i=0;i<n-1;i++)
            printf("%d ",pri[i]);
        printf("%d\n",pri[n-1]);
    }
    return 0;
}


Measured memory_bytes: 256
/*
TEMPLATE
by.YXH_XianYu
   2018.7.4
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define rep(i,j,k) for(int i=j,lim=k;i<=lim;i++)
#define MXN 105

int n;
char s[MXN],
	 t[MXN],
	 ch;

int main(){
	//freopen("TEMPLATE.in","r",stdin);
	//freopen("TEMPLATE.out","w",stdout);

	scanf("%d%s%s",&n,s+1,t+1);
	int ans=n;
	while (ans) {
		int lim=ans;
		for (int i=1; i<=lim; i++)
			if (s[n-ans+i] != t[i]) {
				ans--;
				break;
			}
		if(lim==ans)
			break;
	}
	printf("%d\n",2*n-ans);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>

#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>

#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

class Data{
    public:
        int i;
        int p;
        int y;
        int order;

    static bool cmp_by_i(const Data &a, const Data &b)
    {
        return a.i < b.i;
    }

    static bool cmp_by_y(const Data &a, const Data &b)
    {
        return a.y < b.y;
    }
};

void printV(vector<Data> list){
    cout << "[vector]" << endl;
    
    for(int i=0; i < list.size(); i++){
        cout << list[i].i << " ";
        cout << list[i].p << " ";
        cout << list[i].y << " ";
        cout << list[i].order << " ";
        cout << endl;
    }
    cout << endl;
}

int main(){
    // input
    int n, m;
    cin >> n >> m;

    vector<Data> list;

    FOR(i,0,m){
        int p, y;
        cin >> p >> y;

        Data d;
        d.i = i;
        d.p = p;
        d.y = y;

        list.push_back(d);
    }

    // sort by year
    sort(list.begin(), list.end(), Data::cmp_by_y);

    map<int, int> mp;

    FOR(i,0,m){
        mp[list[i].p]++;
        list[i].order = mp[list[i].p];
    }
    
    // sort
    sort(list.begin(), list.end(), Data::cmp_by_i);

    // print
    for(auto data : list){
        std::cout << std::setfill('0') << std::right << std::setw(6) << data.p;
        std::cout << std::setfill('0') << std::right << std::setw(6) << data.order << endl;
    }
    
    return 0;
}

Measured memory_bytes: 7792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
constexpr ll mod = 1000000007;

int main(){
    ll ans = 0;
    ll n;
    cin >> n;
    rep(i, 1, n+1){
        ll a;
        cin >> a;
        if(i % 2 == 1 && a % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main(){
  int x,y,ans;
  char op;
  cin>>x>>op>>y;
  while(op!='?'){
    switch(op){
      case '+': ans=x+y; break;
      case '-': ans=x-y; break;
      case '*': ans=x*y; break;
      case '/': ans=x/y; break;
    }
    cout<<ans<<"\n";
    cin>>x>>op>>y;
  }
}

Measured memory_bytes: 3060
from sys import stdin
from itertools import accumulate
input = stdin.readline

MOD = 10**9+7
N, K = map(int,input().split())
a = list(map(int,input().split()))

p = list(accumulate(a))

dp = [0] * (K+1)
dp[0] = 1
prefix = [0]+[1]*(K+1)
for i in range(N):
    new_dp = [0]*(K+1)
    for j in range(min(p[i],K)+1):
        new_dp[j] = prefix[j+1] - prefix[max(0,j-a[i])]
    dp = new_dp[:]
    prefix = [i % MOD for i in [0]+list(accumulate(dp))]

print(dp[K]%MOD)


Measured memory_bytes: 138068
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
static const int INF = 1000000000;

pll solve(int a, int b, const vector<vector<int>>& g){
	const int n = g.size();
	vector<int> d(n, INF);
	queue<int> q;
	q.push(a);
	d[a] = 0;
	if(a != b){
		q.push(b);
		d[b] = 0;
	}
	while(!q.empty()){
		const int u = q.front();
		q.pop();
		for(const auto v : g[u]){
			if(d[v] >= INF){
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	}
	vector<vector<int>> h(n);
	int max_color = 0;
	for(int i = 0; i < n; ++i){
		h[d[i]].push_back(i);
		max_color = max(max_color, d[i]);
	}
	ll n_leaves = 1;
	for(int i = max_color - 1; i >= 0; --i){
		ll max_deg = 0;
		for(const int u : h[i]){
			ll deg = 0;
			for(const int v : g[u]){
				if(d[v] > d[u]){ ++deg; }
			}
			max_deg = max(max_deg, deg);
		}
		n_leaves = max_deg * n_leaves;
	}
	if(a == b){
		return pll(max_color + 1, n_leaves);
	}else{
		return pll(max_color + 1, n_leaves * 2);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int>> conn(n);
	for(int i = 1; i < n; ++i){
		int a, b;
		cin >> a >> b;
		--a; --b;
		conn[a].push_back(b);
		conn[b].push_back(a);
	}
	pll answer(INF, 0);
	for(int u = 0; u < n; ++u){
		answer = min(answer, solve(u, u, conn));
		for(const auto v : conn[u]){
			if(u < v){ answer = min(answer, solve(u, v, conn)); }
		}
	}
	cout << answer.first << " " << answer.second << endl;
	return 0;
}



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

int main() {
  string s;
  cin >> s;
  int a = 10 * (s[0] - '0') + (s[1] - '0'), b = 10 * (s[2] - '0') + (s[3] - '0');
  if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
    cout << "AMBIGUOUS" << endl;
  } else if (1 <= a && a <= 12) {
    cout << "MMYY" << endl;
  } else if (1 <= b && b <= 12) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
arg1, arg2 = input().split()
#arg1 = '7'

input_list = []
for i in range(int(arg1)):
    input_list.append(input())

#input_list = ['......', '....#.', '.#....', '..#...', '..#...', '......', '.#..#.']
target_list = []
for row in input_list:
    target_list.append(list(row))
#print(target_list)


# 縦が難しい
# やっぱりまず横を消してしまう。
target_list2 = []
for i in range(len(target_list)):
    for j in range(len(target_list[i])):
        if target_list[i][j] == '#':
            target_list2.append(target_list[i])
            break

#print(target_list2)

target_list3 = list(map(list, zip(*target_list2)))

#print(target_list3)

target_list4 = []
for i in range(len(target_list3)):
    for j in range(len(target_list3[i])):
        if target_list3[i][j] == '#':
            target_list4.append(target_list3[i])
            break

#print(target_list4)

ans_list = list(map(list, zip(*target_list4)))
#print(ans_list)


for row in ans_list:
    moji = ''
    for x in row:
        moji += x
    print(moji)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long



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

	if(a%2&&b%2)cout << "Odd" << endl;
	else cout << "Even" << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Buffer(make([]byte, 500000), 500000)
	sc.Split(bufio.ScanWords)

	n := nextInt()

	var res float64

	for i := 0; i < n; i++ {
		res += 1.0 / nextFloat64()
	}
	res = 1.0 / res
	fmt.Println(res)
}

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll solve_naive(vl a) {
	ll n = sz(a);
	while (n > 1) {
		vl b(--n);
		FOR(i,0,n) b[i] = abs(a[i]-a[i+1]);
		a = b;
	}
	return a[0];
}

ll solve(vl a) {
	ll n = sz(a);
	FOR(i,0,n) a[i]--;
	
	bool has1 = false;
	for (ll x: a) if (x == 1) has1 = true;

	if (!has1) FOR(i,0,n) a[i] /= 2;
	FOR(i,0,n) a[i] %= 2;
	
	ll res = 0;
	FOR(i,0,n) if (!(i & (n-1-i))) res += a[i];
	res %= 2;

	if (!has1) res *= 2;
	return res;
}

void brute() {
	ll seed; cin >> seed;
	srand(seed);

	vl cnt(3);
	FOR(i,0,100000) {
		ll n = 2 + rand() % 10;
		vl a(n);
		FOR(i,0,n) a[i] = 1 + rand() % 3;
		ll cur = solve_naive(a);
		if (solve(a) != solve_naive(a)) {
			for (ll x: a) cout << x << " ";
			cout << endl;
			cout << i << " " << solve(a) << " " << solve_naive(a) << endl;
			return;
		}

		cnt[cur]++;
	}
	
	FOR(i,0,3) cout << cnt[i] << endl;
}

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

//	brute();

	ll n; cin >> n;

	vl a(n);
	FOR(i,0,n) {
		char c; cin >> c;
		a[i] = c-'0';
	}

	cout << solve(a) << endl;
}



Measured memory_bytes: 15872
n = int(input())
a = list(map(int,input().split()))
dp = [[0]*(n+2) for i in range(n+2)]

suma = [[0]*(n+2) for i in range(n+2)]

for i in range(n):
    suma[i][i+1] = a[i]
    for j in range(i+2,n+1):
        suma[i][j] = suma[i][j-1]+a[j-1]

for i in range(2,n+1):
    for l in range(n-i+1):
        r = i+l
        dp[l][r] = float("INF")
        for k in range(l+1,r):
            dp[l][r] = min(dp[l][r],dp[l][k]+dp[k][r]+suma[l][r])
print(dp[0][n])

Measured memory_bytes: 50268
#include<stdio.h>
int main()
{
  int n,count=0;
  char str[1000];
  scanf("%d",&n);
  scanf("%s",str);
  for(int i=0;str[i]!='\0';i++)
    	count++;
  if(count<=n)
    	puts(str);
  else
  {
    for(int i=0;i<n;i++)
        printf("%c",str[i]);
    printf("...\n");
  }
  return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

#define Int long long
#define rep(i, n) for (Int i = 0; i < n; i++)
#define in(params) cin >> params;
#define p(params) cout << params << endl;
#define mod 1000000007LL

using namespace std;

int main()
{
    Int N;
    cin >> N;
    Int H[N];
    Int H2[N];

    if (N == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }

    Int last, current;
    cin >> last;
    H2[0] = last - 1;

    for (Int i = 1; i < N; i++)
    {
        cin >> current;


        if (last  + 1<= current)
        {
            last = current - 1;
        }
        else if (last <= current)
        {
            last = current;
        }
        else
        {
            last = current;
        }
        H2[i] = last;
    }

    last = H2[0];
    for (Int j = 1; j < N; j++)
    {
        if (last <= H2[j])
        {
            last = H2[j];
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1024
S = input()
mid = len(S) // 2
change = 0
# for odd
if len(S) % 2 != 0:
  mid_index = mid
else:
  mid_index = mid
for i in range(0, mid_index):
    if S[i] != S[len(S) - i - 1]:
      change = change + 1
print(change)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, count = 0;
  cin >> a >> b >> c;
  
  for(int i = a; i < b + 1; i++){
    if(c % i == 0){
      count++;
    }
  } 
  cout << count << endl;
}



Measured memory_bytes: 3100