akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才的ですよね

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;

}
int KH[300001], KW[300001];
int h[300001], w[300001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H = getint(), W = getint(), M = getint();

	rep(i, M) {
		KH[h[i] = getint()]++;
		KW[w[i] = getint()]++;
	}

	int saidaih = -1, hh = 0;
	rep1(i, H) {
		if (saidaih < KH[i]) {
			saidaih = KH[i];
			hh = 1;
		}
		else if (saidaih == KH[i]) hh++;
	}
	int saidaiw = -1, ww = 0;
	rep1(i, W) {
		if (saidaiw < KW[i]) {
			saidaiw = KW[i];
			ww = 1;
		}
		else if (saidaiw == KW[i]) ww++;
	}

	ll are = ll(hh) * ww;

	int kazu = 0;
	rep(i, M) {
		kazu += (KH[h[i]] == saidaih && KW[w[i]] == saidaiw);
	}

	printf("%d\n", saidaih + saidaiw - (kazu == are));

	Would you please return 0;
}

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

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i,n-1){
    ans += (n-1) / (i+1);
    
    
  }
  cout << ans;
    
  
  return 0;
}




Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i;
    double prod=1,sum=0;
    cin>>n;
    double arr[n];
    for(i=0;i<n;i++){
        cin>>arr[i];
        prod*=arr[i];
    }
    for(i=0;i<n;i++)
        sum=sum+(prod/arr[i]);
    cout<<prod/sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int map[109][109][109];
int main(){
	long long  ans=0;
	int s[1009];
	int a;
	cin>>a; 
	for(int i=1;i<=a;i++)
	cin>>s[i];
	sort(s+1,s+1+a);
	for(int i=1;i<=a;i++){ 
		for(int j=i+1;j<=a;j++){
			for(int k=j+1;k<=a;k++){
				if(s[i]==s[j]||s[j]==s[k])
				continue;
				if(s[i]+s[j]>s[k]&&s[i]+s[k]>s[j]&&s[k]+s[j]>s[i])
				ans++;
			}
		}
	}

	cout<<ans<<endl;
} 

Measured memory_bytes: 3196
#include<stdio.h>
int main(){
	
	int W,H;
	int x,y,r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(0<=x-r&&x+r<=W&&0<=y-r&&y+r<=H){
		puts("Yes");
	}
	else{
		puts("No");
	}
	
	return 0;
}


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

char s[100010];

int main() {
    scanf("%s", s);
    int n = strlen(s);
    int err1 = 0, err2 = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 + '0' != s[i]) {
            err1++;
        }
        if ((1 - i % 2) + '0' != s[i]) {
            err2++;
        }
    }
    printf("%d\n", min(err1, err2));
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(10);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

bool check(ll K,vl a){
    ll N = a.size();
    FOR(i,0,N)a[i] += K;
    FOR(i,0,N){
        a[i] = ((a[i]-(N-1))+N)/(N+1);
    }
    ll sum = 0;
    FOR(i,0,N)sum += a[i];
    return (sum == K);
}

signed main(){
    ll N;
    cin >> N;
    vl a(N);
    FOR(i,0,N)cin >> a[i];
    sort(ALL(a),greater<ll>());
    if(a[0] < N){
        cout << 0 << endl;
        return 0;
    }
    ll sum = 0;
    FOR(i,0,N)sum += a[i];
    FOR(i,max(sum-N*(N-1),1),sum+1){
        if(check(i,a)){
            cout << i << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include<stdio.h>


int main(){
	int A[4],B[4];
	int i,j,k;
	while(~scanf("%d %d %d %d",&A[0],&A[1],&A[2],&A[3])){
		int hit=0,blow=0;
		scanf("%d %d %d %d",&B[0],&B[1],&B[2],&B[3]);
		for(i=0;i<4;i++){
			if(B[i]==A[i]){
				hit++;
			}
			else {
				for(j=0;j<4;j++){
					if(i!=j){
						if(B[i]==A[j])
							blow++;
					}
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    long sum = 0;
    cin >> n;
    vector<int> a(n) , b(n), c(n-1);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n-1; i++) cin >> c[i];
    for(int i = 0; i < n; i++){
        sum += (long) b[a[i]-1];
        if((a[i+1] == a[i] + 1)&&(i < n-1)){
            sum += (long) c[a[i]-1];
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
info = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    info.append(tmp)
diff = [[info[0][0], info[0][1]+info[0][2]]]
for i in range(n-1):
    time_diff = info[i+1][0] - info[i][0]
    dist_diff = abs(info[i+1][1]-info[i][1]) + abs(info[i+1][2]-info[i][2])
    diff.append([time_diff, dist_diff])
    
flg = 0
for i in range(len(diff)):
    if diff[i][0] < diff[i][1] or (diff[i][0]- diff[i][1]) % 2 !=0:
        flg=1
        break
if flg ==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 36256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
int main(void){
	llint n,ans,T,has=big;cin>>n>>ans>>T;
	queue<pair<llint,llint>>mati;
	while(n--){
		llint x;cin>>x;x*=2;
		mati.push(mp(x,ans));
		while(x-mati.front().fir>=T){
			mineq(has,mati.front().sec-mati.front().fir);
			mati.pop();
		}
		//cout<<has<<" "<<ans<<endl;
		ans=min(has+x,mati.front().sec+T);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;

int main(){
	IOS
	int n;
	cin >> n;
	int huruf=n%10;
	if(huruf==3){
		cout << "bon" << '\n';
	}
	else if(huruf== 0 or huruf== 1 or huruf== 6 or huruf==8){
		cout << "pon" << '\n';
	}
	else{
		cout << "hon" << '\n';
  	}
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
     ll n,x;
     cin>>n;
     x=n%10;
     if(x==3)
       cout<<"bon";
     else if(x==0||x==1||x==6||x==8)
       cout<<"pon";
     else
       cout<<"hon";
   }
}

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

#define ll long long
#define F(i,m,n) for(ll i=m;i<n;i++)
#define Fr(j,n,m) for(ll j=n;j>=m;j--)
#define vll vector<ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpll vector< pll >
#define tlll tuple < ll ,ll,ll >
/*-------------------------------------*---------------------------------------*/

#define godspeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl
#define cout_array(a) cout<<#a<<"=";for(auto x: a){ cout<<x<<" ";}cout<<endl

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

const ll MAX_PRIME = 1e9+7;
const ll INF = 1e18;


/*I NEED YOU TO WORK FOR TWO HOURS ON THIS NO MATTER WHAT....THE RESULT DOESN'T MATTER.....ITS ALL ABOUT YOUR EFFORTS.
---------------------------------------------------------------------------------------------------------------------*/

ll fast_pow(ll x,ll y,ll z){
    if(y==0)return 1%z;
    else if(y==1)return x%z;
    if(y%2==0){
        ll res = fast_pow(x,y/2,z);
        return (res*res)%z;
    }
    else{
        ll res = fast_pow(x,y/2,z);
        ll temp = (res*res)%z;
        return ((x%z)*temp)%z;
    }
}
ll comb_f(ll n){
    if(n<3)return 0;
    return (n*(n-1)*(n-2))/6;
}
ll simp(ll n){
    if(n<2)return 0;
    return (n*(n-1))/2;
}
int main() {
    godspeed
    ll n;
    cin>>n;
    n = abs(n);
    ll k,d;
    cin>>k>>d;
    ll used;
        ll val = n%d;
        //deb(val);
        used = (n-val)/d;
        //deb(used);
        ll rem = k-used;
        //deb(rem);
        if(rem<=0)cout<<n-k*d<<endl;
        else if(rem&1)cout<<abs(val-d)<<endl;
        else cout<<val<<endl;
    return 0;
}

Measured memory_bytes: 3636
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var n int
var h, dp []int

func main() {
	n = readInt()
	h = make([]int, n)
	for i := range h {
		h[i] = readInt()
	}
	dp = make([]int, n)

	for i := 1; i < n; i++ {
		if i-2 >= 0 {
			dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
		} else {
			dp[i] = dp[i-1] + abs(h[i]-h[i-1])
		}
	}

	fmt.Println(dp[n-1])
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int sum = 0;
  int m = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    sum += p;
    if (m < p) {m = p;}
  }
  cout << sum - m / 2 << endl;
}

Measured memory_bytes: 256
words = input()
words = list(words)

YYMM_or_MMYY = []
YYMM_or_MMYY.append(words[0]+words[1])
YYMM_or_MMYY.append(words[2]+words[3])

YYMM_or_MMYY[0] = int(YYMM_or_MMYY[0])
YYMM_or_MMYY[1] = int(YYMM_or_MMYY[1])


if (YYMM_or_MMYY[0] < 13) and (YYMM_or_MMYY[0] > 0) and (YYMM_or_MMYY[1] < 13) and (YYMM_or_MMYY[1] > 0):
    print('AMBIGUOUS')
elif (YYMM_or_MMYY[0] < 13) and (YYMM_or_MMYY[0] > 0):
    print('MMYY')
elif (YYMM_or_MMYY[1] < 13) and (YYMM_or_MMYY[1] > 0):
    print('YYMM')
else:
    print("NA")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,m;
	cin>>h>>m;
	ll sum=0;
	for(ll i=0;i<m;i++){
		ll x;
		cin>>x;
		sum+=x;
	}
	if(sum>=h){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main()
{
    int X;
    scanf("%d",&X);

    if(400<=X&&X<=599)

        printf("8\n");
    else if(600<=X&&X<=799)
        printf("7\n");
    else if(800<=X&&X<=999)
        printf("6\n");
    else if(1000<=X&&X<=1199)
        printf("5\n");
    else if(1200<=X&&X<=1399)
        printf("4\n");
    else if(1400<=X&&X<=1599)
        printf("3\n");
    else if(1600<=X&&X<=1799)
        printf("2\n");
    else if(1800<=X&&X<=1999)
        printf("1\n");
    return 0;
}


Measured memory_bytes: 1660
# -*- coding: utf-8 -*-
n = int(input())

tmp = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(tmp[n - 1])


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

int main() {

    int n, l;
    cin >> n >> l;

    int r = n + l - 1;

    int eat;

    if (r <= 0) eat = r;
    else if (l >= 0) eat = l;
    else eat = 0;

    cout << (r + l) * (r- l + 1) / 2 - eat << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

#define Q 100

void bfs();
void enqueue(int);
int dequeue();

int head = 0,tail = 0,n;
int q[Q+1],b[Q+1][Q+1],color[Q+1] = {},d[Q+1] = {};

int main(){
  int i,j,id,k,v;
  
  scanf("%d",&n);
  for(i = 1; i < n+1; i++){
    scanf("%d %d",&id,&k);
    for(j = 0;j < k;j++){
      scanf("%d",&v);
      b[id][v] = v;
    }
  }
  
  bfs();
  
  for(i = 1; i < n+1; i++){
    if(i != 1 && d[i] == 0)printf("%d -1\n",i);
    else printf("%d %d\n",i,d[i]);
  }
  return 0;
}

void bfs(){
  int i,u;
  color[1] = -1;
  enqueue(1);
  while(head != tail){
    u = dequeue();
     for(i = 1;i < n+1;i++){
       if(b[u][i] != 0){
      if(color[i] == 0){
	color[i] = -1;
	d[i] = d[u] + 1;
	enqueue(i);
      }
     }
    }
  }
  color[u] = -2;
}

void enqueue(int a){
  int next;
  next = (tail+1)%Q;
  
  if(tail != next){
    q[tail] = a;
    tail = next;
  }
}

int dequeue(){
  int val;
  if(head != tail){
    val = q[head];
    head = (head+1)%Q;
    
  }
  return val;
}



Measured memory_bytes: 2052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= x; i++) {
    if (4*x - 2*i == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3088
'use strict'
function Main(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  var N=input.shift();
  var tojo=[input[0]];
  for(let i=1;i<input.length;i++){
    tojo[i]=Math.min(input[i],tojo[i-1]);
  }
  console.log(Math.floor(N/tojo[4])+(N%tojo[4]?1:0)+4);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 11468
#include <iostream>
#include <vector>
using namespace std;
int n, m;
pair<int, int> ranges[200100];
int score[200100];
vector<int> s[200100], e[200100];
long long dp[200100];
long long o = 0;
long long cur = 0;
long long segtree[800100];
long long lazy[800100];
void push (int x, int l, int r) {
	if (lazy[x] == 0) return;
	segtree[x] += lazy[x];
	if (l != r) {
		lazy[2*x+1] += lazy[x];
		lazy[2*x+2] += lazy[x];
	}
	lazy[x] = 0;
}
void update1 (int x, int l, int r, int p, long long v) {
	push(x, l, r);
	if (p < l || p > r) return;
	segtree[x] = max(segtree[x], v);
	if (l == r) return;
	int m = (l+r)/2;
	update1(2*x+1, l, m, p, v);
	update1(2*x+2, m+1, r, p, v);
}
void update2 (int x, int l, int r, int a, int b, long long v) {
	push(x, l, r);
	if (r < a || b < l) return;
	if (a <= l && r <= b) {
		lazy[x] += v;
		push(x, l, r);
		return;
	}
	int m = (l+r)/2;
	update2(2*x+1, l, m, a, b, v);
	update2(2*x+2, m+1, r, a, b, v);
	segtree[x] = max(segtree[2*x+1], segtree[2*x+2]);
}
int main () {
	cin >> n >> m;
	for (int i=0; i<m; i++) {
		cin >> ranges[i].first >> ranges[i].second >> score[i];
		ranges[i].first--; ranges[i].second--;
		s[ranges[i].first].push_back(i);
		e[ranges[i].second].push_back(i);
	}
	for (int i=0; i<n; i++) {
		for (auto j: s[i]) {
			cur += score[j];
		}
		push(0, 0, n-1);
		dp[i] = cur+segtree[0];
		o = max(o, dp[i]);
		update1(0, 0, n-1, i, segtree[0]);
		for (auto j: e[i]) {
			cur -= score[j];
			update2(0, 0, n-1, ranges[j].first, ranges[j].second, score[j]);
		}
	}
	cout << o << endl;
}

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

int A[21] = {} , B[21] = {};
int main(){
	double a,b;
	while(cin >> a >> b){
		a *= 10;
		b *= 10;
		A[(int)(a+1e-9)]++;
		B[(int)(b+1e-9)]++;
	}
	int x,y;
	x=0; for(int i = 11 ; i < 21 ; i++) x += A[i];
	y=0; for(int i = 11 ; i < 21 ; i++) y += B[i];
	cout << x << " " << y << endl;
	x=0; for(int i = 6 ; i < 11 ; i++) x += A[i];
	y=0; for(int i = 6 ; i < 11 ; i++) y += B[i];
	cout << x << " " << y << endl;
	x=0; for(int i = 2 ; i < 6 ; i++) x += A[i];
	y=0; for(int i = 2 ; i < 6 ; i++) y += B[i];
	cout << x << " " << y << endl;
	x=0; for(int i = 0 ; i < 2 ; i++) x += A[i];
	y=0; for(int i = 0 ; i < 2 ; i++) y += B[i];
	cout << x << " " << y << endl;
}

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

typedef long double ld;
#define int long long   
#define PB push_back 
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vii vector< ii >
#define F first
#define S second 
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
ld pi= 3.14159265358979;
//const int mod=998244353; 
const int mod = 1e9+7;
const int N=2e5+5;

void solve()
{   
		ld a, b; cin>>a>>b;
		ld z = a*b;
		int p = floor(z);
		cout<<p;
	
}

signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  //  cout<<setprecision(20);
    int tc=1;// cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int fact(int n)
{
    if (n==0)
        return 1;
    if (n==1)
        return 1;
    return n * fact(n-1);
}

int main()
{
    int n;
    cin>>n;
    string P,Q;
    char k;
    //vector<int> P(n);
    //vector<int> Q(n);
    for(int i=0; i<n; i++)
        {cin>>k;
         P+=k; }
    for(int i=0; i<n; i++)
        {cin>>k;
         Q+=k; }
    int a=0 ,b=0;
    while(prev_permutation(P.begin(), P.end()))
        a++;
    while(prev_permutation(Q.begin(), Q.end()))
         b++;
    //cout<<a<<"  "<<b<<" ";
    if(a<b)
        cout<<b-a;
    else
        cout<<a-b;
    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>    
#include <unordered_map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cerr<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,x,n) for(int i=x;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define w(x) int x;cin>>x;while(x--)
#define display(a,n) {fo(i,n) {cout<<a[i]<<" ";}cout<<endl;}
#define fil(a,n,val) {fo(i,n) a[i]=val; }
const ll MOD   = 1000*1000*1000+7;
const ll MOD2  = 998244353;
const ll N = 1000*1000+5;
const double PI  = 3.14159265;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
ll search(vl arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
const int maxn=3e5+5;

int dp[maxn][3];
int a[maxn], b[maxn], c[maxn],n;

int solve(int ac, int day){
	if(day==n+1)
		return 0;
	if(dp[day][ac]!=-1)
		return dp[day][ac];

	if(day==0){
		return dp[day][ac]=max(solve(0,1),max(solve(1,1), solve(2,1)));
	}
	if(ac==0){
		return dp[day][ac]=a[day]+max(solve(1,day+1), solve(2,day+1));
	}
	else if(ac==1){
		return dp[day][ac]=b[day]+max(solve(0,day+1), solve(2,day+1));
	}
	else{
		return dp[day][ac]=c[day]+max(solve(0,day+1), solve(1,day+1));
	}
}

int main(){
	fastio();
	scanf("%d", &n);
	foo(i,1,n+1){
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
	}
	fo(i,n+1){
		fo(j,3){
			dp[i][j]=-1;
		}
	}

	cout<<solve(0,0)<<endl;


}

Measured memory_bytes: 12244
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

const int MAXN = 8000;

int main() {

	string s; cin >> s;
	s.push_back('*');
	int x, y; cin >> x >> y;

	int cnt = 0;
	vector<int> d[2];
	int p = 0;

	int i = 0;
	while (i < s.size()) {
		if (s[i] == 'F') {
			cnt++;
		}
		else {

			d[p].push_back(cnt);
			p = (p + 1) % 2;
			cnt = 0;

			while (s[i] == 'T' && s[i+1]=='T') {
				i++;
				p = (p + 1) % 2;
			}
		}

		i++;
	}

	//マイナスの座標をそのまま書きたいが配列の添字はマイナスにできないので
	//プラスの方向にずらしておく

	//dp[i番目の方向転換のときに][座標j]にいることができるか?


	vector<vector<int>> dp(MAXN, vector<int>(MAXN*2+1));

	dp[0][8000] = 1;

	for (int i = 0; i < d[0].size(); i++) {

		for (int j = 0; j < MAXN*2+1; j++) {

			if (j - d[0][i] > 0)dp[i+1][j] |= dp[i][j - d[0][i]];
			if (i == 0)continue;

			if (j + d[0][i] <MAXN*2)dp[i+1][j] |= dp[i][j+d[0][i]];
		}
	}

	bool okx = dp[d[0].size()][8000 + x];

	for (int i = 0; i < MAXN; i++) {
		for (int j = 0; j < MAXN*2+1; j++) {
			dp[i][j] = 0;
		}
	}
	
	dp[0][8000] = 1;

	for (int i = 0; i < d[1].size(); i++) {

		for (int j = 0; j < MAXN * 2+1; j++) {

			if (j - d[1][i] > 0)dp[i + 1][j] |= dp[i][j - d[1][i]];
			if (j + d[1][i] < MAXN * 2)dp[i + 1][j] |= dp[i][j + d[1][i]];
		}
	}

	bool oky = dp[d[1].size()][8000 + y];

	if (okx && oky)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 500736
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
constexpr int MOD = 1000000007;
signed main(){
    string s; cin >> s;
    auto memo = vectors(s.size() + 1, 10,13,-1LL);
    vector<int>base(s.size() + 1,0LL);
    base[s.size()] = 1;
    
    for(int i = (int)s.size() - 1; i >= 0; --i)
        base[i] = (9 * base[i + 1] + base[i + 1]) % 13;
    for(int i = 0; i < 13; ++i)
        for(int j = 0; j < 10; ++j)
            memo[s.size()][j][i] = (i == j ? 1 : 0);
    
    function<int(int,int,int)>solver = [&](int digit,int num,int cmod){
        if( memo[digit][num][cmod] != -1LL) return memo[digit][num][cmod];
        memo[digit][num][cmod] = 0;
        int temp =  ( base[digit] * num ) % 13;
        int nmod =  (cmod - temp <= 0 ? cmod - temp + 13 : cmod - temp) % 13;
        int nidx = digit;
        if(s[nidx] == '?'){
            for(int i = 0; i < 10; ++i){
                memo[digit][num][cmod] += solver(digit + 1, i, nmod);
                memo[digit][num][cmod] %= MOD;
            }
        } else {
            memo[digit][num][cmod] += solver(digit + 1,s[nidx] - '0',nmod);
            memo[digit][num][cmod] %= MOD;
        }
        return memo[digit][num][cmod];
    };
    int ans = 0;
    if(s.front() == '?'){
        for(int i = 0; i < 10; ++i)
            ans += solver(1,i,5), ans %= MOD;
    } else {
        ans += solver(1,s.front() - '0',5);
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 155020
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N=sc.nextInt();
		int[][] AB=new int[N][2];
		
		
		for(int i=0;i<N;i++) {
			AB[i][1]=sc.nextInt();
			AB[i][0]=sc.nextInt();
		}
		Arrays.parallelSort(AB, (a, b) -> Integer.compare(a[0], b[0]));
		
		
		for(int i=0;i<N-1;i++) {
			if(AB[i][0]==AB[i+1][0]&&AB[i][1]>AB[i+1][1]) {
				int[] hoge=AB[i];
				AB[i]=AB[i+1];
				AB[i+1]=hoge;
			}
			
		}
		
		int sum=0;
		for(int i=0;i<N;i++) {
			sum+=AB[i][1];
			if(sum>AB[i][0]) {
				System.out.println("No");
				return;
			}
		}
		
		System.out.println("Yes");
		
	}
	
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (c/b);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 39392
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

signed main() {
  int X, N; cin >> X >> N;
  set<int> s;
  for (int i = 0; i < N; ++i) {
    int p; cin >> p;
    s.insert(p);
  }
  int d = 0;
  while (true) {
    if (!s.count(X-d)) {
      cout << X - d << endl;
      return 0;
    }
    if (!s.count(X+d)) {
      cout << X + d << endl;
      return 0;
    }
    ++d;
  }
  return 0;
}


Measured memory_bytes: 3628
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

A, B, K = input_nums()

res_a = A - K if A >= K else 0
remain = K - A
if remain > 0:
    res_b = B - remain if B >= remain else 0
else:
    res_b = B
print('{} {}'.format(res_a, res_b))

Measured memory_bytes: 38384
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input := scanner.Text()
	inputList := strings.Split(input, " ")
	n, _ := strconv.Atoi(inputList[0])

	isKuku := false
	for i := 1; i < 10; i++ {
		if n%i == 0 && 1 <= n/i && n/i <= 9 {
			isKuku = true
			break
		}
	}
	if isKuku {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

void Main() {
    string N;
    cin >> N;
    bool good = false;
    if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
        good = true;
    }
    cout << (good ? "Yes" : "No") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#define MAX 251


int main(){
  int H[MAX + 1], i, h;
  
  scanf("%d", &h); 

  for(i = 1; i <= h; i++) scanf("%d", &H[i]);

  for(i = 1; i <= h; i++){
    printf("node %d: key = %d, ", i, H[i]);
    if(i / 2 >= 1) printf("parent key = %d, ", H[i / 2]);
    if(i * 2 <= h) printf("left key = %d, ", H[i * 2]);
    if(i * 2 + 1 <= h) printf("right key = %d, ", H[i * 2 + 1]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int gcd(int a,int b){
    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

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

    int maxnum=1e6+1;
    vector<int> A(maxnum,0);
    int a;
    for(int i=0;i<N;i++){
        cin>>a;
        A[a]++;
    }

    int cnt=0;
    int flag=1;
    for(int i=2;i<maxnum;i++){
        cnt=0;
        for(int j=i;j<maxnum;j+=i){
            cnt+=A[j];
        }
        if(cnt>1){
            flag=0;
            break;
        }
    }
    if(flag){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }

    int g=-1;
    for(int i=0;i<maxnum;i++){
        if(g==-1 && A[i]>0){
            g=i;
        }else if(A[i]>0){
            g=gcd(g,i);
        }
    }

    if(g==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }

    return 0;
}

Measured memory_bytes: 7208
n = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

acc = [0]
for a in A:
    acc.append((acc[-1]+a)%mod)

ans = 0
for i in range(n-1):
    ans += ((acc[-1]-acc[i+1])*A[i])% mod
    ans %= mod

print(ans)

Measured memory_bytes: 31608
# -*- coding: utf-8 -*-

def main(S_,T):
    for i in range(len(S_)-len(T)+1):
        for j in range(len(T)):
            if S_[i+j]!="?" and T[j]!=S_[i+j]:break
        else:
            print(''.join(list(reversed((S_[:i]+T+S_[i+j+1:]).replace("?","a")))))
            exit()
    print("UNRESTORABLE")

if __name__ == '__main__':
    S_ = "".join(list(reversed(input())))
    T = "".join(list(reversed(input())))
    main(S_,T)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<62;

int main(){
    int n;
    cin>>n;
    vector<ll> v(1ll<<n);
    for(auto &a : v) cin>>a;
    sort(v.begin(),v.end());
    multiset<int> m;
    for(int i=0;i<(1ll<<n)-1;++i){
        m.insert(v[i]);
    }
    vector<int> from;
    from.push_back(v[(1<<n)-1]);
    for(int i=0;i<n;++i){
        auto to = from;
        for(auto cur : from){
            auto it = m.lower_bound(cur);
            if(it == m.begin()){
                cout << "No" << endl;
                return 0;
            }
            it--;
            to.push_back(*it);
            m.erase(it);
        }
        swap(to,from);
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 14592
n, k, c = map(int, input().split())
s = input()

dpl = [0 for i in range(n+1)]
dpr = [0 for i in range(n+1)]

for i in range(n):
    dpl[i+1] = (dpl[i] if s[i] == 'x' else
                dpl[i-c] + 1 if i-c >= 0 else
                1)

for i in range(n, 0, -1):
    dpr[i-1] = (dpr[i] if s[i-1] == 'x' else
                dpr[i+c] + 1 if i+c < n else
                1)

for i in range(1, n+1):
    if dpl[i-1] + dpr[i] < k:
        print(i)

Measured memory_bytes: 20620
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;

vector<int> coins;
int memoization[50001];

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  coins = vector<int> (m, 0);
  for (int i = 0; i < m; i++)
    cin >> coins[i];
  sort(coins.begin(), coins.end());
  memoization[0] = 0;
  for (int i = 1; i < 50001; i++)
    memoization[i] = 1 << 30;
  for (int i = 0; i <= n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      if (coins[j]+i > n) break;
      memoization[i+coins[j]] = min(memoization[i+coins[j]], memoization[i]+1);
    }
  }
  cout << memoization[n] << endl;
  return 0;
}


Measured memory_bytes: 3396
#include<set>
#include<cstdio>
#include<cctype>
#include<string>
inline int getint() {
    register char ch;
    while(!isdigit(ch=getchar()));
    register int x=ch^'0';
    while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
    return x;
}
int main() {
    std::multiset<std::string> set;
    for(register int i=getint();i;i--) set.insert("a");
    for(register int i=getint();i;i--) set.insert("b");
    for(register int i=getint();i;i--) set.insert("c");
    while(set.size()>1) {
        std::string s=*set.begin(),t=*set.rbegin();
        set.erase(set.lower_bound(s));
        set.erase(set.lower_bound(t));
        set.insert(s+t);
    }
    printf("%s\n",(*set.begin()).c_str());
    return 0;
} 

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  for (int n; cin >> n, n;) {

    vector<int> schedule[32];

    rep (i, n) {
      int m; cin >> m;
      rep (j, m) {
        int x; cin >> x;
        schedule[x].push_back(i);
      }
    }

    // b[i][j] = i can have that of j
    bool b[n][n];
    rep (i, n) {
      rep (j, n) {
        b[i][j] = i == j;
      }
    }

    rep (d, 31) {
      int cx = 0;
      rep (j, n) {
        bool bl = false;
        for (int i : schedule[d]) {
          bl |= b[i][j];
        }
        for (int i : schedule[d]) {
          b[i][j] = bl;
          //cerr << i << " can have that of " << j << " on " << d << endl;
        }
        if (bl) ++cx;
      }
      if (cx == n) {
        cout << d << endl;
        goto more;
      }
    }
    cout << (-1) << endl;

more:;

  }

  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int IMPOSSIBLE = 1000000007;

int N, M, L;
int cost[301][301]; //[from][to]

int refills[301][301]; //[from][to]

int main()
{
    cin >> N >> M >> L;
    int INF = L+1;
    for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) {
        if (i == j) {
            cost[i][j] = 0;
        } else {
            cost[i][j] = INF;
        }
    }
    rep(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        if (C <= L) {
            cost[A][B] = cost[B][A] = C;
        }
    }
    
    //! warshall floyd
    for (int k = 1; k <= N; ++k) for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
    }

    for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) {
        if (i == j) {
            refills[i][j] = 0;
        } else if (cost[i][j] <= L) {
            refills[i][j] = 1;
        } else {
            refills[i][j] = IMPOSSIBLE;
        }
    }

    //! warshall floyd again
    for (int k = 1; k <= N; ++k) for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) {
        refills[i][j] = min(refills[i][j], refills[i][k] + refills[k][j]);
    }

    int Q;
    cin >> Q;
    rep(i, Q) {
        int s, t;
        cin >> s >> t;
        cout << (refills[s][t] == IMPOSSIBLE ? -1 : (refills[s][t]-1)) << '\n';
    }
    cout << endl;

    return 0;
}


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

int main() {
 int N;cin>>N;
 double ans=0.0;
 vector<string>u(N);
 vector<double>x(N);
 for(int i = 0; i < N; i++)
 {
     cin>>x.at(i)>>u.at(i);
     if (u.at(i)=="JPY") {
         ans+=x.at(i);
     }
     else
     {
         ans+=x.at(i)*380000.0;
     }
     
     
 }
 cout<<ans<<endl;
}
 


Measured memory_bytes: 256
M,N=map(int,input().split())
list1=[]
for i in range(M):
    list2=[]
    for j in range(M):
        list2.append(10000000000)
    list1.append(list2)
#print(list1)
listN=[]
for k in range(N):
    a,b,c=map(int,input().split())
    list1[a-1][b-1]=c
    list1[b-1][a-1]=c
    listN.append([a-1,b-1,c])
for x in range(M):
    list1[x][x]=0
#print(list1)
for c in range(M):
    for a in range(M):
        for b in range(M):
            if list1[a][b]>list1[a][c]+list1[c][b]:
                list1[a][b]=list1[a][c]+list1[c][b]
#print(list1)
ans=0
for d in range(N):
    if list1[listN[d][0]][listN[d][1]]!=listN[d][2]:
        ans+=1
print(ans)

Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));
    int ans = 0;
    REP(i, K) ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 3644
Var N,i,Dem:Longint;
    A:Array[1..100000] Of Longint;
    B:Array[1..100000] Of Boolean;
Begin
        //Assign(Input,'TRAINED.INP'); Reset(Input);
        //Assign(Output,'TRAINED.OUT'); Rewrite(Output);
        Readln(N);
        Fillchar(B,SizeOf(B),False);
        For i:=1 to N Do
                Begin
                Readln(A[i]);
                End;
        Dem:=0;
        i:=1;
        B[1]:=True;
        While i<>2 Do
                Begin
                B[i]:=False;
                B[A[i]]:=True;
                i:=A[i];
                Inc(Dem);
                If Dem>N Then Break;
                End;
        If Dem>N Then Write('-1') Else Write(Dem);
        //Close(Input);
        //Close(Output);
End.


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



int main(){
    map<int,int> mp;
    vi x;
    int n,k,a; cin >> n >> k;
    
    rep(i,n){
        cin >> a;
        mp[a]++;
    }
    
    for(auto p : mp){
        if(p.second != 0) x.push_back(p.second);
    }
    
    Sort(x);
    
    int ans = 0;
    if(x.size()>k){
        for(int i=0 ; i<x.size()-k ; i++){
            ans += x[i];
        }
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 10748