akhauriyash/Code-Regression huggingface dataset:
#include<cstring>
#include<cstdio>
using namespace std;

//
// ???????????\???????????????????????????????????????????????????????????????????????\??????????????????????????????
//

#define m 1046527
#define l 14

char H[m][l];

int h1(long long key) { return key % m; }

int h2(long long key) { return 1 + (key % m-1); }

int Hash(long long key, int i) {
  // double hash function using the above
  return (h1(key) + i*h2(key)) % m;
}

long long power(int x, int y) {
  if (y == 0) return 1;
  else return x * power(x, y-1);
}


long long strtoi(char x[]) {
  long long sum = 0;
  for (unsigned int i = 0; i < strlen(x); i++) {
    if (x[i] == 'A') sum += 1*power(10, i);
    else if (x[i] == 'C') sum += 2*power(10, i);
    else if(x[i] == 'G') sum += 3*power(10, i);
    else if (x[i]  == 'T') sum += 4*power(10, i);
  }
  return sum;
}


int insert(char str[]) {
  // insert data into the hash table
  long long i = 0;
  long long key = strtoi(str);
  while (true) {
      long long j = Hash(key, i);
      if (strcmp(H[j], str) == 0) return 1;
      else if (strlen(H[j]) == 0) {
	strcpy(H[j], str);
	return 0;
      }
      else i++;
    }
}

int search(char str[]) {
  // search data in the hash table
  long long i = 0;
  long long key = strtoi(str);
  while (true) {
      long long j = Hash(key, i);
      if (strcmp(H[j], str) == 0) return j;
      else if (strlen(H[j]) == 0) return 0;
      else i++;
    }
  return 0;
}



int main() {

  long long n;
  scanf("%lld", &n);

  char com[9];
  char str[l];

  for (int i = 0; i < m; i++) {
    H[i][0] = '\0';
  }

  for (long long i = 0; i < n; i++) {
    scanf("%s%s", com, str);
    
    if (com[0] == 'i') insert(str);
    else if (com[0] == 'f') {
      if (search(str)) printf("yes\n");
      else printf("no\n");
    }
  }
}

Measured memory_bytes: 15344
a, b, c, x = 4.times.map{gets.to_i}
count = 0
res = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      total = 500*i + 100*j + 50*k
      if total == x
        res += 1
      end
    end
  end
end

p res


Measured memory_bytes: 1788
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		Console.WriteLine("ABC" + Console.ReadLine());
	}
}


Measured memory_bytes: 13140
from sys import exit
n = int(input())
hh = list(map(int, input().split()))

for i in range(n-1,0,-1):
    if hh[i] >= hh[i-1]:
        continue
    else:
        hh[i-1] -= 1
        if hh[i] >= hh[i-1]:
            continue
#         print(i)
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 20708
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    ll i,j,n;
    cin>>n;
    vector<ll> a(n);
    for(i=0;i<n;i++) cin>>a[i];
    
    sort(a.rbegin(), a.rend());
    
    ll ans = a[0];
    i = 3;
    j = 1;
    while(i<=n)
    {
        ans+=a[j];
        i++;
        if(i<=n) 
        {
            ans+=a[j];
            j++;
            i++;
        }
        else break;
    }
    cout<<ans;
}

Measured memory_bytes: 4792
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;


vector<int> g[100005];
int n,memo[100005]={};

int dfs(int p){
  if (g[p].size()==0) return 0;
  if (memo[p]>0) return memo[p];
  
  int i,dmax=0;
  for (i=0;i<g[p].size();i++){
    dmax=max(dmax,dfs(g[p][i]));
  }
  return memo[p]=dmax+1;
}

int main(void){
  int n,m,i,x,y;
  
  cin >> n >> m;
  for (i=0;i<m;i++){
    cin >> x >> y;
    g[x-1].push_back(y-1);
  }
  
  int ans=0;
  for (i=0;i<n;i++){
    ans=max(ans,dfs(i));
  }
  
  cout << ans << endl;
  
  return 0;
}

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

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

int main() {
    long long N,X;
    cin >> N>>X;
    long long sou, pat,maisuu;
    pat = 0;
    sou = X;
    for (int i = 0; i < N; i++) {
        maisuu = 1;

        for (int j = i; j <N; j++) {
            maisuu = 2*maisuu+3;
        }
        if (sou < 1) {
            break;
        }
        else {
            if (sou > (maisuu - 1) / 2 && maisuu != 5) {
                sou -= (maisuu + 1) / 2;
                pat += (maisuu + 3) / 4;
            }
            else if (maisuu != 5) {
                sou--;
            }
            else if (sou > 4) {
                pat += 3;
                break;
            }
            else {
                pat += sou - 1;
                break;
            }
        }
    }
         
    cout << pat << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    f(n - 2){
        if(s.substr(i,3) == "ABC"){
            ans++;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

lli comb(lli n, lli r, vector<vector<lli>> &v);

int main(){
    lli n, k;
    cin >> n >> k;

    vector<lli> row(n + 1, -1);
    vector<vector<lli>> v(n + 1, row);
    const int num_red = n - k;
    const int num_of_gap = num_red + 1;

    for(int i = 1; i <= k; ++i){
        lli out = (comb(num_of_gap, i, v) % MOD_CONST) * (comb(k - 1, i - 1, v) % MOD_CONST) % MOD_CONST;
        cout << out << endl;
    }

    return 0;
}

lli comb(lli n, lli r, vector<vector<lli>> &v){
    if(n < 0){
        return 0;
    }

    if(v[n][r] >= 0){
        return v[n][r];
    }else if(n < r){
        return v[n][r] = 0;
    }else if(r == 0){
        return v[n][r] = 1;
    }else if(r * 2 > n){
        return v[n][r] = comb(n, n - r, v) % MOD_CONST;
    }else{
        return v[n][r] = comb(n - 1, r - 1, v) % MOD_CONST + comb(n - 1, r, v) % MOD_CONST;
    }
}

Measured memory_bytes: 31744
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>

using namespace std;


int V;


int otsuri(int value)
{
	value = value - V;
	int rtn = 0;

	rtn += value / 500;
	value %= 500;

	rtn += value / 100;
	value %= 100;

	rtn += value / 50;
	value %= 50;

	rtn += value / 10;

	return rtn;
}
bool flag = false;

bool solve()
{
	cin >> V;
	if (V == 0) { return false; }

	if (flag) { cout << endl; }
	flag = true;

	vector<int> ans{0,0,0,0};
	int ansD = -1000000, ansS = 100000000;

	int N10, N50, N100, N500;
	cin >> N10 >> N50 >> N100 >> N500;

	for (int _10 = 0; _10 <= N10; ++_10)
		for (int _50 = 0; _50 <= N50; ++_50)
			for (int _100 = 0; _100 <= N100; ++_100)
				for (int _500 = 0; _500 <= N500; ++_500)
				{
					int sum = _10 + _50 + _100 + _500;
					int value = 10 * _10 + 50 * _50 + 100 * _100 + 500 * _500;
					if (V > value)continue;

					int D = sum - otsuri(value);
					if (D < ansD)continue;
					if (D > ansD)
					{
						ansD = D;
						ansS = sum;
						ans = vector<int>{ _10,_50,_100,_500 };
						/*
						cout << "\n *** " << endl;
						cout << _10 << " " << _50 << " " << _100 << " " << _500 << endl;
						cout << sum << " " << otsuri(value) << " " << D <<  endl;
						*/
						continue;
					}

					if (sum >= ansS)continue;

					ansD = D;
					ansS = sum;
					ans = vector<int>{ _10,_50,_100,_500 };
					/*
					cout << "\n *** " << endl;
					cout << _10 << " " << _50 << " " << _100 << " " << _500 << endl;
					cout << D << " " << sum << endl;
					*/
					continue;
				}
	
	if (ans[0] != 0)
	{
		cout << 10 << " " << ans[0] << endl;
	}
	if (ans[1] != 0)
	{
		cout << 50 << " " << ans[1] << endl;
	}
	if (ans[2] != 0)
	{
		cout << 100 << " " << ans[2] << endl;
	}
	if (ans[3] != 0)
	{
		cout << 500 << " " << ans[3] << endl;
	}
	return true;
}


int main()
{
	while (solve());
	


	return 0;
}


Measured memory_bytes: 3036
n=int (input())
k=int (input())
x= list(map(int, input().strip().split()))
t=0
for i in range(n):
    #print(x[i])
    a=2*x[i]
    b=abs(2*(k-x[i]))
    #print(a,b)
    t+=min(a,b)
print(t)

Measured memory_bytes: 9028
N = int(input())
A = list(map(int, input().split()))
k = 0 in A
flag = True
ans = 1
if k:
  print(0)
else:
  for i in range(N):
    ans *= A[i]
    if ans > 10**18:
      flag = False
      break

  if flag:
    print(ans)
  else:
    print(-1)

Measured memory_bytes: 84540
n = int(input())
s1= input()
ss1 = list(map(lambda x:int(x), s1.split()))

sum = 0

ss1 = [ss1[0]] + ss1 +[ss1[-1]]

for i in range(1,n+1):

    sum += min(ss1[i-1],ss1[i])
print(sum)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



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

int a,b;

int main(){
    cin >> a >> b;
    if( a <= 9 && b <= 9 && b > 0 && a >0){
        cout << a*b << endl;
    }
    else cout << -1 << endl;


return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
int main() {
  int w,h,c,a,b,g;
  cin >> w >> h >> c;
  a = w,b = h;
  if(a < b) {
    int v = a;
    a = b;
    b = v;
  }
  int r;
  while ((r = a % b)) {
      a = b;
      b = r;
  }
  g = b;
  cout << (w/g)*(h/g)*c << endl;
}


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

int main() {
	int n;
	int a[1000];

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

	for (int i = n; i >= 1; i--) {
		cout << a[i];
		if (i != 1)
			cout << " ";
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

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

			int maxr = n / r;
			int maxg = n / g;
			int maxb = n / b;
			int x = 0;
			for (int rn = 0; rn <= maxr; rn++) {
				int rv = r * rn;
				if (rv > n) {
					break;
				}
				if (rv == n) {
					x++;
					break;
				}
				for (int gn = 0; gn <= maxg; gn++) {
					int rgv = g * gn + rv;
					if (rgv > n) {
						break;
					}
					if (rgv == n) {
						x++;
						break;
					}
					if ((n - rgv) % b == 0) {
						x++;
					}
				}
			}
			System.out.println(x);
		}
	}
	
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif
const double pi = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	ll L;
	cin >> N >> L;
	V<double> T(N); rep(i,N) cin >> T[i], T[i] *= 2 * pi / L;
	double X = 0, Y = 0;
	rep(i,N) for(int j=i+1;j<N;j++){
		ll n = N-1-j;
		X += cos((T[i]+T[j])/2) * n;
		Y += sin((T[i]+T[j])/2) * n;
	}
	rep(i,N) for(int k=i+2;k<N;k++){
		ll n = k-i-1;
		X -= cos((T[i]+T[k])/2) * n;
		Y -= sin((T[i]+T[k])/2) * n;
	}
	rep(j,N) for(int k=j+1;k<N;k++){
		ll n = j;
		X += cos((T[j]+T[k])/2) * n;
		Y += sin((T[j]+T[k])/2) * n;
	}
	X /= (ll)(N) * (N-1) * (N-2) / 6;
	Y /= (ll)(N) * (N-1) * (N-2) / 6;
	cout << X << " " << Y << endl;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}
signed main()
{
    double T, X;
    cin >> T >> X;
    cout << fixed << setprecision(10) << T / X << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int n = kbd.nextInt();
        String temp = kbd.next();
        String[] arr = temp.split("");
        int countR = 0;
        int countB = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i].equals("R")) {
                countR++;
            } else {
                countB++;
            }
        }
        if (countR > countB) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
def main():
    N,K = map(int,input().split())

    MAX = (N-1) * (N-2) //2
    if K>MAX:
        print(-1)
        return

    extra_edges = MAX - K
    graph = []
    # スター(距離2の辺の数を最大にする)
    for i in range(2,N+1):
        graph.append([1,i])
    # 距離2の頂点同士を繋ぐ
    cnt = 0
    for i in range(2,N):
        for j in range(i+1,N+1):
            if cnt >= extra_edges:
                continue
            graph.append([i,j])
            cnt += 1
    print(len(graph))
    for x,y in graph:
        print(x,y)

if __name__ == "__main__":
    main()

Measured memory_bytes: 43376
import sys
h,w = map(int,input().split())
ls = [list(input()) for _ in range(h)]
i = 0
j = 0
while True:
    flag = False
    if i > 0:
        if ls[i-1][j] == "#":
            print("Impossible")
            sys.exit()
    if i < h-1:
        if ls[i+1][j] == "#":
            if flag == False:
                flag = True
                ls[i][j] = "."
                nx = [0,1,0,0]
            else:
                print("Impossible")
                sys.exit()
    if j > 0:
        if ls[i][j-1] == "#":
            print("Impossible")
            sys.exit()
    if j < w-1:
        if ls[i][j+1] == "#":
            if flag == False:
                flag = True
                ls[i][j] = "."
                nx = [0,0,0,1]
            else:
                print("Impossible")
                sys.exit()
    if i == h-1 and j == w-1:
        break
    if nx[1] == 1:
        i += 1
    else:
        j += 1
print("Possible")
    

Measured memory_bytes: 9168
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int kisu;
		int gusu;

		if (K%2 == 0) {
			System.out.println((K/2)*(K/2));
		} else {
			System.out.println(((K/2)+1)*(K/2));
		}
	}

}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
typedef long long ll;
template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  string s;
  cin >> s;
  if (s == "ABC") COUT("ARC");
  else if (s == "ARC") COUT("ABC");
  return 0;
}

Measured memory_bytes: 3624
while True:
    (n, x) = [int(i)for i in input().split()]
    if n == x == 0:
        break

    count = 0
    for a in range(1, n + 1 - 2):
        for b in range(a + 1, n + 1 - 1):
            for c in range(b + 1, n + 1):
                if (a + b + c) == x:
                    count += 1
    print(count)

Measured memory_bytes: 6728
my $n = glob<>;
my @h = reverse(glob<>);

for my $i (0 .. ($#h - 1)) {
    if ($h[$i + 1] - $h[$i] == 1) {
        $h[$i + 1]--;
        next;
    } elsif ($h[$i + 1] <= $h[$i]) {
        next;
    }
    print('No');
    exit;
}

print('Yes')

Measured memory_bytes: 27008
#include <stdio.h>
#include <stdlib.h>

int com(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(){
	int n,k,i,data[51]={0},t=0;
	
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	
	qsort(data,n,sizeof(int),com);
	
	for(i=0;i<k;i++){
		t+=data[i];	
	}
	
	printf("%d\n",t);
	
return 0;
}

Measured memory_bytes: 128
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let s: String = read();
    let cv: Vec<char> = s.chars().collect();

    let l = cv.len();
    let mut ans = 0;
    for i in 0..l {
        if i >= l - 1 - i {
            break;
        }
        if cv[i] != cv[l - 1 - i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdbool.h>
#include<vector>
using namespace std;

int main(){
    vector<int> a(5);
    for(int i = 0; i<5; i++){
    cin >> a[i]; 
    }
    int k;
    cin >> k;
    if(a[4]-a[0]<=k){
        cout << "Yay!";
    }
    else{
        cout << ":(";
    }

}

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

using namespace std;
using ll = long long;

int const N = 100 * 1000 + 16;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n;
  cin >> n;
  string str;
  cin >> str;

  int o = 0;
  int c = 0;
  string p, s;
  for(int i = 0; i < n; ++i) {
    int x = (str[i] == '(');
    if(x)
      o++;
    else if(o)
      o--;
    else
      p += "(";
  }

  while(o--)
    s += ")";


  cout << p + str + s << endl;
}

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

using namespace std;

string S;
int C[30] = {0};
bool flag = true;

int main(){
    cin >> S;

    for(int i = 0; i < S.size(); i++) C[S[i]-'a']++;

    for(int i = 0; i < 26; i++)
        if(C[i] % 2 != 0) flag = false;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int a, b;

bool check(int x) {
    if(x <= b + 1) {
        if(x * (b + 1) < a * b) return true;
        else return false;
    } else {
        int mid = (x + b + 1) / 2;
        if(mid * (x + b + 1 - mid) < a * b) return true;
        else return false;
    }
}

void solve() {
	int q; cin >> q;
    rep(_, q) {
        cin >> a >> b;
        if(a == b) {
            cout << a + b - 2 << endl;
            continue;
        }
        if(a < b) swap(a, b);
        int ok = 0, ng = a;
        while(ng - ok > 1) {
            int mid = (ok + ng) / 2;
            if(check(mid)) ok = mid;
            else ng = mid;
        }
        cout << ok + b - 1 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3552
import scala.io.StdIn

object Main extends App {
  val Array(a, b) = StdIn.readLine.split(" ").map(_.toInt)
  val ans = if((a%3) == 0 || (b%3) == 0 || ((a+b)%3) == 0) "Possible" else "Impossible"
  println(ans)
}

Measured memory_bytes: 25548
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s[3]={"Sunny","Cloudy","Rainy"};
    string s1;
    cin>>s1;
    for(int i=0;i<3;i++)
    {
        if(s1==s[i])
            cout<<s[(i+1)%3];
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<long long,long long> P;



int main(){
	int N,K;
	long long x[50],y[50];

	scanf("%d %d", &N, &K);
	for(int i=0;i<N;i++){
		scanf("%lld %lld", &x[i], &y[i]);
	}

	P p[50];
	for(int i=0;i<N;i++){
		p[i] = make_pair(x[i],y[i]);
	}
	sort(x,x+N);
	sort(y,y+N);
	sort(p,p+N);

	long long ans = 1e18*4;

	for(int l=0;l<N;l++){
		for(int r=l+1;r<N;r++){
			for(int a=0;a<N;a++){
				for(int b=a+1;b<N;b++){
					int num = 0;
					long long left = x[l];
					long long right = x[r];
					long long above = y[b];
					long long below = y[a];
					for(int i=0;i<N;i++){
						if(left<=p[i].first && p[i].first<=right){
							if(below<=p[i].second && p[i].second<=above){
								num++;
							}
						}
					}
					if(num>=K){
						if(ans > (right-left)*(above-below)){
							ans = (right-left)*(above-below);
						}
					}
				}
			}
		}
	}

	printf("%lld\n", ans);

	return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

struct UnionFind{
    vector<int> par; // par[i]:iの親の番号
    vector<int> s; // s[i]:iの属する木のノード数
    int n_group; // 木の数
    
    UnionFind(int N) : par(N) {
        for(int i=0; i<N; i++) par[i] = i;
        s.assign(N, 1);
        n_group = N;
    }
    
    int root(int x){ // xが属する木の根
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){ // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        s[ry] += s[rx];
        s[rx] = 0;
        n_group--;
    }
    
    bool same(int x, int y){ // xとyが同じ木に属するかどうか
        return root(x) == root(y);
    }

    int size(int x){ // xが属する木のノード数
        return s[root(x)];
    }
};

void Main(){
    int N,M; cin >> N >> M;
    UnionFind uf(N);
    REP(i,M){
        int a,b; cin >> a >> b; a--; b--;
        uf.unite(a,b);
    }

    int ans = 0;
    REP(i,N) chmax(ans, uf.size(i));
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 11016
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				int size = list.size();
				System.out.printf("%d\n", list.get(size - 1));
				list.remove(size - 1);
			} else{
				list.add(n);
			}
		}
	}
}

Measured memory_bytes: 26348
import static java.lang.Math.max;
import static java.lang.Math.min;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt(), d = scanner.nextInt();
			System.out.println(max(min(b, d) - max(a, c), 0));
		}
	}
}


Measured memory_bytes: 35528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n, k;
  cin >> n >> k;

  if (2 * k - n - 1  > 0) {
    cout << -1 << endl;
    return 0;
  }

  vector<pair<int, int>> p(n);

  int bi = 2 * n;
  rep(i, n) {
    if (bi < k + n) {
      bi = k + 2 * n - 1;
    }
    p[i].second = bi;
    bi--;
  }

  int ai = k;
  rep(i, n) {
    if (ai >= k + n) {
      ai = k + 1;
      if (n % 2 == 0) {
        p[i].first = k + n - 1;
        continue;
      }
    }
    p[i].first = ai;
    ai += 2;
  }

  rep(i, n) {
    cout << p[i].first << " " << p[i].second << " " << k + 2 * n + i << endl;
  }
  
  

  


  
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}



void solve(){
    int n;
    cin>>n;
    cout<<(n>=30?"Yes":"No")<<endl;
}


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

    solve();
    //loopSolve;

	return 0;
}


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

#define MAX_N 100002

using namespace std;

bool mark[MAX_N][3];
long long start;
long long eend;
long long res=-1;
vector<long long> G[MAX_N];
long long n,m;
queue<long long> q;
long long idx,stat,cnt;
void solve()
{
    mark[start][0]=true;
    q.push(start);q.push(0);q.push(0);
    while(!q.empty()){
        idx=q.front();q.pop();
        stat=q.front();q.pop();
        cnt=q.front();q.pop();
        if(idx == eend && stat == 0){
            if(res<0)res=cnt;
            else res = min(res,cnt);
        }
        for(auto& e:G[idx]){
            if(!mark[e][(stat+1)%3]){
                q.push(e);
                q.push((stat+1)%3);
                if(stat==2)q.push(cnt+1);
                else q.push(cnt);
                mark[e][(stat+1)%3]=true;
            }
        }
    }
    
}

int main()
{
    long long a,b;
    cin>>n>>m;
    for(long long i = 0;i<m;i++){
        cin>>a>>b;
        G[a].push_back(b);
    }
    cin>>start>>eend;
    solve();
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 6016
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n; int x[100000]; ll k;
int s[100000];
bool can(int mid) {
	int sum[100001];
	sum[0] = 0;
	ll cnt = 0;
	rep(i, n) {
		if (x[i] <= mid)sum[i + 1] = sum[i] + 1;
		else sum[i + 1] = sum[i] - 1;
	}
	int bit[1 << 19] = {};
	int ccnt[1 << 18] = {};
	rep(j, n + 1) {
		for (int i = sum[j] + n; i > 0; i -= i & -i) {
			cnt += bit[i];
		}
		for (int i = sum[j] + n + 1; i <= 2 * n + 2; i += i & -i)bit[i]++;
	}
	if (cnt >= k)return true;
	else return false;
}
int main(){
	cin >> n; rep(i, n)cin >> x[i];
	k = (ll)n*(n + 1) / 2; k /= 2; k++;
	int le = 0; int ri = n;
	rep(i, n)s[i] = x[i]; sort(s, s + n);
	while (ri - le > 1) {
		int mid = (ri + le) / 2;
		if (can(s[mid]))ri = mid;
		else le = mid;
	}
	if (n == 1) {
		ri = 0;
	}
	cout << s[ri] << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a<b&&b<c)putout("Yes");
    else putout("No");
    
    return 0;
}



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

typedef unsigned long long LL;
const int N = 200007;

void solve ()
{
    int n;
    scanf("%d", &n);
    int c = 0;

    for(int i = 1; i <= n; i++){
        if(i == 105 || i == 135 || i == 165 || i == 189 || i == 195)
            c++;
    }
    cout << c;
    // 105, 135, 165, 189, 195,
}


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



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> val(1e+5 + 10, 0);
 
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        val[a] += b;
    }
 
    ll ans;
    for (int i = 1; i <= 1e+5+10; i++) {
        k -= val[i];
        if (k <= 0) {
            ans = i;
            break;
        }
 
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4044
import java.io.*;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int t=sc.nextInt();
    long k=sc.nextLong();
    int arr[]=new int[t];
    int vis[]=new int[t];
    for(int i=0;i<t;i++){
      arr[i]=sc.nextInt()-1;
      vis[i]=0;
    }
    int count=0;
    int curr=0;
    int prev=0;
    int flag=-1;
    while(k!=0)
    {
      if(vis[curr]==0)
      {        
      vis[curr]=1;
      prev=curr;
      curr=arr[curr];
      k--;
      continue;}
      else
      {
        count++;
        k--;
        prev=curr;
        if(flag==-1)
          flag=curr;
        else if(curr==flag)
          break;       
        curr=arr[curr];
        continue;}
        
  }
    //System.out.println(flag);
    //System.out.println(count);
    //System.out.println(k);
    count=count-1;
    int pos=-1;
    if(count>0 && k!=0)
    {
      k=k+1;
      if(k%count==0)
     	 pos=prev+1;
      else{
           //System.out.println("here");
        k=k%count;
      	while(k!=0)
        {
          curr=arr[curr];
          k--;
        }
        pos=curr+1;}
    }
    else if(k==0)
        pos=curr+1;
    System.out.println(pos);
}
}

Measured memory_bytes: 61104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
vector<vector<vector<ll>>> dp(11,vector<vector<ll>>(10,vector<ll>()));

int main(){
  int k;
  cin >> k;
  int c = 0;
  rep(i,10) {
    dp[0][i].push_back(i);
    if(i > 0) c++;
    if(c == k) {
      cout << i << endl;
      return 0;
    }
  }
  for(int i = 1; i <= 10; i++) {
    rep(j,10) {
      if(j-1 >= 0) {
        for(auto x : dp[i-1][j-1]) {
          ll a = (ll)j*pow(10,(ll)i) + x;
          dp[i][j].push_back(a);
          if(j > 0) c++;
          if(c == k) {
            cout << a << endl;
            return 0;
          } 
        }
      }
      for(auto x : dp[i-1][j]) {
        ll a = (ll)j*pow(10,(ll)i) + x;
        dp[i][j].push_back(a);
        if(j > 0) c++;
        if(c == k) {
          cout << a << endl;
          return 0;
        } 
      }
      if(j+1 <= 9) {
        for(auto x : dp[i-1][j+1]) {
          ll a = (ll)j*pow(10,(ll)i) + x;
          dp[i][j].push_back(a);
          if(j > 0) c++;
          if(c == k) {
            cout << a << endl;
            return 0;
          } 
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1280
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W = mapint()
As = [list(input()) for _ in range(H)]
dist = [[10**18]*W for _ in range(H)]
dirc = ((-1, 0), (1, 0), (0, -1), (0, 1))

from collections import deque
def bfs(start_lis):
    Q = deque()
    for sy, sx in start_lis:
        dist[sy][sx] = 0
        Q.append((sy, sx))
    while Q:
        y, x = Q.popleft()
        for dy, dx in dirc:
            ny, nx = y+dy, x+dx
            if ny>=H or ny<0 or nx>=W or nx<0:
                continue
            if dist[ny][nx]>dist[y][x]+1:
                dist[ny][nx] = dist[y][x]+1
                Q.append((ny, nx))

start_lis = []
for h in range(H):
    for w in range(W):
        if As[h][w]=='#':
            start_lis.append((h, w))
bfs(start_lis)
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, dist[h][w])
print(ans)

Measured memory_bytes: 191676
/* ***********************************************
Author        :axp
Created Time  :2016/9/11 20:19:55
TASK		  :D.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int inf = 1<<30;
const int md = 1e9+7;
const int N = 1e5+10;
ll tot;
int n,w,h;
pii ar[N];
int T;
int ans[10];
map<pii,int> mp;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d%d%d",&w,&h,&n);
	int x,y;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		for(int dx=max(3,x);dx<=min(x+2,w);dx++)
			for(int dy=max(3,y);dy<=min(h,y+2);dy++)
				mp[make_pair(dx,dy)]++;
	}
	for(map<pii,int>::iterator it=mp.begin();it!=mp.end();it++)ans[it->second]++;
	tot=1ll*(h-2)*(w-2);
	for(int i=1;i<=9;i++)tot-=ans[i];
	printf("%lld\n",tot);
	for(int i=1;i<=9;i++)printf("%u\n",ans[i]);
    return 0;
}


Measured memory_bytes: 56448
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i = 1;
  while(++i <=n){
      int x = i;
    if( x % 3 == 0){
      cout << " " << i;
      continue;
    }  
    while(x){
        if( x % 10 == 3){
            cout << " " << i;
            break;
        }
        x /=10;
    }  
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3088
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    d = dict()
    for i in range(N):
        k, v = input().split()
        v = int(v)
        if k in d:
            d[k].append((i + 1, v))
        else:
            d[k] = []
            d[k].append((i + 1, v))

    sd = sorted(d.items(), key=lambda x: x[0])
    for i in range(len(sd)):
        sd[i][1].sort(key=lambda x: x[1], reverse=True)

    # print(sd)
    for sdl in sd:
        for r in sdl[1]:
            print(r[0])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    ll flag=0;
    rep(i,N){
        char s;
        cin>>s;
        if(s=='Y'){
            flag=1;
        }
    }
    if(flag==1){
        cout<<"Four"<<endl;
    }else{
        cout << "Three" << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N ; cin >> N;
vector <char> vec;


for (int i =0; i<11; i++){ 
        long long a =N/26;
		int b = N%26;
		if (b == 0) b =26;
  		b += 96;
		char c=b;
		vec.push_back (c);
		
  		N /= 26;
  		if (b == 122)N--;
		if (a == 0) break;
		if (a==1 && b==122) break;}
	
int size  = vec.size();

for (int j=0; j < size ; j++ )
	cout<< vec.at (size - j - 1) ;
	
	
	
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N;
    vector<ll> Xs;
    cin >> N;
    Xs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Xs));

    vector<ll> v(N / 2 + 1);
    partial_sort_copy(begin(Xs), end(Xs), begin(v), end(v));
    auto a1 = v[N / 2 - 1];
    auto a2 = v[N / 2];

    for (auto x : Xs) {
        cout << ((x <= a1) ? a2 : a1) << "\n";
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
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;
}

const ll MAX_N = 52;
const ll MAX_X = 1e+13;

ll N, X;
vector<ll> a(MAX_N);
vector<ll> p(MAX_N);

ll solve(ll n, ll x) {
    if (n == 0) {
        if (x <= 0) return 0;
        else return 1;
    }
    else if (x <= 1 + a[n - 1]) {
        return solve(n - 1, x - 1);
    }
    else
        return p[n - 1] + 1 + solve(n - 1, x - 2 - a[n - 1]);
}

int main(){
    cin >> N >> X;
    a[0] = 1;
    p[0] = 1;
    rep(i, N) {
        a[i + 1] = 2 * a[i] + 3;
        p[i + 1] = 2 * p[i] + 1;
    }
    // view(a);
    // view(p);
    ll ans = solve(N, X);
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())

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

minimum = []

m = arr[0]
for i in range(n):
	if arr[i] < m :
		m = arr[i]
		minimum.append(m)

	else:
		minimum.append(m)
ans = float("-inf")
for i in range(1,n):
	ans = max(ans,arr[i] - minimum[i-1])

print ans


Measured memory_bytes: 18716
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

wa = sum(B)
for i in range(N-1):
    if A[i+1] - A[i] == 1:
        wa += C[A[i]-1]
print(wa)

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int ar[100000];
  for(int i = 0; i < N; i++)cin >> ar[i];
  sort(ar, ar + N);
  if(ar[N - 1] == 0){
  	cout << "Yes" << endl;
    return 0;
  }
  if(N % 3 != 0){
  	cout << "No" << endl;
    return 0;
  }
  if((ar[N / 3 - 1] == 0 && ar[N / 3] == ar[N - 1]) || 
    (ar[N / 3 - 1] == ar[0] && ar[N / 3 * 2 - 1] == ar[N / 3] && ar[N - 1] == ar[N / 3 * 2]
    && ((ar[0] ^ ar[N / 3]) ^ ar[N * 2 / 3]) == 0)){
  	cout << "Yes" << endl;
   	return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
def F0_N(N):
  if N % 4 == 0:
  	return N
  elif N % 4 == 1:
    return 1
  elif N % 4 == 2:
     return N + 1
  elif N % 4 == 3:
     return 0

A, B = map(int, input().split())

print(F0_N(A-1) ^ F0_N(B))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template<typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v)
{
    if (v.size() > 0) {
        v.erase(v.begin());
    }
}
template<typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
    if (v.size() > 0) {
        v.erase(v.begin()+v.size()-1);
    }
}

bool isprime(ll n)  //IN  O(sqrt(n))
{
    if(n<=1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;

    return true;
}

vector<ll> factors(ll n){    //IN  O(sqrt(n))

    vll v;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            if((n/i)!=i)
            v.pb(n/i);
        }
    }
    return v;
}

ll power(ll a, ll n)  // using Binary Exponential in TC O(logn)
{                     // Self Written By </ME> :)
    ll res=1;
    while(1)
    {
        if(n%2){
            res=res*a; n--;
        }
        if(n==0) break;
        a=a*a; n/=2;
    }
    return res;
}


int main() {

    fio;
    map<string,int>mp;
    ll n; cin>>n;
    rep(i,0,n)
    {
        string s; cin>>s;
        mp[s]++;
    }

    int maxa=INT_MIN;
    for(auto x: mp)
    {
        maxa=max(maxa,x.second);
    }

    for(auto x: mp)
    {
        if(x.second==maxa)
            cout<<x.first<<"\n";
    }

      
    return 0;
}


Measured memory_bytes: 23808