akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <cstring>
typedef long long LL;

LL ans,a;
bool Query(LL q){
	printf("? %lld\n",q);
	fflush(stdout);


	char str[10];
	scanf("%s",str);
	if(str[0]=='Y') return true;
	else return false;
}
LL query(LL x,int t){
	LL y=x;
	for(int i=1;i<=t;++i) y=y*10+9;
	return y;
}
void GetFirst(){
	int l=1,r=9,mid;
	while(l<=r){
		mid=((l+r)>>1);
		LL q=query((LL)mid,10);
		if(Query(q)) r=mid-1;
		else l=mid+1;
	}
	a=r+1;
}


int GetNewbit(int len){
	int l=0,r=9,mid;


	while(l<=r){
		mid=((l+r)>>1);
		LL q=query(a*10+mid,len);
		if(Query(q)) r=mid-1;
		else l=mid+1;
	}
	return r+1;
}		
void JUDGE(){
	GetFirst();
	int len=9;
	while(1){
		int x=GetNewbit(len); --len;
		a=a*10LL+x;
		if(x==0){
			int cnt=0;
			for(LL y=a;y;y/=10) cnt+=y%10;
			LL y=a-1;
			if(cnt==1){
				if(Query(y)){
					ans=a/10;
					return;
				}
			}
			else{
				if(!Query(y)){
					ans=a/10;
					return;
				}
			}
		}
	}
}


int main(){
	JUDGE();
	printf("! %lld\n",ans);
	fflush(stdout);
}
			
			


Measured memory_bytes: 504
while True:
    count = 0
    h,w = map(int ,raw_input().split())
    if h == w == 0:
        break
    for j in range(h):
        str1 = ""
        if count == 0:
            for i in range(w):
                if i % 2 == 1:
                    str1 += "."
                else:
                    str1 += "#"
            print str1
            count = 1
        else:
            for i in range(w):
                if i % 2 == 1:
                    str1 += "#"
                else:
                    str1 += "."
            print str1
            count = 0
    print "\n",

Measured memory_bytes: 6328
#include <stdio.h>

int main(void) {
    int p, q, r;

    scanf("%d%d%d", &p, &q, &r);

    int max = p; 

    if (max < q)
        max = q;

    if (max < r)
        max = r;

    printf("%d\n", p + q + r - max);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
char s[300010];
int se[300010],sw[300010];
int main(){
	int n,i,tmp,ans;
	scanf("%d%s",&n,s+1);
	for(i=1;i<=n;i++){
		se[i]=se[i-1];
		sw[i]=sw[i-1];
		if(s[i]=='E')
			se[i]++;
		else
			sw[i]++;
	}
	ans=n;
	for(i=1;i<=n;i++){
		tmp=0;
		if(i>1)tmp+=sw[i-1];
		if(i<n)tmp+=se[n]-se[i];
		if(tmp<ans)ans=tmp;
	}
	printf("%d",ans);
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lld l,r,d,i,s=0;
    cin>>l>>r>>d;
    for(i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            s++;
        }
    }
    cout<<s;
	return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
typedef long long ll;
int main(){
  ll a, b, x;
  scanf("%lld %lld %lld", &a, &b, &x);
  
  ll n = 0;
  if(a == 0)
    n = b/x + 1;
  else
    n = b/x - (a-1)/x;
  
  printf("%lld", n);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<map>


using namespace std;

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  map<string,int> balls;
  balls[s] = a;
  balls[t] = b;
  balls[u] -= 1;
  cout << balls[s] << " " << balls[t] << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in [i for i in range(n) if i%2 != n%2][::-1]:
     ans += [a[i]]

for i in [i for i in range(n) if i%2 == n%2]:
     ans += [a[i]]

print(*ans)


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

int main()
{
    int n;
    int alice = 0;
    int bob = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; ++i)
    {
        if (i % 2 == 0)
            alice += a[i];
        else
            bob += a[i];
    }
    cout << max(alice, bob) - min(alice, bob) << endl;
    return 0;
}


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

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

    int a[n];
    int b[n];

    pair<int, int> p[n];

    long over_total = 0;
    long less_total = 0;
    long less_count = 0;

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

        int c = a[i] - b[i];

        p[i] = {c, i};

        if (c < 0) {
            less_total += (-c);
            less_count++;
        } else {
            over_total += c;
        }
    }

    sort(p, p + n, greater<pair<int, int>>());

    if (over_total >= less_total) {
        int ans = less_count;
        int i = 0;
        while (less_total > 0) {
            less_total -= p[i++].first;
            ans++;
        }
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


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

bool memo[101]={};
stack<int> s;
int main(){
	int l;
	cin>>l;
	int c;
	s.push(0);
	for(int i=0;i<l;i++){
		cin>>c;
		if(c>0){
			if(memo[c]){
				cout<<++i<<endl;
				return 0;
			}else{
				s.push(c);
				memo[c]=true;
			}
		}else{
			c=c*-1;
			if(s.top()==c){
				s.pop();
				memo[c]=false;
			}else{
				cout<<++i<<endl;
				return 0;
			}
		}
	}
	cout<<"OK"<<endl;
	
}


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

#define pb push_back

using namespace std;

int n, m, u[100005], ans, dp[100005];
vector<int>g[100005];

void dfs(int v){
	u[v] = 1;
	int maxi = 0;
	for(auto to : g[v]){
		if(u[to] == 1){
			maxi = max(dp[to], maxi);
		}
		else{
			dfs(to);
			maxi = max(dp[to], maxi);
		}
	}
	dp[v] = maxi + 1;
	ans = max(dp[v], ans);
}

int main(){
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int l , r;
		cin >> l >> r;
		g[l].pb(r);
	}
	for(int i = 1; i <= n; i++){
		if(u[i] == 0){
			dfs(i);
		}
	}
	cout << ans - 1;
}

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

int main(void) {
    int64_t N,K;
    int64_t sum=0;
    int64_t maxsum=0;
    int64_t pos = 0;
    cin >> N >> K;
    vector<int64_t> p(N);    

    for(int i=0;i<N;i++) {
        cin >> p[i];
    }

    for(int i=0;i<K;i++) {
        sum += p[i];
    }

    int j=0;
    for(int i=K;i<N;i++,j++) {
        sum = sum - p[j] + p[i];
        if(maxsum < sum) {
            maxsum = sum;
            pos = j+1;
        }
    }

    double ans = K;
    for(int i=pos;i<K+pos;i++) {
        ans += p[i];
    }

    cout << setprecision(12) <<ans /2 << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

string S;
int D;

int dp[14514][2][104];

int keta(int k,bool f,int m){
    if(dp[k][f][m]!=-1){
        return dp[k][f][m];
    }
    if(k>=S.size()){
        int num=0;
        if(m==0)num=1;
        dp[k][f][m]=num;
        return num;
    }
    
    if(f==0){
        int num=0;
        REP(i,10){
            num+=keta(k+1,0,(m+i)%D);
        }
        num%=MOD;
        dp[k][f][m]=num;
        return num;
    }else{
        int num=0;
        int s = S[k]-'0';
        REP(i,s){
            num+=keta(k+1,0,(m+i)%D);
        }
        num+=keta(k+1,1,(m+s)%D);
        dp[k][f][m]=num;
        return num;
    }
    
}

signed main(void){
    cin >> S;
    cin >> D;
    
    REP(i,14514){
        REP(j,2){
            REP(k,104){
                dp[i][j][k]=-1;
            }
        }
    }
    
    int Ans = keta(0,1,0);
    Ans+=(MOD-1);
    Ans%=MOD;
    cout << Ans << endl;
    
    #if debug
    REP(j,D){
        REP(i,S.size()+1){
            cout << dp[i][0][j] << " ";
        }cout << endl;
    }cout << endl;
    
    REP(j,D){
        REP(i,S.size()+1){
            cout << dp[i][1][j] << " ";
        }cout << endl;
    }cout << endl;
    #endif
    
    return 0;
}




Measured memory_bytes: 24576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  string s;cin>>s;
  vector<int> v(26,0);
  rep(i,s.size()){
   if(v[s[i]-'a']!=0){
    cout<<"no"<<endl;
     return 0;
   }
   v[s[i]-'a']++; 
  }
  cout<<"yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;
ll mod = 1e9+7;

ll N;
ll A[300005];
ll B[300005][65][2];
ll d[61];
// B[n][k][l],n番目までにk桁目にlをもつ数の総和

ll Pow(ll x,ll n){
    ll res=1;
    for(int i=0;i<n;++i)res*=x;
    return res;
}

int main(){
    for(int i=0;i<61;++i)d[i]=Pow(2,i);
    cin>>N;
    for(int i=0;i<N;++i)cin>>A[i];
    for(int i=0;i<N;++i){
        for(int k=0;k<61;++k){
            int b=((A[i]&d[k])==d[k]);
            B[i][k][b]++;
            if(i!=0){
                B[i][k][0]+=B[i-1][k][0];
                B[i][k][1]+=B[i-1][k][1];
                B[i][k][0]%=mod;
                B[i][k][1]%=mod;
            }
        }
    }
    ll ans=0;
    for(int i=0;i<N-1;++i){
        for(int k=0;k<60;++k){
            int b=((A[i]&d[k])==d[k]);
            ans+=(d[k]%mod)*(B[N-1][k][!b]-B[i][k][!b]);
            ans%=mod;
        }
    }
    cout<<ans<<endl;
}

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

int main(void){
  int A, B;
  int x[3];
  cin >> A >> B;
  x[0] = A + B;
  x[1] = A - B;
  x[2] = A * B;
  sort(begin(x), end(x));
  cout << x[2] << "\n";
  return 0;
}


Measured memory_bytes: 3588
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MAXM=200000;

int n,m;
int ghead[MAXN],gnxt[2*MAXM],gto[2*MAXM];

int state[MAXN];
int comp[MAXN],ncomp;
int q[2*MAXN],qhead,qtail;
int cnt[MAXN]; bool bip[MAXN];


bool been[1000];
int qq[1000],qqhead,qqtail;
ll bf() {
	assert(n*n<=1000);
	memset(been,false,sizeof(been)); ll ret=0;
	REP(i,n*n) if(!been[i]) {
		qqhead=qqtail=0; been[i]=true,qq[qqhead++]=i,++ret;
		while(qqtail<qqhead) {
			int at=qq[qqtail++]; int at1=at/n,at2=at%n;
			for(int x=ghead[at1];x!=-1;x=gnxt[x]) for(int y=ghead[at2];y!=-1;y=gnxt[y]) {
				int to1=gto[x],to2=gto[y],to=to1*n+to2;
				if(!been[to]) been[to]=true,qq[qqhead++]=to;
			}
		}
	}
	return ret;
}

ll solve() {
	memset(state,0,sizeof(state)); ncomp=0;
	REP(i,n) if(state[i]==0) {
		qhead=qtail=0;
		state[i]=1,comp[i]=ncomp++,q[qhead++]=i;
		while(qtail<qhead) {
			int at=q[qtail++];
			for(int x=ghead[at];x!=-1;x=gnxt[x]) {
				int to=gto[x];
				int nval=state[at]==3?3:3-state[at];
				if((state[to]|nval)==state[to]) continue;
				state[to]|=nval,comp[to]=comp[i],q[qhead++]=to;
			}
		}
	}
	REP(i,ncomp) cnt[i]=0,bip[i]=true; REP(i,n) ++cnt[comp[i]]; REP(i,n) if(state[i]==3) bip[comp[i]]=false;
	int nsingle=0,nbip=0; REP(i,ncomp) if(cnt[i]==1) ++nsingle; else if(bip[i]) ++nbip;
	//REP(i,ncomp) printf("%d: %d %c\n",i,cnt[i],cnt[i]!=1&&bip[i]?'V':'x');

	ll ret=0;
	REP(i,ncomp) {
		if(cnt[i]==1) ret+=n;
		else if(bip[i]) ret+=(ll)cnt[i]*nsingle+2*nbip+(ncomp-nsingle-nbip);
		else ret+=(ll)cnt[i]*nsingle+nbip+(ncomp-nsingle-nbip);
	}
	return ret;
}


void run() {
	scanf("%d%d",&n,&m); REP(i,n) ghead[i]=-1;
	REP(i,m) {
		int a,b; scanf("%d%d",&a,&b); --a,--b;
		gnxt[2*i+0]=ghead[a]; ghead[a]=2*i+0; gto[2*i+0]=b;
		gnxt[2*i+1]=ghead[b]; ghead[b]=2*i+1; gto[2*i+1]=a;
	}
	ll ret=solve(); printf("%lld\n",ret);
	//ll chk=bf(); printf("chk=%lld\n",chk);
}

void stress() {
	while(true) {
		n=5,m=rand()%10;
		REP(i,n) ghead[i]=-1;
		REP(i,m) { int a,b; do { a=rand()%n,b=rand()%n; } while(a==b); gnxt[2*i+0]=ghead[a]; ghead[a]=2*i+0; gto[2*i+0]=b; gnxt[2*i+1]=ghead[b]; ghead[b]=2*i+1; gto[2*i+1]=a; }
		ll ret=solve(); printf("%lld\n",ret);
		ll chk=bf(); printf("chk=%lld\n",chk);
		if(ret!=chk) break;
	}
	printf("%d %d\n",n,m);
	REP(i,n) for(int x=ghead[i];x!=-1;x=gnxt[x]) if(gto[x]>i) printf("%d %d\n",i+1,gto[x]+1);
}



int main() {
	//stress();
	run();
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int mod=10007;
int n;
int idx[1001];
int memo[1001][8];
int dfs(int day,int joutai){
  if(day==n){
    return 1;
  }
  if(memo[day][joutai]!=-1) return memo[day][joutai];
  int ret=0;
  for(int i=0;i<(1<<3);i++){
    if((joutai&i) && (i&(1<<idx[day])) ){
      ret+=dfs(day+1,i)%mod;
    }
  }
  return memo[day][joutai]=ret%mod;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    if(c=='J'){
      idx[i]=0;
    }else if(c=='O'){
      idx[i]=1;
    }else{
      idx[i]=2;
    }
    for(int j=0;j<8;j++){
      memo[i][j]=-1;
    }
  }
  cout<<dfs(0,1)<<endl;
  return 0;
}

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

int main() {
  int N,K;
  cin >> N >>K;
  int ans =1;

  for (int i = 1; i <= N; i++) {
 
    if(ans*2 >= ans+K){
      ans +=  K;
  }else{
      ans =ans*2;
  }
   
 }
 cout << ans << endl;
}

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

int main() {
  ll n; cin>>n;
  vector<int> v(n);
  rep(i,n){cin>>v[i];}
  sort(v.begin(),v.end());
  int a=0,b=0,c=0;
  int i=0,ans;
  if(v[n-1]-v[0]<2){ans=n;}
  else{
    while(i<n){
      if(v[i]==v[0]){a++;i++;}
      else{break;}
    }
    while(i<n){
      if(v[i]==v[0]+1){b++;i++;}
      else{break;}
    }
    while(i<n){
      if(v[i]==v[0]+2){c++;i++;}
      else{break;}
    }
    ans=a+b+c; 
    rep(j,v[n-1]-v[0]-1){
      a=b; b=c; c=0;
      while(i<n){
        if(v[i]==v[0]+j+3){c++;i++;}
        else{break;}
      }
      
      ans=max(ans,a+b+c);
    }
  }
  cout<<ans;
} 

Measured memory_bytes: 640
#include <iterator>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <algorithm>
using namespace std; typedef long long ll; typedef pair<ll,ll> P; const ll INF = 1e15;
int main() {
  ll h,w; cin>>h>>w;

  if (h==1 || w==1) {
    cout<<1<<endl;
  } else {
    cout<<h*w/2+(h*w%2!=0)<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N,M,L,O,P,Q,R;
string S;
int main(){
  cin>>N>>M;
  vector<vector<int>> v(N+1);
  vector<set<int>> v2(N+1);
  vector<set<int>> vv(N+1);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    v[a].push_back(b);
  }
  int s,t;
  cin>>s>>t;
  vector<vector<bool>> flag(N+1,vector<bool>(3,0));
  vector<vector<int>> dist(N+1,vector<int>(3,1<<30));
  queue<pair<int,int>>q;
  flag[s][0]=1;
  dist[s][0]=0;
  q.push({s,0});
  while(!q.empty()){
    int now = q.front().first;
    int kkp=q.front().second;
    int newkkp = (kkp+1)%3;
    q.pop();
    for(int i=0;i<v[now].size();i++){
      int adj = v[now][i];
      if(flag[adj][newkkp])continue;
      flag[adj][newkkp]=1;
      dist[adj][newkkp]=min(dist[now][kkp]+1,dist[adj][newkkp]);
      q.push({adj,newkkp});
    }
  }
  if(dist[t][0]==1<<30)cout<<-1<<endl;
  else cout<<dist[t][0]/3<<endl;
}


Measured memory_bytes: 27648
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}

template<class T,class U>
void msg_with_compare(T A,T B,U A_greater_B,U A_eq_B,U A_less_B){
    if(A==B){cout<<A_eq_B<<"\n";}else if(A>B){cout<<A_greater_B<<"\n";}else{cout<<A_less_B<<"\n";}}

ll a,b,c;
void input(){
    cin>>a>>b>>c;
}
void src(){
    ll amari=0;
    bool f=false;
    rep(i,b){
        amari+=a;
        amari%=b;
        if(amari==c){f=true; break;}
    }
    cout<<(f?"YES":"NO");
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int h,w,d;
    scanf("%d%d%d", &h, &w, &d);

    char str[]="RYGB";
    if(d%2==1) {
        int i,j;
        for(i=0; i<h; i++) {
            for(j=0; j<w; j++) {
                printf("%c", str[(i+j)%2]);
            }
            printf("\n");
        }
    }
    else {
        int d0=d/2;
        int i,j;
        for(i=0; i<h; i++) {
            for(j=0; j<w; j++) {
                int tmp0=(i+j)/d;
                int tmp1=((i%(d*2))-(j%(d*2))+(d*2))%(d*2)/d;

                printf("%c", str[(tmp0%2)+(tmp1%2)*2]);
            }
            printf("\n");
        }
    }


    return 0;
}


Measured memory_bytes: 384
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}


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

  
  int a, b, n;
  cin >> a >> b >> n;
  cout << floor(1. * a / b * min(n, b - 1)) << endl;
}


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

//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back


const int N = 2e5 + 51 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

//gp_hash_table<int, int> table;

int dp[3001][3001];
pair <int, int> pred[3001][3001];

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    int n, m;
    cin >> s >> t;
    n = s.size(), m = t.size();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            char c = s[i - 1], c1 = t[j - 1];
            if (dp[i - 1][j] > dp[i][j - 1]) pred[i][j] = {1, 0}, dp[i][j] = dp[i - 1][j];
            else dp[i][j] = dp[i][j - 1], pred[i][j] = {0, 1};
            if (c == c1 && dp[i][j] < dp[i - 1][j - 1] + 1) {
                pred[i][j] = {1, 1};
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
        }
    }
    int i = n, j = m;
    string ans;
    if (dp[i][j] == 0) return 0;
    while (i > 0 && j > 0) {
        if (pred[i][j] == make_pair(1ll, 1ll)) {
            ans+= s[i - 1];
        }
        auto x = pred[i][j];
        i-= x.ff, j-= x.ss;
    }
    if (dp[n][m] != ans.size()) while (true);
    reverse(ans.begin(), ans.end());
    cout << ans;
}


Measured memory_bytes: 211328
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;
int main() {
	int N, K;
	cin >> N >> K;
	vector<pair<int, int> > data(N);
	vector<int> ys(N), xs(N);
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		data[i] = make_pair(y, x);
		ys[i] = y;
		xs[i] = x;
	}
	sort(ys.begin(), ys.end());
	sort(xs.begin(), xs.end());
	ys.erase(unique(ys.begin(), ys.end()), ys.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());

	ll ans = -1;
	for (int y1: ys) for (int y2 : ys) for (int x1 : xs) for (int x2 : xs) {
		if (y1 > y2 || x1 > x2) continue;
		int c = 0;
		for (int i = 0; i < N; i++) {
			if (data[i].first >= y1 && data[i].first <= y2 && data[i].second >= x1 && data[i].second <= x2) c++;
			if (c == K) break;
		}
		if (c < K) continue;
		ll temp = (ll)(y2 - y1) * (x2 - x1);
		if (ans == -1 || temp < ans) ans = temp;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    ll n;
    cin >> n;

    ll res = 1e18;
    for (ll i = 1; i <= sqrt(n); i++)
    {
        if (n % i)
            continue;

        ll j = n / i;

        res = min(res, i + j - 2);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int ,int> ii;
typedef vector<ii> vii;
typedef pair<int, vector<int>> pv;
typedef pair<int, string> pis;
#define range(x, n) for(int x = 1; x <= n; x++)
#define deb(x) cout << #x << " " << x << endl;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k,x;
    cin >> x >> k;
    if(500*x >= k) cout << "Yes";
    else cout << "No";
  return 0;
}


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

using namespace std;


typedef long long ll;
const int maxn=2e5+10;
ll a;
//vector<ll> ve;
map<int,int>ma1;
map<int,int>ma2;
int main(){
	ll n,k,q;
	cin>>n>>k>>q;
	for(int i=1;i<=n;i++){
		ma1[i]=k;
	}
	for(int i=1;i<=q;i++){
		cin>>a;
//		for(int j=1;j<=n;j++){
//			if(j!=a[i]) ma[j]--;
//		}
		ma2[a]++;
	}
	for(int i=1;i<=n;i++){
		ma1[i]-=(q-ma2[i]);
	}
	for(int i=1;i<=n;i++){
		if(ma1[i]>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}	
}

Measured memory_bytes: 9984
let
    h, w = Int[parse(Int, x) for x in split(readline())]
    s = Array(Char, h, w)
    for i = 1:h
        s[i,:] = Vector{Char}(strip(readline()))
    end

    s1 = deepcopy(s)
    s2 = deepcopy(s)
    for y = 1:h
        for x = 1:w
            if x == 1 || x < w && y % 2 == 0
                s1[y,x] = '#'
            end
            if x == w || 1 < x && y % 2 == 1
                s2[y, x] = '#'
            end
        end
    end
    for y = 1:h
        println(ASCIIString(vec(s1[y,:])))
    end
    println()
    for y = 1:h
        println(ASCIIString(vec(s2[y,:])))
    end
end


Measured memory_bytes: 112484
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in reversed(range(N)):
    if N%2==0:
        if i%2==1:
            B.append(A[i])
    if N%2==1:
        if i%2==0:
            B.append(A[i])

for i in range(N):
    if N%2==0:
        if i%2==0:
            B.append(A[i])
    if N%2==1:
        if i%2==1:
            B.append(A[i])


for i in range(N):
    print(B[i],end=" ")


Measured memory_bytes: 26180
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <iostream>


using namespace std;

signed main() {
    long n;
    cin >> n;
    long long x[n];
    long long plus_sum = 0;
    long long minus_sum = 0;
    long long a;
    for (long i = 0; i < n; i++) {
        cin >> x[i];
        // scanf("%lld", &x[i]);
        x[i] -= (i + 1);
        // if (x[i] >= 0) {
        //     plus_sum +=x[i] - (i + 1);
        // } else {
        //     minus_sum +=x[i] - (i + 1);
        // }
    }
    sort(x, x + n);
    long center = n / 2;
    long long res = 0;
    long long b;
    if (n % 2) {
        b = x[center];
    } else {
        b = static_cast<long long int>(round((x[center - 1] + x[center]) / 2));
    }

    for (long i = 0; i < n; i++) {
        res += abs(x[i] - b);
    }

    cout << res << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  for (int i=0; i<N; i++) {
    cin >> A[i].first;
    A[i].second = i+1;
  }
  sort(A.begin(), A.end());
  for (int i=0; i<N; i++) {
    if (i!=N-1) cout << A[i].second << " ";
    else cout << A[i].second << endl;
  }
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

bool used[101010];
ll place[101010];

int main()
{
	int n,m;cin >> n >> m;
	vector<vector<pair<ll,ll> > > v(n);

	
	REP(i,m)
	{
		int a,b,c;cin >> a >> b >> c;
		a--;b--;
		v[a].PB(MP(b,c));
		v[b].PB(MP(a,-c));
	}
	
	REP(i,n)
	{
		if(!used[i] && v[i].size() != 0)
		{
			used[i] = true;
			queue<pair<ll,ll> > q;
			q.push(MP(i,-1));
			
			while(!q.empty())
			{
				pair<ll,ll> now = q.front();q.pop();
				ll node = now.FI;
				ll prev = now.SE;
				
				REP(j,v[node].size())
				{
					ll aite = v[node][j].FI;
					ll dist = v[node][j].SE;
					if(aite == prev)continue;
					
					if(used[aite])
					{
						if(place[aite] != place[node] + dist)
						{
							cout << "No" << endl;
							return 0;
						}
					}
					else
					{
						place[aite] = place[node] + dist;
						used[aite] = true;
						q.push(MP(aite,node));
					}
				}
			}
		}
	}
	
	cout << "Yes" << endl;
						
	
	return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using vpint = vector<pint>;
using vpll = vector<pll>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n, m;
    cin >> n >> m;
    vpint ab(m);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }

    sort(ALL(ab), [](auto lhs, auto rhs) { return lhs.second < rhs.second; });

    int ans = 0;
    int right = -1;
    rep(i, m)
    {
        if (ab[i].first >= right)
        {
            right = ab[i].second;
            ++ans;
        }
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int[] xm = new int[n];
        int[] ym = new int[m];
        for (int i = 0; i < n; i++) {
            xm[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            ym[i] = sc.nextInt();
        }
        boolean ok = false;
        IN: for (int z = x + 1; z <= y; z++) {
            for (int i = 0; i < n; i++) {
                if (xm[i] >= z)
                    continue IN;
            }
            for (int i = 0; i < m; i++) {
                if (ym[i] < z)
                    continue IN;
            }
            ok = true;
        }

        System.out.println(ok ? "No War" : "War");

    }

}


Measured memory_bytes: 22612
# coding: utf-8
# Your code here!

n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
p = [0]*4

for i in range(n):
    p[0] += abs(x[i] - y[i])
    p[1] += abs(x[i] - y[i])**2
    p[2] += abs(x[i] - y[i])**3
    p[3] = max(p[3], abs(x[i] - y[i]))
p[1] = p[1]**(1/2)
p[2] = p[2]**(1/3)
for i in range(4):
    print("{0:.5f}".format(p[i]))


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

int main(){
    string is;
    cin>>is;
    int n=0,s=0,w=0,e=0;
    for(auto i:is){
        if(i=='N')++n;
        else if(i=='S')++s;
        else if(i=='W')++w;
        else ++e;
    }
    if(n*s>0&&w*e>0)cout<<"Yes"<<endl;
    else if(n==0&&s==0&&w*e>0)cout<<"Yes"<<endl;
    else if(n*s>0&&w==0&&e==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val c = HashMap<Int, Boolean>()
    val penalty = HashMap<Int, Int>()
    repeat(k) {
        val input = readLine()!!.split(" ")
        val index = input[0].toInt()
        val hit = input[1] == "AC"

        if (hit) c[index] = true
        else if (!(c[index] ?: false)) {
            val temp = penalty[index] ?: 0
            penalty[index] = temp + 1
        }
    }

    val score = c.filter { it.value }.count()
    val pscore = c.filter { it.value }.map { it.key }.mapNotNull { penalty[it] } .sum()
    println("$score $pscore")
}


Measured memory_bytes: 60484
def Colorful(a, b, c, d):

    return "Yes" if (abs(a - b) <= d and abs(b - c) <= d) or abs(a - c) <= d else "No"

def main():
    a , b , c , d = map(int , input().split())
    print(Colorful(a , b , c , d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int N;
    int ans = 0;

    //input
    cin >> N;

    int V[N];
    int S;

    for(int i = 0; i < N; i++){
        cin >> V[i];
    }
    for(int i = 0; i < N; i++){
        cin >> S;
        if(V[i] - S > 0){
            ans += V[i] - S;
        }
    }

    //output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
	ll f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
//**********head by yjjr**********
#define pb push_back
#define inf 1e9
template<class T>void vnique(vector<T> &r){sort(r.begin(),r.end());auto t=unique(r.begin(),r.end());r.erase(t,r.end());}
const int maxn=66,maxm=1e6+6,dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},mod=1e9+7;
struct node{int x,y;}a[maxn<<1],que[maxn*maxn*8];
int n,m,K,ans,lx,ly,cnt[maxn][maxn],s1[maxm],s2[maxm],dis[maxn][maxn],head,tail;
bool fb[maxn][maxn],mark1[maxm],mark2[maxm];
vector<int>px,py;
void bfs(int x,int y){
	rep(i,0,lx)rep(j,0,ly)dis[i][j]=inf;
	dis[x][y]=0;que[head=tail=1]=(node){x,y};
	while(head<=tail){
		int nx=que[head].x,ny=que[head++].y;
		rep(i,0,3){
			int nex=nx+dx[i],ney=ny+dy[i];
			if(nex>lx||nex<0||ney>ly||ney<0||dis[nex][ney]<=dis[nx][ny]+1||fb[nex][ney])continue;
			dis[nex][ney]=dis[nx][ny]+1;que[++tail]=(node){nex,ney};
		}
	}
}
int main()
{
	n=read(),m=read(),K=read();
	px.pb(1);px.pb(n+1);py.pb(1);py.pb(m+1);
	rep(i,1,n)s1[i]=m;
	rep(i,1,m)s2[i]=n;
	rep(i,1,K){
		a[i].x=read()+1,a[i].y=read()+1;
		px.pb(a[i].x),px.pb(a[i].x+1);
		py.pb(a[i].y),py.pb(a[i].y+1);
		s1[a[i].x]--,mark1[a[i].x]=1;
		s2[a[i].y]--,mark2[a[i].y]=1;
	}
	rep(i,1,n)s1[i]=(s1[i]+s1[i-1])%mod;
	rep(i,1,m)s2[i]=(s2[i]+s2[i-1])%mod;
	rep(i,1,n-1)if(!mark1[i]&&!mark1[i+1])ans=(ans+1ll*2*s1[i]*(s1[n]-s1[i]))%mod;
	rep(i,1,m-1)if(!mark2[i]&&!mark2[i+1])ans=(ans+1ll*2*s2[i]*(s2[m]-s2[i]))%mod;
	vnique(px);vnique(py);lx=px.size()-2;ly=py.size()-2;
	rep(i,1,K)
		fb[lower_bound(px.begin(),px.end(),a[i].x)-px.begin()][lower_bound(py.begin(),py.end(),a[i].y)-py.begin()]=1;
	rep(i,0,lx)rep(j,0,ly)cnt[i][j]=1ll*(px[i+1]-px[i])*(py[j+1]-py[j])%mod;
	rep(i,0,lx)rep(j,0,ly)
		if(!fb[i][j]){
			bfs(i,j);
			rep(k,0,lx)rep(p,0,ly)
				if(!fb[k][p])ans=(ans+1ll*cnt[i][j]*dis[k][p]%mod*cnt[k][p])%mod; 
   		}
	ans=(ans+mod)%mod;ans=1ll*ans*(mod/2+1)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
int main()
{
 ios_base::sync_with_stdio(0); cin.tie(0);

    int mis = 0;
    int N; cin >> N;
   for(int i = 0;i<N;i++){
        int cur; cin >> cur;
        if (cur != i+1) mis++;
    }
    string ans = (mis <= 2) ? "YES" : "NO";
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
<?php
	$pattern = str_repeat( '#.', 151 );
    while( true ) {
        fscanf( STDIN, "%d%d", $H, $W );
        if( 0 == $H && 0 == $W ) { break; }
        
		for( $i=0; $i<$H; $i++ ) {
			echo substr( $pattern, ($i&1)?1:0, $W ).PHP_EOL;
		}
        print PHP_EOL;
    }
	return;

?>

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

int main(){
  int N,M;
  
  cin >> N;
  
  vector<int> T(N);//それぞれの問題を解くのにかかる時間
  
  for(int i=0;i<N;i++)
    cin >> T.at(i);
  
  cin >> M;
  
  vector<int> P(M);//問題番号
  vector<int> X(M);//何秒になる
  
  for(int i=0;i<M;i++)
    cin >> P.at(i) >> X.at(i);
  
  int k=0;
  
  for(int j=0;j<N;j++)
      k+=T.at(j);
   
  for(int i=0;i<M;i++)
    cout << k-T.at(P.at(i)-1)+X.at(i) << endl;
  
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int n;
	cin >> n;
	cout << (int)pow(n, 3) << endl;

	return 0;
}


Measured memory_bytes: 3260
N,K = gets.split.map {|x| x.to_i}

def div_ceil(x,y)
  return (x+y-1) / y
end

pow2 = 1
right = N+1
ret = 0
while true
  if K*2 < pow2
    break
  end
  left = div_ceil(K,pow2)
  if right > left
    #puts "#{left} #{right} #{pow2}"
    ret += (right - left) / (N * pow2).to_f
    right = left
  end
  pow2 *= 2
end

puts ret


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main(){
  vector<int> h(10);

  for(int i=0;i<10;++i) cin>>h[i];

  sort(begin(h),end(h),greater<int>());

  for(int i=0;i<3;++i) cout<<h[i]<<endl;
  return 0;
}

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

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

  int ans=0;
  for(int i =1; i<10; i++){
   if(N<=111*i){
     ans= 111*i;
     break;
   }
  }

  cout << ans << endl;
}
  


Measured memory_bytes: 256
n,m,x=map(int,input().split())
cost=[]
kekka=[]
res=[]
for _ in range(n):
    a=list(map(int, input().split()))
    cost+=[a[0]]
    kekka+=[a[1:]]
for i in range(2**n):
    sum=[0]*m
    money=0
    ok=1
    for j in range (n):
        if i>>j & 1:
            for k in range(m):
                sum[k]+=kekka[j][k]
            money+=cost[j]
    for l in sum:
        if l < x:ok=0
    if ok==1:res += [money]
print("-1" if res == [] else min(res))

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

using namespace std;

int main(void){
    int n, m, x;
    cin >> n >> m >> x;
    
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    
    for (int i = 0; i < n; i++){
        int t;
        cin >> t;
        c[i] = t;
        
        for (int j = 0; j < m; j++) cin >> a[i][j];
        
    }
    
    int ans = 1e8 + 2;
    
    // bit全探索
    for (int temp = 0; temp < (1<<12); temp++){
        
        bitset<12> s(temp);
        
        int sum = 0;
        
        vector<int> tempSum(m);
        
        for (int i = 0; i < n; i++){
            
            if (s.test(i)){
                sum += c[i];
                
                for (int j = 0; j < m; j++){
                    tempSum[j] += a[i][j];
                }
                
                bool check = true;
                for (int j = 0; j < m; j++){
                    if (tempSum[j] < x) check = false;
                }
                
                if (check){
                    ans = min(ans,sum);
                }
            }
        }
        
        
        
    }
    
    if (ans == 1e8 + 2){
        cout << -1 << endl;
        return 0;
    }
    else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 3628
/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

// ====== pbds begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== pbds ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======

void speed_solve(){
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x/500) * 1000;
    x %= 500;
    ans += (x/5) * 5;
    cout << ans;
}
int main()
{
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool judgePali(int num);

int main()
{
    int A, B, sum = 0;
    cin >> A >> B;
    for (int i = A; i <= B; ++i)
    {
        if (judgePali(i))
        {
            ++sum;
        }
    }
    cout << sum << endl;
}

bool judgePali(int num)
{
    int tmp = 0, remaind = 0, reverse = 0;
    tmp = num;

    while (tmp != 0)
    {
        /* 1桁ずつ数値を切り出す */
        remaind = tmp % 10;

        /* 数値を反転 */
        reverse = reverse * 10 + remaind;

        /* 次の桁へシフト */
        tmp /= 10;
    }
    if (num == reverse)
    {
        return true;
    }
    return false;
}

Measured memory_bytes: 3536
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <assert.h>
#include <queue>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <functional>
#include <bitset>
using namespace std;
#define ll long long

const int N = 1e3+15;

int a[N];

void solve() {
    int n;
    scanf("%d",&n);
    int ind = 1;
    for(int i=1;i<=n;++i) {
        scanf("%d",&a[i]);
        if(abs(a[ind]) <abs(a[i])) {
            ind = i;
        }
    }
    vector<pair<int,int> > ret;
    if(a[ind]>=0) {
        ret.push_back(make_pair(ind,n));
        ret.push_back(make_pair(ind,n));
        for(int i=1;i<n;++i) {
            ret.push_back(make_pair(n,i));
            ret.push_back(make_pair(n,n));
        }
    } else {
        ret.push_back(make_pair(ind,1));
        ret.push_back(make_pair(ind,1));
        for(int i=n;i>1;--i) {
            ret.push_back(make_pair(1,i));
            ret.push_back(make_pair(1,1));
        }
    }
    printf("%d\n",(int)ret.size());
    for(int i=0;i<(int)ret.size();++i) {
        printf("%d %d\n",ret[i].first,ret[i].second);
    }
}
int main() {
    //freopen("/Users/gotop/Documents/ps_practice/ps_practice/input.txt", "r", stdin);
    solve();
}


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

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

struct P{
	int fi,se;
};

#define bool int
#define false 0
#define true 1
#define P struct P

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
int board[1111][1111];
bool is_prime[1111111];

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

P mem[1111][1111];
P none;

P max(P a,P b){
	if(a.fi==b.fi){
		if(a.se>b.se)return a;
		else return b;
	}else if(a.fi>b.fi)return a;
	else return b;
}

P dfs(int x,int y){
	if(mem[x][y].fi!=-1)return mem[x][y];
	P res;
	res.fi=0; res.se=0;
	int xx;
	repl(xx,x-1,x+2){
		if(xx>=0&&xx<1111&&y+1>=0&&y+1<1111&&board[xx][y+1]!=0&&board[xx][y+1]<=m)res=max(res,dfs(xx,y+1));
	}
	if(is_prime[board[x][y]]){
		res.fi++;
		if(res.se==0)res.se=board[x][y];
	}
	return mem[x][y]=res;
}

int main(){
	//cin.sync_with_stdio(false);
	memset(is_prime,1,sizeof(is_prime));
	is_prime[0]=is_prime[1]=false;
	int i,j;
	rep(i,1111111){
		if(is_prime[i]){
			int j;
			for(j=i*2;j<1111111;j+=i)is_prime[j]=false;
		}
	}
	int num=1;
	int x=1111/2,y=1111/2;
	int len=1,state=0;
	none.fi=-1; none.se=-1;
	while(1){
		rep(i,2){
			rep(j,len){
				board[x][y]=num++;
				x+=dx[state];y+=dy[state];
			}
			state=(state+1)%4;
		}
		if(num>1000000)break;
		len++;
	}
	while(1){
		scanf("%d %d",&m,&n);
		if(n==0)break;
		int sx,sy;
		rep(i,1111)rep(j,1111){
			if(board[i][j]==n){
				sx=i;sy=j;
			}
		}
		rep(i,1111)rep(j,1111)mem[i][j]=none;
		P res=dfs(sx,sy);
		printf("%d %d\n", res.fi,res.se);
	}
	return 0;
}

Measured memory_bytes: 19268
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod (ll)998244353
#define forn(i,k,n) for(ll i=k;i<n;i++)
#define v(ll) vector<ll>
#define vl(a,n,ll,k) vector<ll> a(n,k)
#define vll(a,n,m,ll,k) vector<vector<ll>> a(n,vector<ll>(m,k))
#define MAX 1000000
#define ed '\n'
#define pb push_back
#define mkp make_pair
#define lint ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int MOD = 1000000007;
int lcm(int a, int b)
{
  return(a*b/__gcd(a,b));
}
int main()
{
	lint;
	ll n;
	cin>>n;
	ll ans=lcm(n,360)/n;
	cout<<ans<<ed;
}

Measured memory_bytes: 3628
n, k = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int ,input().split())


judge = 0
dic = {}


for i in range(n):
    if a[i] in dic:
        dic[a[i]] += b[i]
    else:
        dic[a[i]] = b[i]
#print(dic)
dic = list(dic.items())
dic.sort()
#print(dic)


for i in range(10**9):
    if judge >= k:
        print(dic[i-1][0])
        break
    else:
        judge += int(dic[i][1])
    #print(judge)


Measured memory_bytes: 24440