akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

template <typename T>
struct segtree{
	//元データx[i]はv[n+i]
	//v[i]の親はv[i/2],子はv[i*2]とv[i*2+1]
	vector<T> v;
	int n;
	
	const T init_value = 0;
	
	segtree(vector<T> &x){
		n=1;
		while(true){
			if(n>=x.size())break;
			n*=2;
		}
		v.resize(2*n,init_value);
		
		for(int i=0;i<x.size();i++){
			v[n+i]=x[i];
		}
		for(int i=n-1;i>=0;i--){
			v[i]=func(v[i*2],v[i*2+1]);
		}
	}

	void update(int x,T val){
		x+=n;
		v[x]=val;
		while(true){
			x=(x)/2;
			v[x]=func(v[x*2],v[x*2+1]);
			if(x<=0)break;
		}
	}
	
	//区間[l,r)におけるクエリ処理
	T query(int l,int r){
		T res = init_value;
		l+=n;r+=n;
		while(true){
			if(l%2==1){
				res=func(v[l],res);
				l++;
			}
			if(r%2==1){
				res=func(v[r-1],res);
				r--;
			}
			if(l>=r)break;
			l/=2;r/=2;
		}
		return res;
	}
	T func(T a,T b){
		return max(a,b);
	}
	
	void show(){
		int n = 1;
		for(int i=1;i<v.size();i++){
			for(int j=0;j<n;j++){
				if(j!=0)cout<<' ';
				cout<<v[i+j];
			}
			cout<<endl;
			i+=n-1;
			n*=2;
		}
	}
	
};


int main(){
	int N;
	cin>>N;
	vector<long long> h(N),A(N);
	
	for(int i=0;i<N;i++){
		cin>>h[i];
		h[i]--;
	}
	vector<long long> K;
	for(int i=0;i<N;i++){
		cin>>A[i];
		K.push_back(0);
	}
	
	segtree<long long> S(K);
	
	long long ans = 0;
	
	for(int i=0;i<N;i++){
		long long a = S.query(0,h[i])+A[i];
		ans = max(a,ans);
		
		S.update(h[i],a);
	}
	
	cout<<ans<<endl;
			
		
	
	return 0;
}


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
 
int main(){
long long L, R;  cin >> L >> R;

int ans = 2018; 
for (int i = L; i < R; i++) {
    for (int j = i + 1; j <= R; j++) {
        int tmp = (i % 2019) * (j % 2019) % 2019;
        if (tmp == 0) {
            cout << '0' << endl;
            return 0;
        }
        ans = min(ans, tmp);
    }
}

cout << ans << endl;

}

Measured memory_bytes: 256
/*


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

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

int main()
{
    
   int n,m;
   cin>>n>>m;
   //cout<<endl;
   vector<pair<int,int>> all;
   REP(i,n)
   {
       int a;
       cin>>a;
       all.push_back(make_pair(a,1));
   }
   REP(i,m)
   {
       int b,c;
       cin>>b>>c;
       all.push_back(make_pair(c,b));
   }
   sort(all.begin(),all.end(),greater<pair<int,int>>());
   //cout<<endl;

   // REP(i,n+m)
   // {
   //     cout<<all.at(i).first<<" "<<all.at(i).second<<endl;
   // }
   //cout<<endl;

   int64_t ans=0;
   int j=0;
   REP(i,n)
   {
       if(all.at(j).second<=0)
       {
           j++;
           i--;
       }
       else
       {
           ans+=all.at(j).first;
           all.at(j).second--;
       }  
       //cout<<"j="<<j<<"i="<<i<<endl;
       //cout<<ans<<endl;
       //cout<<endl;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef pair<double, pdd> pddd;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char g[105][105];
bool ignoreR[105];
bool ignoreC[105];

int main() {
    int r, c;
    scanf("%d%d\n", &r, &c);
    for(int i = 0; i < r; i++) {
        scanf("%s", g[i]);
    }
    for(int i = 0; i < r; i++) {
        ignoreR[i] = true;
        for(int j = 0; j < c; j++) {
            if(g[i][j] == '#') ignoreR[i] = false;
        }
    }
    for(int j = 0; j < c; j++) {
        ignoreC[j] = true;
        for(int i = 0; i < r; i++) {
            if(g[i][j] == '#') ignoreC[j] = false;
        }
    }
    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++) {
            if(ignoreR[i] || ignoreC[j]) continue;
            printf("%c", g[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
/// Template by Zayed ///

///************************************************************///
/// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>

#include <string>
#include <cstring>
#include <sstream>

#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
//#include<unordered_map>
#include <set>
//#include<unordered_set>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
///************************************************************///
using namespace std;
int caseno = 1;
///************************************************************///
#define NL '\n'
#define SF scanf
#define PF printf
#define PC() printf("Case %d: ", caseno++)//NOTES:printf
//#define PC cout << "Case "//NOTES:cout
//#define CN cout << caseno++ << ": "//NOTES:cout
#define CLR(ar) memset(ar, 0, sizeof(ar))
#define SET(ar) memset(ar, -1, sizeof(ar))
#define READ() freopen("input.txt", "r", stdin)
#define WRITE() freopen("output.txt", "w", stdout)
#define BOOST std::ios_base::sync_with_stdio(0);
///************************************************************///
typedef long long LL;//NOTES:"%lld"
typedef unsigned long long ULL;//NOTES:"%llu"
///************************************************************///
#define INF (1 << 31) - 1
#define MOD 1000000007
#define pii pair<int, int>
#define pic pair<int, char>
#define pci pair<char, int>
#define pLL pair<LL, LL>
#define pis pair<int, string>
#define psi pair<string, int>
#define pss pair<string, string>
#define PI 2 * acos(0.0);
#define EPS 1e-11;
///************************************************************///
// Numeric Functions
template < class T > inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline LL POW(LL base, LL power){
	LL I, res = base; if (power == 0) return 1;
	for (I = 0; I < power - 1; I++) res *= base; return res;
}
// Translator Functions
int ToInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToInt(
double ToDouble(string s) { double r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToDouble(
string ToString(int n) { string s; stringstream convert; convert << n; s = convert.str(); return s; }//NOTES:ToString(
///************************************************************///

/*
*******4 Direction Array*******
int dx[] = {0, 0, - 1, 1}, dy[] = {-1, 1, 0, 0};
*******8 Direction Array*******
int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};
********Knight Moves********
int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1};
*/

const int SIZE = 1e6;



int main()
{
	BOOST
	///READ();
	///WRITE();
	int tcases, I, J, K, N, n, m, cnt = 0, len, A, B;
	cin >> A >> B;
	cout << (A + B) % 24 << NL;

	return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

struct Card {
  ll n, cnt;
};

bool cmp(const Card &a, const Card &b) {
  if (a.n == b.n) {
    return a.cnt > b.cnt;
  }
  return a.n > b.n;
}

ll N, M;
vector<Card> v;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  v.resize(N + M);
  for (int i = 0; i < N; i++) {
    ll ai;
    cin >> ai;
    v[i] = Card{ai, 1};
  }
  for (int i = 0; i < M; i++) {
    ll bi, ci;
    cin >> bi >> ci;
    v[N + i] = Card{ci, bi};
  }

  sort(v.begin(), v.end(), cmp);

  ll ans = 0;
  ll cnt = 0;
  for (int i = 0; i < N + M; i++) {
    if (cnt + v[i].cnt == N) {
      ans += (v[i].n * v[i].cnt);
      break;
    } else if (cnt + v[i].cnt > N) {
      ll c = N - cnt;
      ans += (v[i].n * c);
      break;
    } else {
      ans += (v[i].n * v[i].cnt);
      cnt += v[i].cnt;
    }
  }

  cout << ans << endl;
  return 0;
}

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

int main() {
	int a, b;
	for (;;) {
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		if (a < b)cout << a << " " << b << endl;
		else cout << b << " " << a << endl;
	}
}


Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    double X;
    cin >> X;

    double mon = 100;
    int y = 0;
    while (mon < X)
    {
        y++;
        mon = mon + (long long)(mon * 0.01);
    }

    cout << y << endl;
    
    return 0;
}

Measured memory_bytes: 3720
n = 20
a = 2
b = 5

i = input()
d = i.split()
n = int(d[0])
a = int(d[1])
b = int(d[2])

sum1 = 0

for i in range(1,n+1):
    d = list(str(i))
    sum2 = 0
    for i2 in d:
        sum2 = sum2 + int(i2)
    if(a<=sum2 and sum2<=b):
        sum1 = sum1 + int(i)

print(sum1)


Measured memory_bytes: 3064
def divisor(n):
    i = 1
    res = []
    while i*i <= n:
        if n%i == 0:
            res.append(i)
            if n//i not in res:
                res.append(n//i)
        i += 1
    res.sort()
    return res

def main():
    n, m = map(int, input().split())
    md = divisor(m)
    ans = 0
    for i in md:
        if (m - n*i)%i == 0 and (m - n*i) >= 0:
            ans = i
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int i;
        String line=sc.nextLine();
        String answer="";
        int length=line.length();
        for(i=0;i<length;i++){
            char ch =line.charAt(i);
            if(Character.isLowerCase(ch)==true){
                answer+=Character.toUpperCase(ch);
            }else{
                answer+=Character.toLowerCase(ch);
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 31584
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val sx, sy, tx, ty = sc.nextInt()

    //step1
    step(tx - sx, 'R')
    //step2
    step(ty - sy + 1, 'U')
    //step3
    step(tx - sx + 1, 'L')
    //step4
    step(ty - sy + 1, 'D')
    //step5
    step(1, 'R')

    //step6
    step(ty - sy, 'U')
    //step7
    step(tx - sx + 1, 'R')
    //step8
    step(ty - sy + 1, 'D')
    //step9
    step(tx - sx + 1, 'L')
    //step10
    step(1, 'U')
    println()
  }

  def step(n: Int, w: Char): Unit = {
    for (_ <- 0 until n) print(w)
  }
}

Measured memory_bytes: 33036
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){

    string s; 
    ll N; 
    cin >> N >> s;

    for(ll i = 0; i < s.size(); i++){
        char ss = s[i] + N;
        if(ss > 90){
            ss %= 90;
            ss += 64;
        }
        cout << ss;
    }
    cout << endl;

}

Measured memory_bytes: 256
def main():
    n = int(input())
    A = []
    B = []
    C = {}
    for i in range(n):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        C[str(i)] = a + b
    ans = 0
    isA = True
    for k, v in sorted(C.items(), key=lambda x: -x[1]):
        if isA:
            ans += A[int(k)]
        else:
            ans -= B[int(k)]
        isA = not isA
    print(ans)


if __name__ == "__main__":
    main()


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

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

int main(){
    char a;
    cin >> a;
    if (isupper(a)) cout << 'A' << endl;
    else cout << 'a' << endl;
    
    return 0;
}

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

using namespace std;

int main(){
	int n=0,ct=0, score=0, out=0,run=0;
	string x;
	cin >> n;
	while (1){
		int  score = 0, out = 0, run = 0;
		while (1){
			cin >> x;
			if (x == "OUT"){
				out++;
			}
			if (x == "HOMERUN"){
				score+=run;
				score++;
				run = 0;
			}
			if (x == "HIT"){
				run++;
			}
			if (run > 3){
				run--;
				score++;
			}
			if (out == 3){
				cout << score << endl;
				ct++;
				break;
			}
		}
		if (ct == n)break;
	}
	return 0;

}

Measured memory_bytes: 1208
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		if((s[0]+s[1])%3!=0){
			Console.WriteLine("0");
			return;
		}
		if(((s[0]+s[1])/3-Abs(s[0]-s[1]))<0){
			Console.WriteLine("0");
			return;
		}
		Cb r=new Cb((s[0]+s[1])/3+1);
		Console.WriteLine("{0}",r.C1((s[0]+s[1])/3,((s[0]+s[1])/3-Abs(s[0]-s[1]))/2));
	}
}
public class Cb{
	private const int mod=(int)1e9+7;
	public long[] r;
	public Cb(int n){
		r=new long[n];
		r[0]=1;
		for(int i=1;i<n;i++){r[i]=(r[i-1]*i)%mod;}
	}
	public long C1(long n,long k){return (r[n]*Mi(r[k]*r[n-k]))%mod;}
	public long C2(long n,long k){
		long l=1;
		n%=mod;
		for(int i=1;i<=k;i++){l=(l*(n-i+1))%mod;l=(l*Mi(i))%mod;}
		return l;
	}
	public long P1(long n,long k){return n<k?0:(r[n]*Mi(r[n-k]))%mod;}
	public long Mi(long a){
		a=(a+mod)%mod;
		long b=mod,u=1,v=0;
		while(b>0){long t=a/b;a-=t*b;a^=b;b^=a;a^=b;u-=t*v;u^=v;v^=u;u^=v;}
		u%=mod;
		if(u<0){u+=mod;}
		return u%mod;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 18144
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    if(s[0] == '9' || s[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace B___Some_Sums
{
    class Program
    {
        static void Main(string[] args)
        {
            var N_A_B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = N_A_B[0];
            var A = N_A_B[1];
            var B = N_A_B[2];
            int sum = 0;

            for (int i = 1; i <= N; i++)
            {
                var res = i.ToString().ToCharArray().Select(x => int.Parse(x.ToString())).Sum();

                if (res >= A && res <= B)
                    sum += i;
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
in totval=0;
void ad(multiset<in>& gud, multiset<in>& bad, in& nd, in v){
  if(nd>0){
    --nd;
    gud.insert(v);
    totval+=v;
  }
  else{
    if(v>=*gud.begin()){
      totval+=v;
      gud.insert(v);
      totval-=*gud.begin();
      bad.insert(*gud.begin());
      gud.erase(gud.begin());
    }
    else{
      bad.insert(v);
    }
  }
}
multiset<in>::iterator it;
bool rm(multiset<in>& gud, multiset<in>& bad, in v){
  if(bad.empty())
    return 0;
  in nuv;
  if(v>=*gud.begin()){
    totval-=v;
    gud.erase(v);
    it=bad.end();
    --it;
    nuv=*it;
    totval+=nuv;
    bad.erase(bad.find(nuv));
    gud.insert(nuv);
  }
  else{
    bad.erase(bad.find(v));
  }
  return 1;
}
multiset<in> gldgud,gldbad,slvgud,slvbad;
in ndgld,ndslv;
vector<tuple<in,in,in> > srt;
in bst=-1e18;
in ofs=0;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in tx,ty,tz;
  cin>>tx>>ty>>tz;
  in n=tx+ty+tz;
  ndgld=tz;
  ndslv=ty;
  in a,b,c;
  in g,s;
  forn(zz,n){
    cin>>a>>b>>c;
    ofs+=a;
    g=c-a;
    s=b-a;
    srt.PB(tuple<in,in,in>(s-g,s,g));
    ad(gldgud,gldbad,ndgld,g);
  }
  sort(all(srt));
  reverse(all(srt));
  in df;
  forv(i,srt){
    tie(df,s,g)=srt[i];
    ad(slvgud,slvbad,ndslv,s);
    if(rm(gldgud,gldbad,g)){
      if(ndslv==0)
	bst=max(bst,totval);
    }
    else
      break;
  }
  cout<<bst+ofs<<endl;
  return 0;
}


Measured memory_bytes: 7984
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	nums := make([]int, n)
	for i, _ := range nums {
		fmt.Scan(&nums[i])
	}
	c := 1
	s := 0
	for _, v := range nums {
		s += v
		if s <= x {
			c++
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 512
import sys
readline = sys.stdin.readline
intin = map( int, readline().rstrip().split() )

a , b ,c , x , y  = intin

times = max(x,y)

total = 0
for t in range(times):
    if x > 0 and y > 0 :
        if a + b >= 2 * c :
            total += 2 * c
            x -= 1
            y -= 1
            continue
        else:
            total += a+b
            x -= 1 
            y -= 1
            continue
    elif x > 0 and y <= 0 :
        if a > 2 * c :
            total += 2 * c
            x -= 1
            continue
        else:
            total += a
            x -= 1
            continue
    elif y > 0 and x <= 0 :
        if b > 2 * c :
            total += 2 * c
            y -= 1
            continue
        else:
            total += b
            y -= 1
            continue
    else:
        break

print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to, cap, rev;}; //to, capacity, 反対エッジ
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;

    graph(ll n): N(n), G(N), used(N,false) {}

    void ade(ll s, ll t, ll cap){
        G[s].emplace_back((edge){t, cap, (ll)G[t].size()});
        G[t].emplace_back((edge){s, cap, (ll)G[s].size()-1}); // 無向ならcap
    }

    ll dfs(ll v, ll goal, ll water){
        if(v == goal) return water;
        used[v]=true;
        for(auto& E : G[v]){
            if(!used[E.to] and E.cap > 0){
                ll o_flow = dfs(E.to, goal, min(water, E.cap));
                if(o_flow > 0){
                    E.cap -= o_flow;
                    G[E.to][E.rev].cap += o_flow;
                    return o_flow;
                }
            }
        }
        return 0;
    }

    ll max_flow(ll s, ll g){
        ll flow = 0;
        while(1){
            rep(i,N) used[i] = false;
            ll o_flow = dfs(s, g, INF);
            if (o_flow==0) return flow; //更新がなかったら終了
            flow += o_flow;
        }
    }
};

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    vector<ll> A(M);
    vector<ll> B(M);
    vector<ll> ans(N,0);
    graph g(N);
    rep(i,M) {
        cin>>A[i]>>B[i];
        --A[i],--B[i];
        g.ade(A[i],B[i],1);
        ans[A[i]]++;
        ans[B[i]]++;
    }
    ll ct=0;
    ll ok=false;
    vector<ll> x;
    rep(i,N){
        if(ans[i]%2==1) dame;
        ct+=ans[i]/2-1;
        if(ans[i]/2>=3) ok=true;
        if(ans[i]/2==2) x.emplace_back(i);
    }
    if(ct<=1) dame;

    if(ok or ct>=3){
        cout<< "Yes" <<"\n"; return;
    }

   ll desu= g.max_flow(x[0],x[1]);

   if(desu==2) {
       cout<< "Yes" <<"\n"; return;
   }
    dame;

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 12288
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 100000007
#define INF 1e9
/****************************/
int main()
{
	int k;
	int n;
	cin>>k>>n;
	if(k>=10)
	{
		cout<<n;
	}
	else
	{
		cout<<n+100*(10-k);
	}
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a=n/100;
  int b=n%100;
  if(a>0&&a<13&&b>0&&b<13){
    cout<<"AMBIGUOUS"<<endl;
  }else if(a>0&&a<13){
    cout<<"MMYY"<<endl;
  }
  else if(b>0&&b<13){
    cout<<"YYMM"<<endl;
  }
  else{
    cout<<"NA"<<endl;
  }
}



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

int main() {
  int a,b,c,d,n;
  cin >> n;
  a = n/1000;
  b = n/100-a*10;
  c = n/10-a*100-b*10;
  d = n%10;
  if ((a==b && b==c) || (b==c && c==d)) {
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; bool ooo = 0; template <typename T> ostream& operator << (ostream& _o_, const vector <T> &_v_) { if(!_v_.empty()) {_o_ << '['; copy(_v_.begin(), _v_.end(), ostream_iterator <T> (_o_, ", ")); _o_ << "\b\b]"; } return _o_; } struct Dbg { template <typename T> Dbg& operator, (const T& v) { cerr << v << ", "; return *this; } } Dbg;
#define debug(args...)  if(ooo) { cerr << #args << " = "; Dbg, args; cerr << endl; }

struct point {
	int x, y;
	bool operator < (const point &o) const {
		return x < o.x || (x == o.x && y < o.y);
	}
} a[55];

int n, ans = 0;
map <pair<int, int>, int> m;

signed main() {
	cin >> n;
	for(int i = 1, x, y; i <= n; i++) {
		cin >> x >> y;
		a[i] = {x, y};
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			int p = a[i].x - a[j].x, q = a[i].y - a[j].y;
			if(p || q) m[{p, q}]++;
			debug(p, q);
		}
	}
	for(auto &x : m) {
		debug(x.first.first, x.first.second, x.second);
		ans = max(ans, x.second);
	}
	cout << n - ans;
}


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

const int INF = 1000000000;

int main()
{
	int T[10][10];
	int z=0;
	int a=0;
	int p[10];
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(T[i][j]>T[i][k]+T[k][j]){
						T[i][j]=T[i][k]+T[k][j];
					}
				}
			}
		}
		for(int i=0;i<m;i++){
			p[i]=0;
			for(int j=0;j<m;j++){
				p[i]=p[i]+T[i][j];
			}
		}
		z=p[0];
		for(int i=0;i<m;i++){
				if(z>p[i]){
					z=p[i];
				 a=i;
				}
		}
		
		cout<<a<<" "<<z<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Info{
	Info(ll arg_A){
		A = arg_A;
	}
	Info(){
		A = 0;
	}
	bool operator<(const struct Info &arg) const{

		return A < arg.A;
	}
	ll A;
};

ll N,M;

int main(){

	scanf("%lld %lld",&N,&M);

	ll tmp;
	priority_queue<Info> Q;

	for(int i = 0; i < N; i++){

		scanf("%lld",&tmp);
		Q.push(Info(tmp));
	}

	Info info;

	while(M > 0 && Q.empty() == false){

		info = Q.top();
		Q.pop();

		info.A /= 2;
		M--;

		if(info.A > 0){

			Q.push(info);
		}
	}

	ll ans = 0;

	while(!Q.empty()){

		ans += Q.top().A;
		Q.pop();
	}

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

	return 0;
}


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

using ll=long long;

int main() {
  int N; cin >>N;
  set<int> A;
  rep(i,0,N) {
    int temp; cin >>temp;
    A.insert(temp);
  }
  cout <<((int)A.size()==N ? "YES":"NO") <<endl;
  return 0;
}


Measured memory_bytes: 12928
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//整数の入力
		int N = sc.nextInt();
		//条件分岐
		switch(N%10) {
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			break;
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;
		case 3:
			System.out.println("bon");
			break;
		}
	}

}


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

int main(){
  int N,K,a;
  cin >> N >> K;
  a=1;
  for(int i=0;N>i;i++){
    if(a<K){
      a*=2;
    }else{
      a+=K;
    }
  }  
  cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

vector<int> strz(const string& s) {
	vector<int> z(s.size());
	z[0] = s.size();
	int i = 1, j = 0;
	while (i < s.size()) {
		while (i + j < s.size() && s[i + j] == s[j]) j++;
		z[i] = j;
		if (j == 0) {
			i++;
			continue;
		}

		int k = 1;
		while (i + k < s.size() && k + z[k] < j) {
			z[i + k] = z[k];
			k++;
		}

		i += k;
		j -= k;
	}

	return z;
}

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

	vector<string> table;
	int n; cin >> n;
	string s; cin >> s;

	int ans = 0;
	FOR_LT(i, 0, n) {
		vector<int> z = strz(s.substr(i, n));
		FOR_LT(j, 0, z.size()) {
			ans = max(ans, min(j, z[j]));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

Measured memory_bytes: 3092
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vb v(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        v[i] = a == b;
    }
    rep(i, n - 2) {
        if (v[i] and v[i + 1] and v[i + 2]) {
            Yes(1);
            return 0;
        }
    }
    Yes(0);
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;

    int sum=0;

    if(a+b<2*c)sum=a*x+b*y;
    else{
        sum+=2*c*min(x,y);
        if(x>y)sum+=(x-y)*min(a,c*2);
        else sum+=(y-x)*min(b,c*2);
    }

    cout<<sum<<endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws Exception
	{
	  Scanner sc=new Scanner(System.in);
		Long n=sc.nextLong();
		List<Long> li=new ArrayList<Long>();
		Quadrillion(n);
		
		
	}
	public static void Quadrillion(Long n)
	{
		StringBuffer sb=new StringBuffer();
		while(n>0)
		{
			Long x=n%26;
			if(x==0)
			{
				sb.append('z');
				n=n/26-1;
			}
			else
			{
				sb.append((char)((x-1)+'a'));
				n=n/26;
			}
		}
		 System.out.println(sb.reverse());
	}

}


Measured memory_bytes: 36012
import bisect


A, B, Q = map(int, input().split())
INF = float("inf")
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b = bisect.bisect_right(s, x)
    d = bisect.bisect_right(t, x)
    ans = INF
    for S in (s[b - 1], s[b]):
        for T in (t[d - 1], t[d]):
            d1 = abs(S - x) + abs(T - S)
            d2 = abs(T - x) + abs(S - T)
            ans = min(ans, d1, d2)
    print(ans)


Measured memory_bytes: 14084
#include <stdio.h>
#include <math.h>

#define NO_DATA -1
#define MAX_COUNT 30
int check[999999];
int checkEnd=0;

int isPrime(int n){
    if(n&0b1){
        
    }
    else {
        return 0;
    }
    if(3==n){
        return 1;
    }
    int square_root = (int)sqrt(n);
    for(int i=3; i<=square_root; i+=2){
        if(0==n%i){
            return 0;
        }
    }
    return 1;
}

int countPrimarity(unsigned int n)
{
    int i = 0;
    int count = check[checkEnd];
    for( i=checkEnd+1;i<=n;i+=2 ) {
        if( isPrime(i))
            count++;
        check[i]=count;
        check[i+1]=count;
        checkEnd=i+1;
    }
    return count;
}

int main(int argc, const char * argv[]) {
    unsigned int input;
    int result[MAX_COUNT];
    int scanResult;
    
    for(int cnt=0;cnt<999999;cnt++){
        check[cnt]=NO_DATA;
    }
    check[1]=0;
    check[2]=1;
    checkEnd=2;
    
    scanResult = scanf("%ud", &input);
    int index=0;
    while (scanResult!=EOF) {
        switch (input) {
            case 1:
                result[index]=0;
                break;
            case 2:
                result[index]=1;
                break;
            default:
                if(input<=checkEnd) result[index] = check[input];
                else result[index]=countPrimarity(input);
                break;
        }
        index++;
        scanResult = scanf("%ud", &input);
    }
    
    for (int i=0;i<index;i++) {
        printf("%d\n", result[i]);
    }
    return 0;
}



Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
const int base = 31;
const long long mod = 99999999999999997LL;
long long p[40];
int n;
string s;

int val(char c) {
	return c - 'a';
}

int main(int argc, char const *argv[])
{
	cin >> n;
	cin >> s;
	p[0] = 1;
	for(int i = 1; i <= n+n; i++) {
		p[i] = p[i - 1] * base;
		p[i] %= mod;
	}
	map <long long, int> mp[20];
	for(int i = 0; i < (1 << n); i++) {
		long long sum = 0;
		int p1 = 0;
		int p2 = n-1;
		for(int j = 0; j < n; j++) {
			if((i >> j) & 1) {
				sum += 1LL * val(s[j]) * p[p1++]; 
			} else {
				sum -= 1LL * val(s[j]) * p[p2--];
			}
			sum %= mod;
			if(sum < 0) sum += mod;
		}
		mp[__builtin_popcount(i)][sum] += 1;
	}
	long long ans = 0;
	for(int i = 0; i < (1 << n); i++) {
		long long sum = 0;
		int p1 = n-1;
		int p2 = 0;
		for(int j = n+n-1; j >= n; j--) {
			if((i >> (j - n)) & 1) {
				sum += 1LL * val(s[j]) * p[p1--];
			} else {
				sum -= 1LL * val(s[j]) * p[p2++];
			}
			sum %= mod;
			if(sum < 0) sum += mod;
		}
		sum = (mod - sum) % mod;
		ans += mp[n - __builtin_popcount(i)][sum];
	} 
	cout << ans << endl;
	return 0;
}

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

#define N 100005

int n, p[N], d[N], dp[N];
vector <int> v[N];
int A, B;

void dfs(int k, int pa) {
	dp[k] = dp[pa] + 1;
	d[k] = 1; p[k] = pa;
	for (auto x : v[k]) {
		if (x == pa) continue;
		dfs(x, k);
		d[k] = max(d[k], 1 + d[x]);
	}
	return;
}

int main() {
	scanf("%d %d %d", &n, &A, &B);
	for (int i = 1, x, y; i < n; i ++) {
		scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(B, 0);
	int ans = -1, dist = dp[A] - dp[B];
	bool f = dist & 1;
	dist = (dist - 1) >> 1;
	while (dist --) A = p[A];
	if (v[A].size() == 1) ans = dp[A] - 2;
	else ans = d[A] - 2 + dp[A] - 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16736
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(a+b<c+d)cout<<"Right"<<endl;
  if(a+b==c+d)cout<<"Balanced"<<endl;
  if(a+b>c+d)cout<<"Left"<<endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	if nextInt() < 1200 {
		puts("ABC")
	} else {
		puts("ARC")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

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

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
use std::io::Read;
use std::io::{stdout, BufWriter, Write};

fn main() {
    let mut buf = String::new();

    // stdinから全てbufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 読み込んだ文字列をスペースで分解する
    let mut iter = buf.split_whitespace();

    // about a
    let a: usize = iter.next().unwrap().parse().unwrap();
    // about b
    let b: usize = iter.next().unwrap().parse().unwrap();

    // ans
    let ans: usize = if a >= 13 {
        b
    } else if a >= 6 && a <= 12 {
        b / 2
    } else {
        0
    };

    // 出力
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    writeln!(out, "{}", ans).unwrap();
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a + b > c + d){
        cout << "Left" << endl;
    } else if(a + b < c + d){
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#define big(i, j) (a[i] >= x && a[j] >= x)
#define small(i, j) (a[i] < x && a[j] < x)
using namespace std;

int a[200005];
int n;

inline void in(register int &x){
	register char ch;
	x = 0;
	while(isspace(ch = getchar()));
	do x = x*10 + ch-'0'; while(isdigit(ch = getchar()));
}

bool check(int x){
	for(int i=1; i<n; i++){
		if(big(n-i, n-i+1) || big(n+i, n+i-1)) return true;
		if(small(n-i, n-i+1) || small(n+i, n+i-1)) return false;
	}
	return a[1] >= x;
}

int main(){
//	freopen("at2165.in", "r", stdin);
//	freopen("at2165.out", "w", stdout);
	in(n);
	for(int i=1; i<=n*2-1; i++)
		in(a[i]);
	int l = 1, r = n * 2 - 1, mid, ans;
	while(l <= r){
		mid = (l+r) >> 1;
		if(check(mid)){
//			printf("%d is valid.\n", mid);
			ans = mid;
			l = mid + 1;
		}
		else r = mid - 1;//, printf("%d is invaild.\n", mid);
	}
	printf("%d\n", ans);
	return 0;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    int c1 = h1 * 60 + m1;
    int c2 = h2 * 60 + m2;
    cout << max(c2-c1-k, 0) << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    bool x;
    cin>>x;
    cout<<(int)!x<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
	int n,m,l,i,j,k;
	int A[100][100]={0},B[100][100]={0};
	long int ans;
	scanf("%d %d %d",&n,&m,&l);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}for(j=0;j<m;j++){
		for(k=0;k<l;k++){
			scanf("%d",&B[j][k]);
		}
	}for(i=0;i<n;i++){
		for(k=0;k<l;k++){
			ans = 0;
			for(j=0;j<m;j++){
			ans += A[i][j]*B[j][k];
		}
		if(k==l-1)
		printf("%ld\n",ans);
		else
		printf("%ld ",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 688
#include<stdio.h>
int main()
{
     int a;
     float p;
     scanf("%d",&a);
     if(a%2==0)
     {
         p=(float)(a/2)/a;
         printf("%f",p);
      }
      else
      {
          p=(float)(a/2+1)/a;
          printf("%f",p);
      }
       return 0;
}


Measured memory_bytes: 128
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
////////////////いろいろあるよ//////////////////////////////////
int main(){
    int ans=0;
    ll A,B;
	cin >> A >> B;
  	bool is=false;
    FOR(i,10,1001){
        if(int(i*0.08)==A && int(i*0.1)==B){ans=i;is=true;break;}
    }

	if(is==true)cout << ans << endl;
  else cout << -1 << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void )
{
	int info_num, info_cou, build_cou, step_cou, room_cou;
	int build_num, step_num, room_num, people_num;
	int room[4][3][10] = {};
	
	scanf( "%d", &info_num );
	
	for( info_cou = 0; info_cou < info_num; info_cou++ )
	{
		scanf( "%d %d %d %d\n", &build_num, &step_num, &room_num, &people_num );
		room[build_num - 1][step_num - 1][room_num - 1] += people_num;
	}
	
	for( build_cou = 0; build_cou < 4; build_cou++ )
	{
		for( step_cou = 0; step_cou < 3; step_cou++ )
		{
			for( room_cou = 0; room_cou < 10; room_cou++ )
			{
				printf( " %d", room[build_cou][step_cou][room_cou] );
			}
			printf( "\n" );
		}
		if( build_cou < 3 )
		{
			printf( "####################\n" );
		}
	}
	return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,x;
   std::cin >> n>>x;
   int L;
   int m=0;
   for (int i=1;i<=n;i++){
       std::cin >> L;
       m+=L;
       if(m>x){std::cout << i << std::endl;break;}
       if(i==n)std::cout << n+1 << std::endl;
   }

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
  std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
  }
}

using namespace std;

int main(void) {
  double t, x, result;
  cin >> t >> x;
  
  result = t / x;
  
  cout << fixed << setprecision(10) << result << endl;


  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char num[1001];
    int i, sum;
    
    while (1) {
        scanf("%s", num);
        
        if (num[0] == '0') {
            break;
        }
        
        sum = 0;
        for (i = 0; num[i] != '\0'; i++) {
            sum += num[i] - '0';
        }
        
        printf("%d\n", sum);
    }
    
    return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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


int main() {
	string s;
	int q;
	list<char> cs;
	cin >> s >> q;
	for(char c : s) {
		cs.push_back(c);
	}

	int is_reverse = false;

	rep(i, q) {
		int cmd;
		cin >> cmd;
		if (cmd == 1) {
			is_reverse = !is_reverse;
			
		} else {
			int f;
			char c;
			cin >> f >> c;
			bool is_front = (f == 1);
			if (is_reverse) {
				is_front = !is_front;
			}
			if (is_front) {
				cs.push_front(c);
			} else {
				cs.push_back(c);
			}
		}
	}

	if (is_reverse) {
		while(!cs.empty()) {
			cout << cs.back();
			cs.pop_back();
		}

	} else {
		for(char c : cs) {
		cout << c;
		}
	}

	cout << endl;


	return 0;
}

Measured memory_bytes: 9984
main = do
  li <- getLine
  let [a,b,c,d] = map read $ words li
  print $ compute a b c d

compute :: Int -> Int -> Int -> Int -> Int
compute a b c d = maximum [a*c,a*d,b*c,b*d]
--ごちゃごちゃ場合分けするより、4つの端を全てやってみるのが早いか。


Measured memory_bytes: 3904
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int n;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	char s[101], t[101];
	scanf("%s %s", s, t);
	int len = strlen(s);
	REP(i, len) {
		REP(j,len) {
			//printf("%c %c\n", t[(i + j) % len], s[j]);
			if (t[(i + j) % len] != s[j])break;
			if (j == len - 1) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
}

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

struct Node {
	int nextNode;
	int cost;
} typedef tNode;

int main() {
	int N, K, aux, i, j;
	scanf("%d", &N);
	scanf("%d", &K);

	int h[N];
	tNode costs[N];

	for (i = 0; i < N; i++) {
		scanf("%d", &aux);
		h[i] = aux;
	}

	for (i = 0; i < N; i++) {
		costs[i].cost = -1;
		costs[i].nextNode = -1;
	}

	for (i = N - 1; i >= 0; i--) {
		if (i == N - 1) {
			costs[i].cost = 0;
			costs[i].nextNode = -1;
		} else {
			for (j = i + 1; j <= i + K && j < N; j++) {
				aux = abs(h[i] - h[j]);

				if (costs[i].cost == -1 || (costs[i].cost > (aux + costs[j].cost))) {
					costs[i].cost = (aux + costs[j].cost);
					costs[i].nextNode = j;
				}
			}
		}
	}

	printf("%d\n", costs[0].cost);

	return 0;
}


Measured memory_bytes: 1280