akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long

int n, m, cost[1001], dp[1001][(1<<12) + 12], msk[1001];

int calc(int idx, int ms) {
        if (ms == (1 << n)-1) return 0;
        if (idx == m) return 1e9;
        int &ret = dp[idx][ms];
        if (ret != -1) return ret;
        ret = 1e9;
        ret = min(ret, calc(idx + 1, ms | msk[idx]) + cost[idx]);
        ret = min(ret, calc(idx + 1, ms));
        return ret;
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        cin >> n>> m;
        lp(i, m) {
                int a, b; cin >> a>> b;
                cost[i] = a;
                int mk = 0;
                lp(j, b) {
                        int l; cin >> l;
                        l--;
                        mk |= 1<<l;
                }
                msk[i] = mk;
        }
        lp(i, 1001) lp(j, 1<<12) dp[i][j] = -1;
        int ans = calc(0, 0);
        cout << (ans == 1e9? -1: ans);
return 0;
}


Measured memory_bytes: 32512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    set<string> used;
    cout << "?a" << endl;
    used.insert("a");
    while(1){
        string t;
        cin >> t;
        if(t[0]!='a' || used.count(t)>0){
            cout << "!OUT" << endl;
            break;
        }
        else{
            used.insert(t);
            cout << "?" << t.back() << "aa" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}



int main(){
  string S,T;cin>>S>>T;
  bool ok =false;
  rep(i,S.size()){
    S=S[S.size()-1] +S.substr(0,S.size()-1);
    if(S==T){
      ok =true;
      break;
    }
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;

int Result(int cards[5]){
	int num_card[13];
	bool four=false, three=false, two=false;
	int	num_two=0;
	int min = 12,max = 0;

	for(int i=0;i<13;++i)num_card[i]=0;

	for(int i=0;i<5;++i){
		num_card[ cards[i] - 1 ] ++;
	}
	
	for(int i=0;i<13;++i){

		if(num_card[i]>0){
			if(i<min)min=i;
			if(i>max)max=i;

			if(num_card[i]==4)four=true;
			else if(num_card[i]==3)three=true;
			else if(num_card[i]==2){
				two=true;
				++num_two;
			}
		}
	}

	if(four)return 7;
	else if(three){
		if(two)return 6;
		else return 4;
	}
	else if(two){
		if(num_two == 2)return 3;
		else return 2;
	}

	if(max-min+1 == 5||(num_card[0]&&num_card[12]&&num_card[11]&&num_card[10]&&num_card[9]))
		return 5;
	return 1;
}

int main(){

	string res;
	int c[5];

	while(scanf("%d,%d,%d,%d,%d",&c[0],&c[1],&c[2],&c[3],&c[4])+1){
		
		
		switch( Result(c) ){
			case 1:res="null";break;
			case 2:res="one pair";break;
			case 3:res="two pair";break;
			case 4:res="three card";break;
			case 5:res="straight";break;
			case 6:res="full house";break;
			case 7:res="four card";break;
		}

		cout << res << endl;

	}

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll x;
	cin >> x;
	auto f = [](ll x) { return x * x * x * x * x; };
	repl(i, -1000, 1000) {
		repl(j, -1000, 1000) {
			if (f(i) - f(j) == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10000)

n, m = map(int, input().split())

root = [[] for _ in range(n)]

for i in range(m):
    x, y = map(int, input().split())
    root[x-1].append(y-1)

memo = ["empty" for _ in range(n)]

def dp(x):
    if memo[x] == "empty":
        res = 0
        for i in root[x]:
            res = max(res, dp(i)+1)
        memo[x] = res

    return memo[x]

for j in range(n):
    dp(j)

print(max(memo))

Measured memory_bytes: 157076
MOD = 10**9 + 7


def comb(n, k, MOD):
    if k > n - k:
        k = n - k
    ans = 1
    for i in range(1, k + 1):
        ans *= n + 1 - i
        ans *= pow(i, MOD - 2, MOD)  # a //= i
        ans %= MOD
    return ans


x, y = map(int, input().split())
a = 2 * y - x
b = 2 * x - y

if a < 0 or b < 0:
    ans = 0
elif a % 3 != 0 or b % 3 != 0:
    ans = 0
else:
    a //= 3
    b //= 3
    # print(a, b)
    ans = comb(a + b, a, MOD)

print(ans)


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

int main(void){
    int r;
    cin >> r;
    if (r < 1200) cout << "ABC" << endl;
    else if (r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define PI  3.14159265358979323846

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
string S;
ll N, M;
vector<string>A;


int main() {
    cin >> N >> M;
    if (N<M) {
        cout << 0 << endl;
    }
    else {
        cout << 10 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0


for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if X == 500 * i + 100 * j + 50 * k:
                ans += 1

print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

namespace B
{
	static class Program
	{
		static void Main(string[] args)
		{
			var line1 = Console.ReadLine();
			var N = int.Parse(line1);

			var X = new List<double>();
			var U = new List<string>();

			for (int i = 0; i < N; i++) {
				var line2 = Console.ReadLine();
				var line2Splited = line2.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
				X.Add(double.Parse(line2Splited[0]));
				U.Add(line2Splited[1]);
			}

			double sum = 0.0;
			for (int i = 0; i < N; i++) {
				if (U[i] == "JPY") sum += X[i];
				else {
					sum += X[i] * 380000.0;
				}
			}

			Console.WriteLine(sum);
		}
	}
}

Measured memory_bytes: 11220
#include<iostream>
using namespace std;
int main(){
	long long int a,b,c,ans=0,m;
	cin>>a>>b>>c;
	ans=b/c;
	m=a/c;
	ans-=m;
	if(a%c==0)ans+=1;
	//if(a%c!=0 && b%c!=0)ans--;
	cout<<ans<<endl;
}
//1 2 

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

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int* cpyArray(int data[],int len);//配列(int)を複製した配列のポインタをreturn

//don't forget free(data);

int main(){
    int n;
    int *a,*b,*c;
    scanf("%d ",&n);
    a=inputArray(n);
    b=inputArray(n);
    c=inputArray(n-1);
    int ans=0;
    for(int i=0;i<n;i++){
        ans += b[a[i]-1];
        if(a[i]+1==a[i+1])ans += c[a[i]-1];
    }
    free(a);
    free(b);
    free(c);
    printf("%d",ans);
    return 0;
}

//temp##############################################

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

int* cpyArray(int data[],int len){
    int *cp;
    cp=(int*)malloc(sizeof(int)*len);
    for(int i=0;i<len;i++){
        cp[i]=data[i];
    }
    return cp;
}

//temp##############################################


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <map>
#include <climits>
#include <vector>
#include <set>
#include <string>
#include <numeric>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
//#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
const int N = 1e5 + 2;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int32_t main() {
    FAST_IO;
    string o, e, f;
    cin >> o >> e;
    for (int i = 0; i < max(o.length(), e.length()); i++) {
        if (i < o.length()) f += o[i];
        if (i < e.length()) f += e[i];
    }
    cout << f;
    return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void){
    int n,q;
    cin>>n;
    map<ll,ll> mp;
    ll sum=0;
    rep(i,0,n){
        int a;
        cin>>a;
        mp[a]++;
        sum+=a;
    }
    cin>>q;
    rep(i,0,q){
        int b,c;
        cin>>b>>c;
        sum+=(c-b)*mp[b];
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}



Measured memory_bytes: 9464
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

// 負の数にも対応した % 演算
long long mod1(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

signed main(){
  ll n;
  cin >> n;
  ll a = 1, b = 1, c = 1;
  rep(i,n){
    a *= 10;
    a %= MOD;
    b *= 9;
    b %= MOD;
    c *= 8;
    c %= MOD;
  }
  ll ans = (a + c) % MOD;
  ans = mod1(ans - (b * 2) % MOD, MOD);
  cout << ans << endl;
  return 0;
}

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


using namespace std;

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(2 * n);
    for (int& x : a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    int res = 0;
    for (int i = 0; i < a.size(); i += 2) {
        res += a[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
 
void solve(){
    ll n;
    cin>>n;
    ll m;
    cin>>m;
    multiset<ll> s;
    loop(i,0,n) {
        ll x;
        cin>>x;
        s.insert(x);
    }
    loop(i,0,m){
        auto it = s.end();
        it--;
        ll ff = *it;
        s.erase(it);
        s.insert(ff/2);
    }
    ll ans = 0;
    for(auto x: s){
        ans += x;
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
 
}


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

bool pattern(string s) {
  int i = stoi(s);
  if (i == 0 || i > 12) {
    return true;
  } else {
    return false;
  }
}

int main(void){
    string S;
    cin >> S;
    string f, b;
    f = S.substr(0, 2);
    b = S.substr(2, 2);
    
    bool F, B;
    F = pattern(f);
    B = pattern(b);
    
    if (F && !B) {
      cout << "YYMM";
    } else if (F && B) {
      cout << "NA";
    } else if (!F && B) {
      cout << "MMYY";
    } else {
      cout << "AMBIGUOUS";
    }
    cout << endl;
}

Measured memory_bytes: 256
// Confessions of a Dangerous Mind

/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

/*
	"With self-discipline most anything is possible."
*/	

	double n; cin >> n;
	cout << fixed << setprecision(10) << pow(n / 3.0, 3);
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  ll n, k;
  cin >> n >> k;
  vector<ll> p, m;
  ll z = 0;
  rep(i, n)
  {
    ll a;
    cin >> a;
    if (a > 0)
    {
      p.push_back(a);
    }
    else if (a < 0)
    {
      m.push_back(-a);
    }
    else
    {
      z++;
    }
  }

  sort(all(p));
  sort(all(m));

  auto simulate = [&](ll x) {
    //xより小さい要素がk-1個以下ならtrue
    ll cnt = 0;
    if (x > 0)
    {
      cnt += (ll)p.size() * (ll)m.size();
      cnt += (ll)p.size() * z;
      cnt += (ll)m.size() * z;
      rep(i, p.size()) //p,p
      {
        ll lo = -1, hi = (ll)p.size();
        while (hi - lo > 1)
        {
          int mid = (lo + hi) / 2;
          if (p[i] * p[mid] < x)
            lo = mid;
          else
            hi = mid;
        }
        cnt += max(lo - i, 0LL);
      }

      rep(i, m.size()) //m,m
      {
        ll lo = -1, hi = (ll)m.size();
        while (hi - lo > 1)
        {
          int mid = (lo + hi) / 2;
          if (m[i] * m[mid] < x)
            lo = mid;
          else
            hi = mid;
        }
        cnt += max(lo - i, 0LL);
      }
      //z,z
      cnt += z * (z - 1) / 2;
    }
    else if (x < 0)
    {
      for (auto pi : p) //p,m
      {
        ll lo = -1, hi = m.size();
        while (hi - lo > 1)
        {
          ll mid = (lo + hi) / 2;
          if (pi * m[mid] > -x)
            hi = mid;
          else
            lo = mid;
        }
        cnt += (ll)m.size() - hi;
      }
    }
    else if (x == 0)
    {
      cnt += (ll)p.size() * (ll)m.size();
    }
    return cnt <= k - 1;
  };

  auto binary_search = [&]() {
    ll L = -LINF, H = LINF;
    while (H - L > 1)
    {
      ll M = (L + H) / 2;
      if (simulate(M))
        L = M;
      else
        H = M;
    }
    return L;
  };

  cout << binary_search() << endl;

  return 0;
}


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

using namespace std;

int n;
string s;

signed main(){
	cin >> n >> s;
	int ta = 0, mu = 0;
	rep(i, s.size()) {
		if (s[i] == '(')mu++;
		else if (s[i] == ')'&&mu >= 1) mu--;
		else ta++;
	}
	rep(i, ta)cout << '(';
	cout << s;
	rep(i, mu)cout << ')';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
char s[105];
void Solve() {
    read(N);
    scanf("%s",s + 1);
    int cnt = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(s[i] == 'R') ++cnt;
        else --cnt;
    }
    if(cnt > 0) puts("Yes");
    else puts("No");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

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 long long INF = 1LL << 60;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//cout<<""<<endl;
int main(){
  int N;cin>>N;
  string S1,S2;cin>>S1>>S2;
  ll ans=1;
  int now=0;
  bool ok=false;
  while(true){
    if(now>=S1.size())break;
    if(S1[now]==S2[now]){
      if(ok){
        ans*=2;
      }
      if(now==0){
        ans*=3;
      }
      now++;
      ok=true;
    }
    else{
      if(ok){
        ans*=2;
      }
      else{
        if(now==0)ans*=6;
        else ans*=3;
      }
      now+=2;
      ok=false;
    }
     ans%=1000000007;
  }
  cout<<ans<<endl;
  
}



Measured memory_bytes: 3724
num = gets.to_i
ary = gets.split().map(&:to_i)
sorted_ary = ary.sort

diff_ary = ary.zip(sorted_ary).map{|attr| attr.first - attr.last}

diff_size = diff_ary.reject(&:zero?).size

if diff_size == 0 || diff_size == 2
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,n;
    cin >> n;
 a=0;b=0;
    vector<int> card(n);
    for (int i = 0; i < n; i++){
        cin >> card.at(i);
    }
    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());
 
    for (int i = 0; i < n; i += 2){
        a += card.at(i);
    }
    for (int i = 1; i < n; i += 2){
        b += card.at(i);
    }
    cout << a-b << endl;
 
}

Measured memory_bytes: 256
def sum(i):
	S = 0
	while i >= 1:
		S +=  i % 10
		i = i // 10
	return S

counter = 0

N, A, B = (int(i) for i in input().split()) #任意個の整数値の入力、今の場合３個



for i in range(1, N + 1):	#rangeの範囲に注意
	if sum(i) >= A and sum(i) <= B:
		counter += i

print(counter)		


Measured memory_bytes: 2940
if __name__ == '__main__':
    _, m = map(int, input().split())
    pres = [[i] + [int(s) for s in input().split()] for i in range(m)]
    pres.sort(key=lambda t: t[2])
    count = dict((p, 1) for _, p, _ in pres)
    prev_y = 0
    addrs = []
    for i, p, _ in pres:
        addrs.append((i, p * 1000000 + count[p]))
        count[p] += 1
    addrs.sort(key=lambda t: t[0])
    for _, a in addrs:
        print("%012d" % a)


Measured memory_bytes: 42712
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void dfs(int i,vector<ll> &v,vector<int> &visited,vector<ll> &aux,ll &element)
{
    visited[i]=1;
    aux.push_back(i);
    if(visited[v[i]])
    {
        element=v[i];
        return;
    }
    else
    {
        dfs(v[i],v,visited,aux,element);
    }
}

int main() 
{
	int t=1;
	//cin>>t;
	while(t--)
	{
	    int n;
	    ll k;
	    cin>>n>>k;
	    vector<ll> v(n+1);
	    for(int i=1;i<=n;i++)
	    cin>>v[i];
	    ll element;
	    vector<ll> aux;
	    vector<int> visited(n+1,0);
	    dfs(1,v,visited,aux,element);
	    map<ll,ll> mp1,mp2;
	    ll extra=0;
	    ll i;
	    ll len=0;
	    for(i=0;i<aux.size();i++)
	    {
	        if(aux[i]==element)
	        break;
	        mp1[extra]=aux[i];
	        extra++;
	        len++;
	    }
	    extra=0;
	    ll cycle=0;
	    for(;i<aux.size();i++)
	    { 
	        mp2[extra]=aux[i];
	        extra++;
	        cycle++;
	    }
	    if((k-len)==0)
	    {
	        cout<<element;
	        return 0;
	    }
	    if(k<len)
	    {
	        cout<<mp1[k];
	        return 0;
	    }
	    k-=len;
	    ll rem=(k%cycle);
	    cout<<mp2[rem];
	}
	return 0;
}


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 341;

int q;
int m[MAX];
int x[MAX];

ll ans;

int l[MAX];
vi primes;

void sieve() {
	fi(2, MAX - 1) {
		if (!l[i]) {
			for (int j = i; j < MAX; j += i) {
				if (l[j] == 0 || l[j] > i) l[j] = i;
			}
			primes.pb(i);
		}
	}
}

int cnt[MAX];

int const K = 19;

bool can(int x) {
	while (x > 1) {
		int k = l[x];
		int d = 0;
		while (x % k == 0) {
			x /= k;
			d++;
		}
		if (cnt[k] < d) return 0;
	}
	return 1;
}

void calc() {
	vll a(MAX, 0LL);

	fi(1, q) {
		int x = m[i];
		bool ok = true;
		while (x > 1) {
			int k = l[x];
			if (k >= K) break;
			int d = 0;
			while (x % k == 0) {
				x /= k;
				d++;
			}
			if (cnt[k] < d) ok = false;
		}
		if (ok && x != 1) {
			a[x] += ::x[i];
		}
	}

	for (int x : primes) {
		if (x < K) continue;
		if (a[x] > 0) {
			cnt[x] = 1;
		} else {
			cnt[x] = 0;
		}
	}
	
	ll cur = 0;
	fi(1, q) {
		if (can(m[i])) {
			cur += x[i];
		}
	}

	ans = max(ans, cur);
}

void go(int x) {
	if (primes[x] >= K) {
		calc();
		return;
	}
	int cur = 1;
	fo(0, 100) {
		if (cur >= MAX) break;
		cnt[primes[x]] = o;
		go(x + 1);
		cur *= primes[x];
	}
}

void solve() {
	sieve();
	go(0);	
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d", &q);
  fi(1, q) {
  	scanf("%d %d", &m[i], &x[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Ordinary Number
            int n = int.Parse(Console.ReadLine());
            var p = ReadLine();
            int ans = 0;

            for(int i = 0; i < n - 2; i++)
            {
                var a = p.Skip(i).Take(3).OrderBy(x => x).ToList();

                if (p[i + 1] == a[1])
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);            
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

int main(){
  
  int A, B, C;
  cin >> A >> B >> C;
  
  vector<int> V(3);
  
  V.at(0) = A;
  V.at(1) = B;
  V.at(2) = C;
  
  sort(V.begin(), V.end());
  
  int K;
  cin >> K;
  
  for (int i=0; i<K; i++)
    V.at(2) *= 2;
  
  int sum;
  
  sum = V.at(0) + V.at(1) + V.at(2);
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
require 'pp'

n = gets.to_i
p_n = gets.split.map(&:to_i)
q_n = gets.split.map(&:to_i)

i = 0
p_index = -1
q_index = -1
(1..n).to_a.permutation(n).sort.each do |x|
    if p_index == -1 && x == p_n
        p_index = i
    end

    if q_index == -1 && x == q_n
        q_index = i
    end

    i += 1
end

puts (p_index - q_index).abs



Measured memory_bytes: 7640
#include <iostream>
#include <vector>
#include <climits>
#include <queue>
using namespace std;

class BellmanFord
{
	class Edge {
		int from, to; // 2端点のインデックス
		int weight; // コスト

	public :
		Edge(int n, int m, int w) {
			from = n;
			to = m;
			weight = w;
		}
		int GetFrom() { return from; }
		int GetTo() { return to; }
		int GetWeight() { return weight; }
	};

	int node_num;
	vector<Edge> edges;
	int *distances;
	int start;
	int end;

public:
	BellmanFord(int n, int s, int e) {
		node_num = n;
		start = s;
		end = e;
		distances = new int[n];
	}

	~BellmanFord() {
		delete[] distances;
	}

	void AddEdge(int from, int to, int weight) {
		Edge edge(from, to, weight);
		edges.push_back(edge);
	}

	int ShortestPath(bool &has_roop) {
		// initialise
		for (int i = 0; i < node_num; i ++) {
			distances[i]  = (i == start)? 0 : INT_MAX;
		}
		has_roop = false;

		// back traceしてゴールにたどり着き得る頂点を得る
		vector<Edge>::iterator itr, itr_end = edges.end();
		vector<int> reached(node_num, 0);
		reached[end] = 1;
		priority_queue<int> queue;
		queue.push(end);
		while (queue.size()) {
			int cur = queue.top();
			queue.pop();
			for (itr = edges.begin(); itr != itr_end; itr ++) {
				if (cur != itr->GetTo()) continue; // curを接続するedgeでない
				if (reached[itr->GetFrom()] == 1) continue; // 検索済み
				reached[itr->GetFrom()] = 1;
				queue.push(itr->GetFrom());
			}
		}

		for (int i = 0; i < node_num; i ++) {
			for (itr = edges.begin(); itr != itr_end; itr ++) {
				int from_cost = distances[itr->GetFrom()];
				int to_cost = distances[itr->GetTo()];

				if (!reached[itr->GetTo()]) continue; // さし先が無関係
				if (from_cost == INT_MAX) continue; // 1度も訪れていない
				int new_dist = from_cost + itr->GetWeight();

				if (new_dist < to_cost) {
					distances[itr->GetTo()] = new_dist;
					if (i == node_num-1) {
						// ループがなければ、1回のコスト更新で1つの頂点の経路が確定
						// つまり、node_num-1回ですべての頂点の経路の最小値が決まる
						// node_num回目の更新ができるとすると、ループがある
						has_roop = true;
						break;
					}
				}
			}
		}

		return distances[end];
	}
};

int main() {
	int n, m, p;
	cin >> n >> m >> p;
	BellmanFord bellman(n, 0, n-1);

	int a, b, c;
	for (int i = 0; i < m; i ++) {
		cin >> a >> b >> c;
		c = c - p;
		a = a-1;
		b = b-1;
		// 最短経路を求めるアルゴリズムなので-1をかける
		c *= -1;
		bellman.AddEdge(a, b, c);
	}

	bool has_roop = false;
	int dist = bellman.ShortestPath(has_roop);
	if (has_roop) cout << "-1" << endl;
	else {
		dist *= -1; // スコアの符号を戻す
		if (dist < 0) dist = 0;
		cout << dist << endl;
	}

	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int X = cin.nextInt();
        int Y = cin.nextInt();

        Console.WriteLine(X + Y / 2);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 11092
(N,M,T),*Y=$<.map{|l|l.split.map &:to_i};X=Y.reverse;$><<(T<2?(a=(r=0..N).map{|i|1<<i-1};Y.each{|x,y|a[x]=a[y]|=a[x]};g=r.find{|i|a[i]>(1<<N)-2})?(o=[p]*-~N;o[g]=1;X.map{|x,y|o[x]?o[y]=?^:(o[x]||=o[y];?v)}):[-1]:N<3?[-1]:X.map{|x,y|y<4&&Y[x]==Y[6-x-y]?(Y[x]=Y[y];?v):(Y[y]=Y[x];?^)}).reverse.join

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

int main(){
  long long A,V ,B ,W, T;
  cin >>A >> V >> B>> W >> T;
  
  long long kyori = abs(B -A);
  long long sa = V - W; //1秒ごとに縮まる距離
  if(kyori - sa*T <= 0)cout << "YES" << endl;
  else cout <<"NO" << endl;
}

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


int a[200005];
long long dp[200005];
long long pom[200005];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	if (n % 2 == 0){
		long long s1 = 0, s2 = 0;
		for (int i = 1; i <= n; i += 2)
			s1 += a[i];
		for (int i = 2; i <= n; i += 2)
			s2 += a[i];
		long long wynik = max(s1,s2);

		dp[1] = a[1];
		for (int i = 2; i <= n; ++i)
			dp[i] = dp[i-2] + a[i];

		pom[n] = a[n];
		for (int i = n-1; i >= 1; --i){
			if (i % 2 == 1)
				pom[i] = pom[i+2] + a[i];
	 		else
	 			pom[i] = max(pom[i+2]+a[i],pom[i+3]+a[i]);
		}


		for (int i = 1; i < n; ++i){
			long long s = 0;
			if (i % 2 == 1){
				s = dp[i] + (dp[n] - dp[i+1]);
				wynik = max(wynik, s);
			}
		}
		cout << wynik << "\n";
		return 0;
	}

	dp[1] = a[1];
	for (int i = 2; i <= n; ++i)
		dp[i] = dp[i-2] + a[i];
	long long wynik = -1e18;

	pom[n] = a[n];
	for (int i = n-1; i >= 1; --i){
		if (i % 2 == 1)
			pom[i] = pom[i+2] + a[i];
 		else
 			pom[i] = max(pom[i+2]+a[i],pom[i+3]+a[i]);
	}


	for (int i = 1; i < n; ++i){
		long long s = 0;
		if (i % 2 == 1){
			s = dp[i] + (dp[n-1] - dp[i+1]);
			wynik = max(wynik, s);

			s = dp[i] + (dp[n] - dp[i+2]);
			wynik = max(wynik, s);

			s = dp[i] + pom[i+3];
			wynik = max(wynik, s);
		}
		if (i % 2 == 0){
			s = dp[i] + pom[i+3];
			wynik = max(wynik, s);
		}

		//cout << s << ": " << i << "\n";
	}
	wynik = max(wynik, dp[n]-dp[1]);
	wynik = max(wynik, dp[n-1]);
	cout << wynik << "\n";
}

Measured memory_bytes: 7512
n = input()
l = len(n)
f = n[l-1]
if f == "2" or f == "4" or f == "5" or f == "7" or f == "9":
    print("hon")
elif f == "0" or f == "1" or f == "6" or f == "8":
    print("pon")
else:
    print("bon")
    pass

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

num = range(1, int(n ** 0.5) + 1)
from itertools import combinations_with_replacement
table = [0] * n
for i in combinations_with_replacement(num, 3):
    #print(i)
    index = (i[0] + i[1] + i[2]) ** 2 - (i[0] * i[1] + i[0] * i[2] + i[1] * i[2])

    if (i[0] + i[1] + i[2]) ** 2 - (i[0] * i[1] + i[0] * i[2] + i[1] * i[2]) > n:
        continue
    if i[0] == i[1] == i[2]:
        table[index - 1] += 1
    elif i[0] != i[1] != i[2]:
        table[index - 1] += 6
    else:
        table[index - 1] += 3
for i in range(n):
    print(table[i])

Measured memory_bytes: 9568
#include <cstdio>

const int mxn = 105;

int n, a[mxn];

signed main() {
	scanf("%d", &n);
	
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	
	for (int i = 0; i < n; ++i) {
		// insert a[i]
		int v = a[i], p = 0;
		
		while (p < i && v > a[p])++p; 
		
		for (int j = i; j > p; --j)
			a[j] = a[j - 1];
		
		a[p] = v;
		
		// print array
		for (int j = 0; j < n - 1; ++j)
			printf("%d ", a[j]);
		printf("%d\n", a[n - 1]);
	}
	
	return 0;
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i,N)
  {
    cin >> vec[i];
  }
  sort(RALL(vec));
  int sum1 = 0;
  int sum2 = 0;
  for(int i=0;i<N;i++)
  {
    if(i%2==0)
    {
      sum1 += vec[i];
    }
    else if(i%2==1)
    {
      sum2 += vec[i];
    }
    
  }
  cout << sum1-sum2 << endl;
  return 0;
}


Measured memory_bytes: 256
(defun f(line0 line1)
  (if (and (string= line0 "1")
           (string= line1 "2"))
    "3"
    (if (and (string= line0 "1")
             (string= line1 "3"))
      "2"
      (if (and (string= line0 "2")
               (string= line1 "1"))
        "3"
        (if (and (string= line0 "2")
                 (string= line1 "3"))
          "1"
          (if (and (string= line0 "3")
                   (string= line1 "1"))
            "2"
            "1"))))))

(let* ((line0 (read-line nil nil))
       (line1 (read-line nil nil)))
  (format t "~A~%" (f line0 line1)))


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

typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) { s >> x; } return s;}
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> H(N); cin >> H;

    bool f = true;
    for (int i = N - 2; i >= 0; i--) {
        if (H[i] > H[i + 1]) {
            if (H[i] == H[i + 1] + 1) {
                H[i]--;
            } else {
                f = false;
                break;
            }
        }
    }

    Yes(f);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n;

ll mod=1e9+7,dp[3005][3005],s[3005][3005];

string t;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> t;
    dp[1][1]=1;
    s[1][1]=1;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=i;j++){
            if(t[i-2]=='>') dp[i][j]=((s[i-1][i-1]-s[i-1][j-1])%mod+mod)%mod;
            else dp[i][j]=s[i-1][j-1];
            s[i][j]=(s[i][j-1]+dp[i][j])%mod;
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans+=dp[n][i],ans%=mod;
    cout << ans;
}


Measured memory_bytes: 139648
n,k,*a=map(int,open(0).read().split())
s,m=sum(a),1
for i in sum([[s//i,i]for i in range(1,int(s**.5)+1)if s%i<1],[]):
  p=[0]+sorted(j%i for j in a)
  for j in range(n):p[j+1]+=p[j]
  f=t=0
  for j in range(n):
    f|=t==p[~j]<=k
    t+=i-p[~j]+p[-j-2]
  m=max(m,i*f)
print(m)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, T; cin >> N >> T;

    int last = 0, ans = 0;
    REP(i, 0, N) {
        int t; cin >> t;
        if (last <= t) {
            ans += T;
        } else {
            ans += (t + T) - last;
        }
        last = t + T;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a,b,c,d;
	int ryokin;
	int kari;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c >> d;
		ryokin = a*c+b*d;
		if (c >= 5 && d >= 2) {
			ryokin = (double)ryokin * 0.8;
		} else if (c >= 5) {
			kari = (double)(a*c+b*2)*0.8;
			ryokin = min(ryokin, kari);
		} else if (d >= 2){
			kari = (double)(a*5+b*d)*0.8;
			ryokin = min(ryokin, kari);
		} else {
			kari = (double)(a*5+b*2)*0.8;
			ryokin = min(ryokin, kari);
		}
		cout << ryokin << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */
 
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007
 
const long double PI = 3.141592653589793236L;
 
typedef long long int ll;
typedef long double ld;
 
using namespace std;

void solve()
{
    string s;
    cin >> s;

    int sum = 0;
    int n = s.size();

    for(int i = 0; i < n; i++) 
    {
        sum += s[i] - '0';
    }

    if(sum % 9) 
    {
        cout << "No\n";
    }
    else {
        cout << "Yes\n";
    }

} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int T = 1;
    //cin >> T;
 
    while (T--)
    {
        solve();
    }
    
    return 0;
}
 


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll l,r,d;cin>>l>>r>>d;
    ll ans=r/d-(l-1)/d;
    cout<<ans<<endl;
}

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


int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  
  int ans =  0;
  if(a[0]==a[1]&&a[1]==a[2]) {
    cout << ans << endl;
    return 0;
  }
  
  sort(a.begin(), a.end());
  while(a[2]-a[0]>1) {
    a[0]+=2;
    ans++;
    sort(a.begin(), a.end());
  }
  sort(a.begin(), a.end());
  if(a[0]==a[1]&&a[1]==a[2]) {
    cout << ans << endl;
    return 0;
  } else if(a[0]==a[1]) {
    cout << ans+1 <<endl;
  } else {
    cout << ans+2 << endl;
  }
    
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
  var abc = lines[0].split(' ');
  var abc = abc.map(function(str) { return Number(str)});
  var a = abc[0];
  var b = abc[1];
  var c = abc[2];
  var count = 0;

  for(i=a; i<=b; i++){
    if(c % i == 0){
      count++;
    }
  }
  console.log(count);
  
});


Measured memory_bytes: 16272
n, m = map(int, input().split())
H = [0] + list(map(int, input().split()))
graph = {i: set() for i in range(1, n + 1)}

for _ in range(m):
    a, b = map(int, input().split())
    graph[a].add(b)
    graph[b].add(a)

ans = 0
for v in range(1, n + 1):
    orig_h = H[v]
    for nv in graph[v]:
        if orig_h <= H[nv]:
            break
    else:
        ans += 1
print(ans)


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int H,W;cin>>H>>W;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin>>S[i];
    }
    for(int i=0;i<H;i++){
        if(i==0){
            for(int j=0;j<W;j++){
                printf(".");
            }
        }else if(i==H-1){
            for(int j=0;j<W;j++){
                printf("#");
            }
        }else{
            for(int j=0;j<W;j++){
                if(j%2==0){
                    printf("#");
                }else if(S[i][j]=='#'){
                    printf("#");
                }else{
                    printf(".");
                }
            }
        }
        printf("\n");
    }
    printf("\n");
    for(int i=0;i<H;i++){
        if(i==H-1){
            for(int j=0;j<W;j++){
                printf(".");
            }
        }else if(i==0){
            for(int j=0;j<W;j++){
                printf("#");
            }
        }else{
            for(int j=0;j<W;j++){
                if(j%2==1){
                    printf("#");
                }else if(S[i][j]=='#'){
                    printf("#");
                }else{
                    printf(".");
                }
            }
        }
        printf("\n");
    }
}


Measured memory_bytes: 1024