akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, x, y;
    cin >> N;
    vector<pair<int, int>> R(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> x >> y;
        R[i] = make_pair(x, y);
    }
    for (int i = 0; i < N; i++) {
        cin >> x >> y;
        B[i] = make_pair(x, y);
    }
    
    sort(R.begin(), R.end(), [](const pair<int, int> &a, const pair<int, int> &b) {
        if (a.second != b.second) {
            return a.second > b.second;
        }
        else {
            return a.first > b.first;
        }
    });

    sort(B.begin(), B.end(), [](const pair<int, int> &a, const pair<int, int> &b) {
        if (a.first != b.first) {
            return a.first < b.first;
        }
        else {
            return a.second < b.second;
        }
    });

    int C = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (R[j].first < B[i].first && R[j].second < B[i].second) {
                R[j].second = 2*N;
                C++;
                break;
            }
        }
    }
    cout << C << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 500010;
const int MOD = (ll)1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;

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





int b[101];
signed main() {
	int N; cin >> N;
	vector<int>ans;
	REP(i, N) {
		cin >> b[i];
	}
	REP(i, N) {
		if (b[i] > i+1) {
			print(-1); return 0;
		}
	}
	REP(i, N) {
		auto it = ans.begin();
		it += b[i] - 1;
		ans.insert(it, b[i]);
	}
	REP(i, N) {
		print(ans[i]);
	}
	
}	


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  if(n % x == 0) cout << n / x * t;
  else cout << (n / x + 1) * t;
}


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

using namespace std ;

const int MAX = 305*305 ;
int ans[MAX], r[MAX] , c[MAX] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n , m , d;
	cin>>n>>m>>d ;
	int arr[n][m];
	memset(ans, -1 , sizeof(ans)) ;
	for(int i = 0 ; i < n ; ++i)
	{
		for(int j = 0; j < m ; ++j)
		{
			cin>>arr[i][j] ;
			r[arr[i][j]] = i ;
			c[arr[i][j]] = j ;
		}
	}
	for(int x = n*m ; x >= 1 ; --x)
	{
		if(ans[x] != -1)
			continue ;
		ans[x] = 0 ;
		for(int j = x-d ; j >= 1 ; j -= d)
		{
			ans[j] = ans[j+d] + (abs(r[j] - r[j+d]) + abs(c[j] - c[j+d])) ;
		}
	}
	int q ;
	cin>>q ;
	while(q--)
	{
		int l , r ;
		cin>>l>>r ;
		cout<<ans[l] - ans[r]<<"\n";
	}
	return 0 ;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,k,ans;
int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
 
// 階乗
std::vector<int>fact;
void mod_fact(int n, int m){//N,MOD
	fact.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%m;
	}
}
 
// nCk mod p
int mod_nCr(int n, int k, int m){
	if(n<k)return 0;
	return fact[n]*mod_inverse(fact[k]*fact[n-k]%m,m)%m;
}
int mod_pow(int a, int n, int p){
	if(n==1)return a%p;
	if(n%2==1)return a*mod_pow(a,n-1,p)%p;
	int num=mod_pow(a,n/2,p);
	return num*num%p;
}
int a,b;
signed main(){
	cin>>n>>a>>b;
	ans=mod_pow(2,n,MOD);
	int num=1;
	rep(i,a){
		num*=n-i;
		num%=MOD;
	}
	int num2=1;
	rep(i,a){
		num2*=i+1;
        num2%=MOD;
	}
	int extra1=num*(mod_inverse(num2,MOD)%MOD);
    extra1%=MOD;
	int num3=1;
	rep(i,b){
		num3*=n-i;
		num3%=MOD;
	}
	int num4=1;
	rep(i,b){
		num4*=i+1;
        num4%=MOD;
	}
	int extra2=num3*(mod_inverse(num4,MOD)%MOD);
    extra2%=MOD;
	ans-=(extra1+extra2)%MOD+1;
	if(ans>=0)cout<<ans<<endl;
	else cout<<ans+MOD<<endl;
}


Measured memory_bytes: 256
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

struct edge {
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<edge> > Graph;
Graph G(2001);

void add_edge(int from, int to, int cost) {
  G[from].push_back(edge(to, cost));
}

int N, K;

// depthが正の間頂点を数える
int countV(int p, int v, int depth) {
  int c = 1;
  if (depth) {
    for (edge e : G[v]) {
      if (e.to != p) {
        c += countV(v, e.to, depth - 1);
      }
    }
  }
  return c;
}

void solve() {
  int ans = 0;
  if (K % 2 == 0) {
    // 直径が偶数→すべての頂点に関して, 距離K/2以上の頂点を数え,それの最小値が答え
    REP(i, N) {
      ans = max(ans, countV(-1, i, K/2));
    }
  } else {
    // 直径が奇数→すべての辺に関して, 距離(K - 1)/2 以上となる頂点を数え, それの最小値が答え
    REP(i, N) {
      for (edge e : G[i]) {
        int l = countV(e.to, i, K/2);
        int r = countV(i, e.to, K/2);
        ans = max(ans, l + r);
      }
    }
  }
  cout << N - ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> K;
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b;
    add_edge(a - 1, b - 1, 1);
    add_edge(b - 1, a - 1, 1);
  }
  solve();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
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;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

long long fac[MAX], finv[MAX], inv[MAX];

// combinationのテーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main() {
    //COMinit();
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}

Measured memory_bytes: 256
import           Data.Maybe
import           Data.Bits
import qualified Data.ByteString.Char8         as C8

getInts :: IO [Int]
getInts = fmap (map (fst . fromJust . C8.readInt) . C8.words) C8.getLine

main :: IO ()
main = do
    [a, b] <- getInts
    print $ (f a) `xor` (f b) `xor` a

f :: Int -> Int
f n = [n, 1, n + 1, 0] !! (n `mod` 4)


Measured memory_bytes: 380
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String S = sc.next();
        String mae = S.substring(0,k-1);
        String usiro = S.substring(k);
        char A = S.charAt(k-1);
        if(A == 'A'){
          A = 'a';
        }else if (A == 'B'){
          A = 'b';

        }else{
          A = 'c';
        }
        System.out.println(mae + A + usiro);
    }
}


Measured memory_bytes: 22612
N, M = map(int, input().split())

S_C = []
for _ in range(M):
    s, c = map(int, input().split())
    S_C.append([s, c])

if N == 1:
    r = range(0, 10)
elif N == 2:
    r = range(10, 100)
else:
    r = range(100, 1000)

for i in r:
    str_i = str(i)

    flag = True
    for s, c in S_C:
        if str_i[s - 1] != str(c):
            flag = False
            break

    if flag:
        print(i)
        quit(0)

print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int main() {
    int N;
    int A, B;
    while(cin >> N, N) {
        A = 0, B = 0;
        REP(i, N) {
            int s, t;
            scanf("%d%d", &s, &t);
            if(s > t) A += s + t;
            if(t > s) B += s + t;
            if(s == t) {A += s; B += t;}
        }
        
        cout << A << " " << B << endl;
    }
    return 0;
}

Measured memory_bytes: 1244
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define mp make_pair
#define pb push_back
#define FI first
#define SE second
#define FOR(i,a,b) for(int (i)=((int)a); (i)<((int)b); (i)++) // [a,b)
#define REP(i,N) FOR((i), 0, ((int)N)) // [0,N)
#define INF (1 << 30)
#define icin(x) int x; cin >> x
#define lcin(x) ll x; cin >> x
#define dcin(x) double x; cin >> x
#define scin(s) string s; cin >> s
#define aout(x) cout << x << endl
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vcin(v,N) vi v(N); REP(i,N) cin >> v[i]
#define vcinl(v,N) vl v(N); REP(i,N) cin >> v[i]
#define vmax(v) *max_element(all(v)) // 遅い？いつか書き直す
#define vmin(v) *min_element(all(v))
#define vidx(v,it) distance((v).begin(),(it))
#define vsum(v) accumulate(all(v),0)
#define vsumr(v,a,b) accumulate((v).begin()+(a),(v).begin()+(b),0) //[a,b)
#define vfnd(v,val) find(all(v),val) // itrを返す。存在しない場合v.end()を返す
#define vcnt(v,val) count(all(v),val)
#define vrep(v,it) for(auto it=(v).begin(); it != (v).end(); ++it)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0) // IOS;で高速化

// デバッグ用
// dbg(...) printfと同様に使用可能 
// trc(var) (変数名)=(値)と表示
// stopif(val) 条件分が真の時に止まる
// vdbg(v) vの中身を表示
#ifdef LOCAL
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
    #define trc(var) cout << #var << "=" << var << endl
    #define trc2(v) cout << #v << "={"
    #define stopif(val) assert( !(val) )
    #define vdbg(v) vector_debug(v)
#else
    #define dbg(...) 1
    #define trc(var) 1
    #define trc2(v) 1
    #define stopif(val) 1
    #define vdbg(v) 1
#endif

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > vvi;
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}
ll gcd(ll a, ll b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}
template<typename C> inline void vector_debug(vector<C> v){trc2(v);ostream_iterator<C> o(cout,",");copy(all(v),o);cout<<"}"<<endl;}
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

// icin(x)    int x; cin >> x;
// vcin(A,N)  vi(vl) Aを宣言してcinで初期化
// aout(x)    cout << x << endl;

int main(){ IOS;
    icin(X); icin(Y);
    aout(X+Y/2);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int set_num = 0;
  int max, sum;
  scanf("%d %d", &max, &sum);
  for(int i = 0; i <= max; i++){
    for(int j = 0; j <= max; j++){
      int z = sum - i - j;
      if(z >= 0 && z<= max){
        set_num += 1;
      }
    }
  }

  printf("%d\n", set_num);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012

int main(){
    ll i,j;
    ll n;
    
    VVI v(6060,VI(6060,0));
    string s,t;
    ll ans=0;
    cin>>s>>t;
    for(i=0;i<3;i++) if(s[i]==t[i]) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 287488
#include<cmath>
#include<cstdio>
#include<cstring>

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

using namespace std;

typedef	long long	ll;

int main(){
	ll order[9];
	rep(i,9)	order[i]=(i+1)*9*(ll)pow(10.,i);

	for(int n,k;scanf("%d%d",&n,&k),n;){
		int p;
		for(p=0;p<9;p++){
			if(n<=order[p])	break;
			n-=order[p];
		}

		int startnum=(int)pow(10.,p)+(n-1)/(p+1);
		int startdgt=(n-1)%(p+1);
		char ans[1024]="",tmp[1024];
		sprintf(tmp,"%d",startnum);
		strcat(ans,tmp+startdgt);
		for(int i=0,j=startnum+1;i<k;i+=p+1,j++){
			sprintf(tmp,"%d",j);
			strcat(ans,tmp);
		}
		ans[k]='\0';
		puts(ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector< vector<int> > data(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> data[i][j];
			if (j != 0) {
				data[i][j] += data[i][j-1];
			}
		}
	}
	int MAX = data[0][0];
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			for (int k = 0; k < n; k++) {
				for (int l = k; l < n; l++) {
					int dd = 0;
					for (int m = k; m <= l; m++) {
						if (i == 0) {
							dd += data[m][j];
						} else {
							dd += data[m][j]-data[m][i-1];
						}
					}
					MAX = max(MAX, dd);
				}
			}
		}
	}
	cout << MAX << endl;
	return 0;
}

Measured memory_bytes: 1256
#coding: UTF-8

from bisect import bisect_right

# 指定した数以下の素数の個数を返却する
# 素数判定はエラストテネスのふるい

# 要素1000000のリスト（素数かどうかのリスト）を準備
max_number = 1000000
prime_flag_list = [True] * max_number

# 0、1は素数でない
prime_flag_list[0] = False
prime_flag_list[1] = False

# 2の倍数（2を除く）は素数でない
prime_flag_list[4::2] = [False] * len(prime_flag_list[4::2])

# 3以上の数について、素数ならその倍数を振るい落とす
for i in range(3, int(max_number**0.5) + 1, 2):
    prime_flag_list[i*i::i] = [False] * len(prime_flag_list[i*i::i])

# フラグの立ったままの箇所は素数なので、そこだけ取り出す
prime_list = [i for i in range(2, max_number) if prime_flag_list[i]]

while True:
    try:
        input = int(raw_input())
    except EOFError:
        break
        
    # 素数リスト（ソート済み）の中に、入力した数値を入れるとしたら何項目目になるかを
    # bisectで求める
    print bisect_right(prime_list, input)

Measured memory_bytes: 44524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long[] a = new long[n+1], b = new long[n];
		long c = 0;

		for(int i = 0; i < n+1; i++)
			a[i] = in.nextInt();
		for(int i = 0; i < n; i++)
			b[i] = in.nextInt();


		for(int i = 0; i < n; i++) {
			if(a[i] <= b[i]) {
				c += a[i];
				b[i] -= a[i];
			}else {
				c += b[i];
				b[i] = 0;
			}

			if(a[i+1] <= b[i]) {
				c += a[i+1];
				a[i+1] = 0;
			}else {
				c += b[i];
				a[i+1] -= b[i];
			}
		}

		System.out.println(c);
	}
}


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

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

    ll x = n < b ? n : b - 1;
    ll ans = floor((a * x) / b) - a * floor(x / b);

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


Measured memory_bytes: 3584
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int dp[3][310][310];

int main() {
	int n,m;
	while(scanf("%d%d",&n,&m)!=EOF){
		int i,j;
		memset(dp,0,sizeof(dp));
		for(i=1;i<=n;i++){
			char buf[1000];
			fgets(buf,1000,stdin);
			fgets(buf,1000,stdin);
			int c,v,d,l;
			scanf("%d%d%d%d",&c,&v,&d,&l);
			for(j=0;j<=m;j++){
				if(j<c){
					dp[0][i][j]=dp[0][i-1][j];
					dp[1][i][j]=dp[1][i-1][j];
					dp[2][i][j]=dp[2][i-1][j];
				}else{
					dp[0][i][j]=max(dp[0][i-1][j],dp[0][i][j-c]+v);
					dp[1][i][j]=max(dp[1][i-1][j],dp[1][i][j-c]+d);
					dp[2][i][j]=max(dp[2][i-1][j],dp[2][i][j-c]+l);
				}
			}
		}
/*
for(int ii=0;ii<=n;ii++){
for(int jj=0;jj<=m;jj++){
cout<<ii<<" "<<jj<<" ";
cout<<dp[0][ii][jj]<<" ";
cout<<dp[1][ii][jj]<<" ";
cout<<dp[2][ii][jj]<<" ";
cout<<endl;
}
}
*/
		int res=0;
		chmax(res,dp[0][n][m]);
		chmax(res,dp[1][n][m]);
		chmax(res,dp[2][n][m]);
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 2016
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

bool isOK(ll n, int k) {
  while(n % k == 0) {
    n /= k;
  }
  return n % k == 1;
}

int main(void) {
  ll n;
  cin >> n;
  ll res = 1; // k = n
  for(ll k = 2; k*k <= n; ++k) {
    if(n % k == 0) {
      if(isOK(n, k)) {
        ++res;
      }
      if(n / k != k && isOK(n, n/k)) {
        ++res;
      }
    }
  }
  if(n > 2) {
    ++res; // k = n-1
    for(ll k = 2; k*k <= n-1; ++k) {
      if((n-1) % k == 0) {
        ++res;
        if((n-1) / k != k) {
          ++res;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <queue>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    map<int, vector<int>> link;
    int a, b;
    for (int i = 0; i < M; i++){
        cin >> a >> b;
        link[a].push_back(b);
        link[b].push_back(a);
    }
    map<int, int> sign;
    vector<int> dist(N, -1);
    queue<int> q;
    q.push(1);
    dist[0] = 0;
    while(!q.empty()){
        int p = q.front();
        q.pop();
        for (auto np : link[p]){
            if (dist[np-1] != -1) {
                continue;
            }
            dist[np-1] = dist[p-1] + 1;
            sign[np] = p;
            q.push(np);
            // cout << "sign " << np << ": "<< p << endl;
        }
    }
    cout << "Yes" << endl;
    for (int i = 2; i <= N; i++) {
        cout << sign[i] << endl;
    }
}




Measured memory_bytes: 20440
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

bool check(int i, int male0, string sex) {
    if(sex == "Male" && male0 == true && i % 2 == 0)
        return true;
    if(sex == "Female" && male0 == true && i % 2 == 1)
        return true;
    if(sex == "Male" && male0 == false && i % 2 == 1)
        return true;
    if(sex == "Female" && male0 == false && i % 2 == 0)
        return true;
    return false;
}

int main() {
    int N;
    cin >> N;
    int l = 0, r = N;
    cout << 0 << "\n" << flush;
    string S;
    cin >> S;
    int male0 = 0;
    if(S == "Vacant")
        return 0;
    else if(S == "Male")
        male0 = 1;
    while(1) {
        int mid = (l + r) / 2;
        cout << mid << "\n" << flush;
        string s;
        cin >> s;
        if(s == "Vacant") {
            return 0;
        }
        if(check(mid, male0, s)) {
            l = mid;
        } else
            r = mid;
    }
    return 0;
}

Measured memory_bytes: 852
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
zahyo = [l() for _ in range(N)]
zahyo2 = [sum(zahyo[i]) for i in range(N)]
zahyo3 = [zahyo[i][0]-zahyo[i][1] for i in range(N)]
ans = 0
print(max(max(zahyo2)-min(zahyo2),max(zahyo3)-min(zahyo3)))

Measured memory_bytes: 130924
g = [[int(i) for i in input().split()] for i in range(3)]
res = 'No'

for a1 in range(101):
    b1 = g[0][0] - a1
    b2 = g[0][1] - a1
    b3 = g[0][2] - a1
    for a2 in range(101):
        if (a2 + b1) == g[1][0] and (a2 + b2) == g[1][1] and (a2 + b3) == g[1][2]:
            for a3 in range(101):
                if (a3 + b1) == g[2][0] and (a3 + b2) == g[2][1] and (a3 + b3) == g[2][2]:
                    res = 'Yes'
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,ans;
main(){
cin>>n;
for(int k=1;k<=n;k++){
   string s;
   s=to_string(k);
   if(s.size()%2==1){
    ans++;
   }
}
cout<<ans;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int k, n;
	int p[10000];
	ll ans = 0;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	qsort(p, n, sizeof(int), cmpint);
	for (int i = 0; i < k; i++) {
		ans += p[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1744
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N, K;
    cin >> N >> K;
    int h[N];
    REP(i, N) cin >> h[i];

    int count = 0;
    REP(i, N) {
        if (h[i] >= K) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    string a[n],b[n];
    REP(i,n){
        cin >> a[i];
    }
    REP(i,m){
        cin >> b[i];
    }
    REP(i,n){
        REP(j,n){
            if(i + m <= n && j + m <= n){
                REP(k,m){
                    REP(l,m){
                        if(b[k][l] != a[i + k][j + l]) goto no;
                    }
                }
                cout << "Yes" << endl;
                return 0;
                no:;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <iostream>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ll long long int
int a[100007];
ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
int main() {
	int n; cin >> n;
	rep(i, n)
		cin >> a[i];
	int ans = a[0];
	for (int i = 1; i < n; i++) {
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
using System;

namespace ABC127_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = sss[0];
            var b = sss[1];
            if(a<=5)
            {
                Console.WriteLine(0);
                return;
            }
            else if(6<= a && a<= 12)
            {
                Console.WriteLine(b / 2);
                return;
            }
            else
            {
                Console.WriteLine(b);
                return;
            }
             
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define MAXN 400
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
map<LL,LL> mp;
int col[MAXN+5][4];
LL Translate(int seq[4])
{
	LL x=0;
	for(int i=3;i>=0;i--)
		x=1000LL*x+1LL*seq[i];
	return x;
}
void Add(int seq[4],int val)//以块为单位进行计算 
{
	LL num=Translate(seq);
	for(int tmn=0;tmn<4;tmn++)
	{
		num/=1000LL;
		num+=seq[tmn]*1000000000LL;
		mp[num]+=val;
	}
}
LL Query(LL x)
{
	if(mp.find(x)==mp.end())
		return 0LL;
	return mp[x];
}
void GetSeq(int a0,int a1,int a2,int a3,int seq[4])
{
	seq[0]=a0;seq[1]=a1;seq[2]=a2;seq[3]=a3;
}
int main()
{
//	freopen("in.txt","r",stdin);
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d %d %d %d",&col[i][0],&col[i][1],&col[i][2],&col[i][3]);
		Add(col[i],1);
	}
	int val[4][4];
	LL ans=0,tot=0;
	LL ansn[4];
	for(int i=1;i<=N;i++)
	{
		for(int tmn=1;tmn<=4;tmn++)
		{
			Add(col[i],-1LL);
			for(int j=i+1;j<=N;j++)
			{
				Add(col[j],-1LL);
				tot=1LL;
				GetSeq(col[j][1],col[j][0],col[i][1],col[i][0],val[0]);
				GetSeq(col[j][2],col[j][1],col[i][0],col[i][3],val[1]);
				GetSeq(col[j][0],col[j][3],col[i][2],col[i][1],val[2]);
				GetSeq(col[j][3],col[j][2],col[i][3],col[i][2],val[3]);
				//==================
				ansn[0]=Query(Translate(val[0]));
				ansn[1]=Query(Translate(val[1]));
				ansn[2]=Query(Translate(val[2]));
				ansn[3]=Query(Translate(val[3]));
				if(ansn[0]&&ansn[1]&&ansn[2]&&ansn[3])
				{
					tot*=Query(Translate(val[0]));
					Add(val[0],-1LL);
					tot*=Query(Translate(val[1]));
					Add(val[1],-1LL);
					tot*=Query(Translate(val[2]));
					Add(val[2],-1LL);
					tot*=Query(Translate(val[3]));
					Add(val[0],1LL);
					Add(val[1],1LL);
					Add(val[2],1LL);
					ans+=tot;
				}
				//==================
				Add(col[j],1LL);
			}
			Add(col[i],1LL);
			int first=col[i][0];
			for(int k=0;k<3;k++)
				col[i][k]=col[i][k+1];
			col[i][3]=first;
		} 
	}
	printf("%lld\n",ans/3LL);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, K;
	long long h[100000], min = 10000000000;
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &h[i]);
	}
	sort(h, h + N, greater<int>());
	for (int i = 0; i < N - K + 1; i++) {
		if (h[i] - h[i + K - 1] < min) {
			min = h[i] - h[i + K - 1];
		}
	}
	printf("%lld", min);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll d;
    cin >> n >> d;
    vector<ll> x(n),y(n);
    rep(i,n) cin >> x[i] >> y[i];
    int ans=0;
    rep(i,n){
        if(d*d>=x[i]*x[i]+y[i]*y[i]) ++ans;
    }
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 6360
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> vertices(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    vertices[a].push_back({i, b});
    vertices[b].push_back({i, a});
  }

  vector<int> ans(n - 1, 0);
  vector<bool> visited(n, false);

  // ノード番号，親の色
  queue<pair<int, int>> q;
  q.push({0, 0});

  int max_n = 0;
  while (!q.empty()) {
    auto idx = q.front().first, p_color = q.front().second;
    q.pop();
    if (visited[idx]) {
      continue;
    }

    visited[idx] = true;

    // v.first: 辺のインデックス
    // v.second: 辺の向かう先
    int color = 1;
    for (auto v : vertices[idx]) {
      if (p_color == color) {
        color++;
      }

      if (ans[v.first] == 0) {
        q.push({v.second, color});
        ans[v.first] = color;
        color++;
      }
    }

    max_n = max(max_n, color - 1);
  }

  cout << max_n << '\n';
  for (auto c : ans) {
    cout << c << '\n';
  }
}

Measured memory_bytes: 7040
#include <iostream>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
long long N;
const long long MAX_NUM = 1e5;
long long Pri[100001];
long long L[100001];
long long a[1005];
long long ans;
map<long long, long long> M;
void check(long long T) {
    long long temp = 0;
    for(long long i = 1; i <= N; i++)
        if(a[i] % T == 0)
            temp += a[i];
    ans = max(temp, ans);
}
void  resolve(long long n) {
    if(n == 1)
        return ;
    for (long long i = 1; i <= L[0]; i++)
        if (n % L[i] == 0) {
            if(M[L[i]] >= 0)
                check(L[i]);
            while(n % L[i] == 0 && n > 1)
                n /= L[i];
        }
    if(n != 1)
        check(n);
}
int main() {
	for (long long i = 2; i <= MAX_NUM; i++)
		Pri[i] = 1;
	for (long long i = 2; i <= MAX_NUM; i++) {
		if (Pri[i])
			for (long long j = 2 * i; j <= MAX_NUM; j += i)
				Pri[j] = 0;
	}
	for (long long i = 2; i <= MAX_NUM; i++)
		if (Pri[i])
			L[++L[0]] = i;
    cin >> N;
    for(long long i = 1; i <= N; i++)
        cin >> a[i];
    for(long long i = 1; i <= N; i++)
        resolve(a[i]);
    cout << ans << endl;
	return 0;
}




Measured memory_bytes: 3996
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
    exit()


Flag = True
i = 0
while Flag:
    if (x - i) not in p:
        print(x - i)
        break
    elif (x + i) not in p:
        print(x + i)
        break
    i += 1


Measured memory_bytes: 9116
/* ***********************************************
Author        :yang12138
Created Time  :2017年05月18日 星期四 10时50分49秒
File Name     :B.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=105;
int in[N];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	int n,m; 
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		in[u]++,in[v]++;
	}
	for(int i=1;i<=n;i++) cout<<in[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
// Marcin Knapik
// before you read it
// make sure it's a good idea
#include<bits/stdc++.h>
using namespace std;

typedef long long         ll;
typedef unsigned long long      ull;
typedef pair< ll, ll >        pll;
typedef pair< int, int  >       ii;
typedef vector< int  >       vi;
typedef vector< ii >        vii;
typedef vector< vi >        vvi;
typedef vector< vector < ii > >   vvii;
typedef vector< ll >        vll;
typedef vector< pll >       vpll;
typedef long double         ld;

#define boost   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define szy     first
#define gi      second
#define sz(a)   (int)(a).size()
#define pb      push_back
#define all(c)    (c).begin(), (c).end()
#define rall(c)   (c).rbegin(), (c).rend()


template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template<class T> inline T sub(T a, T b, T mod) {return ((a - b)+mod)%mod;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

ld e = 2.7182818284590452353602874713526624;
ld PI = acos(-1);
ld eps = 1e-11;

const ll T = 1 << 19;
const ll INF = 1e9 + 7;
const ll BIG_INF = 1e18 + 5;
const long long  N = 44 + 7;
ll n, m, k;
string a, b;

int main(){
	boost;
	cin >> n;
	vi tab(n);
	cin >> tab;
	int ans = 0;
	for(int i = 1 ; i < n-1 ; i++){
		vi pom;
		pom.pb(tab[i-1]);
		pom.pb(tab[i]);
		pom.pb(tab[i+1]);
		sort(all(pom));
		if(tab[i] == pom[1])
			ans++;
	}
	cout << ans << '\n';
}		

Measured memory_bytes: 384
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=10000;

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

	if((A*B)%2)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define pb push_back
#define int long long
#define pi pair<int , int>
#define mp make_pair
vector<int> edges[N];
bool visited[N];
int parent[N];
int find(int x){
 if(parent[x] == -1){
 return x;
 }
 return find(parent[x]);
}
int n  , m ;
int arr[N];
int32_t main(){
cin>>n>>m;
for(int i = 0 ;i < n ;i++){
 cin>>arr[i];
}
memset(visited , true , sizeof(visited));
set<pi> st;
for(int i = 0 ; i  < m ; i++){
	int x , y;
	cin>>x>>y;
	if(st.find({x-1 , y-1}) == st.end() || st.find({y-1 , x-1}) == st.end()){
	edges[--x].pb(--y);
	edges[y].pb(x);
}
	//~ if(arr[x] >= arr[y]){
	 //~ visited[y] = false;
	//~ }
	//~ else if(arr[y] >= arr[x]){
	 //~ visited[x] = false;
	//~ }
}
//~ int cnt = 0;
//~ for(int i = 0 ; i < n ;i++){
  //~ if(visited[i])cnt++;
//~ }
//~ cout<<cnt<<endl;
int cnt = 0;
for(int i = 0 ; i < n; i++){
	bool ok = true;
 for(int j = 0 ; j  < (int)edges[i].size() ; j++){
    if(arr[i] <= arr[edges[i][j]]){
	  ok = false;
	  break;
	}
 }
 if(ok)cnt++;
}
cout<<cnt<<endl;
}


Measured memory_bytes: 12800
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,X; cin >> N >> X;
    vector<ll> b(N),l(N),u(N);
    rep(i,N) cin >> b[i] >> l[i] >> u[i];

    ll V = 0;
    rep(i,N) V += b[i]*l[i];
    vector<pll> A(N);
    rep(i,N) A[i] = pll(l[i]*b[i]+u[i]*(X-b[i]),i);
    sort(all(A));
    reverse(all(A));
    auto func=[&](ll x) {
        ll p = x/X;
        ll q = x%X;
        vector<bool> check(N);
        ll val = 0;
        rep(i,p) {
            check[A[i].second] = 1;
            val += A[i].first;
        }
        ll ret = 0;
        rep(i,N) {
            ll tmp;
            if (b[i] >= q) tmp = q*l[i];
            else tmp = b[i]*l[i] + (q-b[i])*u[i];

            if (check[i]) chmax(ret,val-(b[i]*l[i]+(X-b[i])*u[i])+A[p].first+tmp);
            else chmax(ret,val+tmp);  
        }
        return ret >= V;
    };
    ll ng = -1;
    ll ok = N*X;
    while (ok-ng>1) {
        ll mid = (ok+ng)/2;
        if (func(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << ln;
}


Measured memory_bytes: 7160
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt() % 10;
        String ans = "";
      
        if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9){
          ans = "hon";
        }else if(a == 0 || a == 1 || a == 6 || a == 8){
          ans = "pon";
        }else if(a == 3){
          ans = "bon";
        }
        
      	System.out.println(ans);
 
    }
}

Measured memory_bytes: 35744
d[1<<22],i,N,p;w[99];main(j){for(*d=1;~scanf("%d",w+i++););for(N=*w;p<N<<N;d[i]+=(j<i)*d[j]*w[__builtin_popcount(j)*N+p++%N+1],d[i]%=j=1e9+7)i=(j=p/N)|1<<p%N;printf("%d",d[i]);}

Measured memory_bytes: 10368
while True:
    try:
        p = list(map(float, input().split(',')))
    except:
        break
    v = [p[i] - p[(i + 2) % 8] for i in range(8)]
    ip = [v[i] * v[(i + 3) % 8] - v[i + 1] * v[(i + 2) % 8] > 0 for i in range(0,8,2)]
    if sum(ip) == 0 or sum(ip) == 4:
        print('YES')
    else:
        print('NO')

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

using namespace std;

int main() {

    string S;
    cin >> S;

    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

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

int d[110][110];
int edge[110][110];
const int INF = 114514810;
int n, m;

int main(void) {
    rep(i, 110) rep(j, 110) {
        d[i][j] = edge[i][j] = INF;
    }

    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        //scanf("%d%d%d", &a, &b, &c);
        cin >> a >> b >> c;
        --a; --b;
        d[a][b] = d[b][a] = c;
        edge[a][b] = edge[b][a] = c;
    }

    rep(k, n) rep(i, n) rep(j, n) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (edge[i][j] == INF) continue;
            if (d[i][j] == edge[i][j]) ++cnt;
        }
    }

    int ans = m - cnt;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())
    A = [int(i) for i in readline().split()]

    ans = N - sum(A)
    print(max(ans, -1))


if __name__ == "__main__":
    main()


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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}
template<typename T> inline T dmax(T x, T y){return x > y ? x : y;}
template<typename T> inline T dmin(T x, T y){return x < y ? x : y;}

const int MAXN = 2e5 + 5;
const ll oo = 2e18;

int a[MAXN], N;

ll pre[MAXN];

int dpre[MAXN], dsuf[MAXN];

inline ll get(int cl, int cm, int cr){
	return abs((pre[cm] - pre[cl - 1]) - (pre[cr] - pre[cm]));
}

int main(){
#ifdef cydiater
	freopen("input.in", "r", stdin);
#endif
	scanf("%d", &N);
	up (i, 1, N) scanf("%d", &a[i]);
	up (i, 1, N) pre[i] = pre[i - 1] + a[i];
	int cl = 1;
	up (i, 2, N) {
		while (cl + 1 < i && get(1, cl, i) > get(1, cl + 1, i)) cl++;
		dpre[i] = cl;
	}
	int cr = N;
	down (i, N - 1, 1) {
		while (cr - 1 > i && get(i, cr - 1, N) > get(i, cr - 2, N)) cr--;
		dsuf[i] = cr;
	}
	ll ans = oo;
	up (i, 2, N - 2) {
		int pp = dpre[i], qq = dsuf[i + 1] - 1;
		ll mx = -oo, mn = oo;
		cmax(mx, pre[pp]); cmin(mn, pre[pp]);
		cmax(mx, pre[i] - pre[pp]); cmin(mn, pre[i] - pre[pp]);
		cmax(mx, pre[qq] - pre[i]); cmin(mn, pre[qq] - pre[i]);
		cmax(mx, pre[N] - pre[qq]); cmin(mn, pre[N] - pre[qq]);
		cmin(ans, mx - mn);
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power( ll a, ll n, ll m){
  ll ans = 1;
  while(n){
  if(n&1)
  {
  ans *= a;
  ans%=m;
  }
  a*=a;
  n/=2;
  }
  return ans ;
} 


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){
string s;
cin>>s;

if( s.length() != 6)
{
	cout <<"No\n";
	return 0 ;
}

if(s[2]==s[3] && s[4]==s[5]){
	
	cout<<"Yes\n";
	return 0 ;
	
}


cout<<"No\n";
return 0 ;





return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    const int M = 300;
    int h, w; cin >> h >> w;
    vector<string> s(h); for (auto &si: s) cin >> si;
    vector<vector<bool>> b(M * 2, vector<bool>(M * 2));
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        if (s[i][j] == '#') b[i + j][i - j + M] = true;
    }
    auto calc = [&](bool rev) {
        if (rev) rep(i, M * 2) rep(j, i) swap(b[i][j], b[j][i]);
        vector<vector<int>> acc(M * 2, vector<int>(M * 2 + 1));
        rep(i, M * 2) rep(j, M * 2) acc[i][j + 1] = acc[i][j] + b[i][j];
        long long ans = 0;
        rep(i, M * 2) rep(j, M * 2) if (b[i][j]) {
            for (int k = j + 1; k < M * 2; k++) if (b[i][k]) {
                int d = k - j, lf = rev ? j + 1 : j, rg = rev ? k : k + 1;
                if (0 <= i - d)    ans += acc[i - d][rg] - acc[i - d][lf];
                if (i + d < M * 2) ans += acc[i + d][rg] - acc[i + d][lf];
            }
        }
        return ans;
    };
    cout << calc(false) + calc(true) << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int count = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(void){
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  if(S[K - 1] == 'A'){
    S[K - 1] = 'a';
  }else if(S[K - 1] == 'B'){
    S[K - 1] = 'b';
  }else if(S[K - 1] = 'C'){
    S[K - 1] = 'c';
  }
  cout << S << endl;
  return 0;
}


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

typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	ll INF = 1LL<<60;
	ll n,k,q;
	cin>>n>>k>>q;
	
	vector<ll> a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	auto check = [&](ll m)
	{
		vector<vector<ll> > v;
		v.push_back(vector<ll>());
		for(int i=0;i<n;i++)
		{
			if(a[i]>m)
				v[v.size()-1].push_back(a[i]);
			else
				v.push_back(vector<ll>());
		}
		ll c = 0;
		for(auto u:v)
			c+=max((ll)(u.size()-k+1),0LL);
		
		if(c<q)
			return INF;
		vector<ll> w;
		for(auto u:v)
		{
			if(u.size()<k)
				continue;
			sort(u.begin(),u.end());
			for(int j=0;j<u.size() - k+1;j++)
				w.push_back(u[j]);
		}
		sort(w.begin(),w.end());
		return w[q-1] - w[0];
	};
	
	
	ll ans = check(0);
	
	for(int i=0;i<n;i++)
		ans = min(ans,check(a[i]));
	
	cout<<ans;
	
}

Measured memory_bytes: 384