akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(X: int):
    gohyaku = X // 500
    nokori = X % 500
    go = nokori // 5
    print(1000*gohyaku + 5 * go)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
struct ee{int go,next;} e[200005];
int n,q,b[200005],s[200005],ans,cnt,f[200005],mfs[800005],mf[800005],ljb[200005];
void build(int p,int ll,int rr){
	if (ll==rr){
		if (!ll) mf[p]=mfs[p]=0;
		else mf[p]=mfs[p]=-1000000000;
		return;
	}
	build(p*2,ll,(ll+rr)/2);build(p*2+1,(ll+rr)/2+1,rr);
	mfs[p]=max(mfs[p*2],mfs[p*2+1]);
}
int askf(int p,int ll,int rr,int x,int y){
	if (x>y) return 0;
	if (ll==x&&rr==y) return mf[p];
	int mid=(ll+rr)/2;
	if (y<=mid) return askf(p*2,ll,mid,x,y);
	else if (x>mid) return askf(p*2+1,mid+1,rr,x,y);
	else return max(askf(p*2,ll,mid,x,mid),askf(p*2+1,mid+1,rr,mid+1,y));
}
int askfs(int p,int ll,int rr,int x,int y){
	if (ll==x&&rr==y) return mfs[p];
	int mid=(ll+rr)/2;
	if (y<=mid) return askfs(p*2,ll,mid,x,y);
	else if (x>mid) return askfs(p*2+1,mid+1,rr,x,y);
	else return max(askfs(p*2,ll,mid,x,mid),askfs(p*2+1,mid+1,rr,mid+1,y));
}
void add(int p,int ll,int rr,int x,int nf,int nfs){
	mf[p]=max(mf[p],nf);mfs[p]=max(mfs[p],nfs);
	if (ll==rr) return;
	int mid=(ll+rr)/2;
	if (x<=mid) add(p*2,ll,mid,x,nf,nfs);
	else add(p*2+1,mid+1,rr,x,nf,nfs);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&b[i]);
	for (int i=1;i<=n;i++) s[i]=s[i-1]+(b[i]?1:-1),ans+=!b[i]; 
	scanf("%d",&q);
	for (int i=1;i<=q;i++){
		int x,y;scanf("%d%d",&x,&y);
		e[++cnt]=(ee){y,ljb[x]};ljb[x]=cnt;
	}
	build(1,0,n);f[0]=0;
	for (int i=1;i<=n;i++) f[i]=-1000000000;
	for (int i=1;i<=n;i++){
		for (int td=ljb[i];td;td=e[td].next){
			int j=e[td].go;
			f[j]=max(f[j],askf(1,0,n,0,i-1)+s[j]-s[i-1]);
			if (i<j) f[j]=max(f[j],askfs(1,0,n,i,j-1)+s[j]);
		}
		for (int td=ljb[i];td;td=e[td].next){
			int j=e[td].go;
			add(1,0,n,j,f[j],f[j]-s[j]);
		}
	}
	printf("%d",n-ans-askf(1,0,n,1,n));
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

vector <int> a;

int main(){
  int inp;
  
  for (int i = 0 ;i<3;i++){
    cin >> inp;
    a.push_back(inp);
  }

  sort(a.begin(),a.end());

  cout << a[0]+a[1] << endl;

  return 0;
}


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




int main()
{
	int a, b;
	cin >> a >> b;
	if (a < b) {
		for (int i = 0; i < b; i++)cout << a;
	}
	else {
		for (int i = 0; i < a; i++)cout << b;
	}
	
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

const int MOD = 1000000007;
int main() {
    int n;
    int64 ans = 1;
    cin >> n;
    for (int64 i=1; i<=n; i++) ans = (ans%MOD) * i;

    cout << ans % MOD << endl;
}

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

int r,g,b,n,ans=0,i,j;

int main(){
  cin>>r>>g>>b>>n;
  for (i=0;i*r<=n;i++){
  	for (j=0;j*g<=n-i*r;j++){
  		if ((n-i*r-j*g)%b==0)
  			ans++;
    	}
  }
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N, K = list(map(int, input().split()))
A = np.fromstring(input(), int, sep=" ")

p = 1
count = 0
memo = {1: 0}
while count < K:
    p = A[p-1]
    count += 1

    if p not in memo:
        memo[p] = count
    else:
        step = count - memo[p]
        count += max(0, K-count) // step * step
        memo = {p: count}

print(p)

Measured memory_bytes: 44828
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_M = 70;
ll N;
ll dp[MAX_M][3];

ll memo(int digit, int val) {
  if (digit < 0) {
    return 1;
  }
  ll &res = dp[digit][val];
  if (res >= 0) {
    return res;
  }
  res = 0;
  int next_val;
  // 0 0
  next_val = 2 * val + (N >> digit & 1);
  if (next_val >= 0) {
    res += memo(digit - 1, min(2, next_val));
    res %= MOD;
  }
  //(1, 0), (0, 1)
  next_val = 2 * val + (N >> digit & 1) - 1;
  if (next_val >= 0) {
    res += memo(digit - 1, min(2, next_val));
    res %= MOD;
  }
  //(1, 1)
  next_val = 2 * val + (N >> digit & 1) - 2;
  if (next_val >= 0) {
    res += memo(digit - 1, min(2, next_val));
    res %= MOD;
  }
  return res;
}

int main(int argc, char const *argv[]) {
  cin >> N;
  memset(dp, -1, sizeof(dp));
  cout << memo(60, 0) << endl;
  return 0;
}


Measured memory_bytes: 504
from math import cos, sin, sqrt, radians
a, b, h, m = map(int,input().split())
hm = 60 * h + m
angled = abs(hm / 2 - 6 * m)
angle = radians(angled)
x = pow(a-b*cos(angle), 2)
y = pow(b*sin(angle),2)
print(sqrt(x+y))


Measured memory_bytes: 9504
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  ll N,ans=0;
  cin>>N;
  
  if(N%2==1){
    cout<<0<<endl;
    return 0;
  }
  
  ans+=N/10;
  N/=10;
  
  while(N>0){
    ans+=N/5;
    N/=5;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	int x,y;cin>>x>>y;
	for(int i=1;i<=x;i++)
	{
	   if((2*i+(4*(x-i)))==y ||((4*i+(2*(x-i)))==y))
	   {
	   cout<<"Yes";
	   return 0;
	   }
	}
	cout<<"No";
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const int  MAX = 1000000;
//const int MAX = 55655;

vector<int> prime;
bool isntprime[MAX+1];
	
void init(){
isntprime[0] = isntprime[1] = true;
  int j;	
  for(int i=2;i<= MAX;i++)if(!isntprime[i])for(prime.push_back(i),j=2*i;j<=MAX;j+=i)isntprime[j] = true;
}

void compute() {

}

int cnt = 0;
void dfs(int rem,int cur,int  sum,deque<int> &deq) {
  
  if( rem <= 0 ) {
    if( !isntprime[sum] ) {
      cout << "[" << sum << "] is prime!" << endl;
      rep(i,(int)deq.size()) { cout << deq[i] << " "; } puts("");
      ++cnt;
    }
    return;
  }
  if( cur >= (int)prime.size() ) {
    return;
  }
  
  REP(i,cur,(int)prime.size()) {
    if(prime[i] > 55555 ) break;
    deq.push_back(prime[i]);
    dfs(rem-1,i+1,sum+prime[i],deq);
    deq.pop_back();
  }
}

int main() {
  srand((unsigned int)time(NULL));
  init();
  /*
  cout << prime.back() << endl;
  cout << 55555  << endl;
  cout << prime.size() << endl;
  deque<int> deq;
  //dfs(5,0,0,deq);
  puts("FIN---");

  rep(i,(int)prime.size()) {
    if( prime[i] % 10 == 1 ) {
      cout << prime[i] << endl;
    }
  }
  puts("--");
  */
  int n;
  cin >> n;
  vector<int> ans;
  map<int,vector<int>> mp;
  rep(i,(int)prime.size()) {
    if( prime[i] > 55555 ) break;
    //mp[prime[i] % 10].push_back(prime[i]);
    if( prime[i] % 10 == 1 && (int)ans.size() < n ) ans.push_back(prime[i]);
  }
  /*
  rep(i,10) {
    cout << i << " : " <<mp[i].size() << endl;
  }
  */

  rep(i,n) {
    if( i ) printf(" ");
    cout << ans[i];
  } puts("");
  
  return 0;
}


Measured memory_bytes: 1916
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1<<29;
ll a,b,c,d;
ll cnt(ll n){
ll ccnt,dcnt,cdcnt;
ccnt=n/c;
dcnt=n/d;
ll gcd= __gcd(c,d);
ll lcm=c*d/gcd;
cdcnt=n/lcm;
ll ans=0;
ans=ccnt+dcnt-cdcnt;
return ans;
}
int main(){
cin>>a>>b>>c>>d;
ll q=b-cnt(b);
ll w=(a-1)-cnt(a-1);
ll tmp=q-w;
cout<<tmp<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;



int n;;;
const int nx = 1e5+5;
int ac[nx][3];
int dp[3][nx];
int go(int a, int i){
	if(i == n) 
              return 0;
	if(dp[a][i] != -1) 
              return dp[a][i];
	int& ans = dp[a][i];
	
	if(a==0){
		ans=max(ans, go(1, i+1)+ac[i][0]);
		ans=max(ans, go(2, i+1)+ac[i][0]);;
	}
	if(a==1){
		ans=max(ans, go(0, i+1)+ac[i][1]);
		ans=max(ans, go(2, i+1)+ac[i][1]);;
	}
	if(a==2){
		ans=max(ans, go(0, i+1)+ac[i][2]);;
		ans=max(ans, go(1, i+1)+ac[i][2]);;
	}
	
	return ans;;
}
int main(){

	cin>>n;

	for(int i=0; i<n; i++) 
              cin>>ac[i][0]>>ac[i][1]>>ac[i][2];;

	memset(dp, -1, sizeof dp);

	cout<<max(go(0,0),max(go(1,0),go(2,0)))<<"\n";

	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
using namespace std;

int main() {
	int a, b, n; cin >> a >> b >> n;
	cout << ((a*b < n) ? a*b : n )<< endl;
	return 0;
}

Measured memory_bytes: 384
#include <climits>
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

int func(int in)
{
	if (in & 1)
		return in * 3 + 1;
	else
		return in >> 1;
}

int main()
{
	int s;
	scanf("%d", &s);
	int i = 1;

	while (true)
	{
		if (s == 4 || s == 2 || s == 1)
			break;
			
		i++;
		s = func(s);
	}
	i += 3;
	printf("%d\n", i);
	return 0;
}


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

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

using namespace std;

int main(){
	int n; cin>>n;
	bool ok=false;
	rep(i,100) rep(j,100) if(4*i+7*j==n) ok=true;
	cout<<(ok?"Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main(){
	string p; cin >> p;
	if (p[0] == p[1] || p[1] == p[2] || p[2] == p[3])print("Bad");
	else print("Good");



	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
struct node{
  int key;
  int cost;
  struct node *next;
};
typedef struct node *GG;
  
GG G[10001];
GG MNode(int,int,GG);
void Insert(int,int,int);
int main()
{
  int i,j,n,count=0,v,c,c1,v1;
  int color[10001],d[10001],pi[10001],mincost,ii;
  GG GGG;
  scanf("%d",&n);
  for(i=0;i<n;i++)G[i]=MNode(0,0,NULL);
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&c);
    for(j=0;j<c;j++){
      scanf("%d%d",&v1,&c1);
      Insert(i,v1,c1);
    }
  }
  for(i=0;i<n;i++){
    color[i]=0;
    pi[i]=-1;
    d[i]=10000001;
  }
  d[0]=0;
   
  while(1){
    mincost=10000001;
    for(i=0;i<n;i++){
      if(color[i]!=2 && d[i]<mincost){
        mincost=d[i];
        ii=i;
      }
    }
    if(mincost==10000001)break;
    color[ii]=2;
    for(GGG=G[ii];GGG!=NULL;GGG=GGG->next){
      if(color[GGG->key]!=2 && (GGG->cost+d[ii])<d[GGG->key]){
    pi[GGG->key]=ii;
    d[GGG->key]=GGG->cost+d[ii];
    color[GGG->key]=1;
      }
    }
  }
  for(i=0;i<n;i++)printf("%d %d\n",i,d[i]);
   
  return 0;
}
  
GG MNode(int key,int cost,GG Node)
{
  GG n;
  n=(GG)malloc(sizeof(struct node));
  n->key=key;
  n->cost=cost;
  n->next=Node;
  return n;
}
void Insert(int s,int t,int u)
{
  GG GGG;
  GGG=MNode(t,u,G[s]->next);
  G[s]->next=GGG;
}

Measured memory_bytes: 18224
import sys

h,w,m=map(int,input().split())


hlis=[0 for i in range(h)]
wlis=[0 for i in range(w)]
hw=[]

for i in range(m):
  hi,wi=map(int,input().split())
  hlis[hi-1]+=1
  wlis[wi-1]+=1
  hw.append([hi-1,wi-1])

hmax=max(hlis)
wmax=max(wlis)

ph=[]
pw=[]
for i in range(h):
  if hlis[i]==hmax:
    ph.append(i)
for i in range(w):
  if wlis[i]==wmax:
    pw.append(i)

if len(ph)*len(pw)>3*(10**5):
  print(hmax+wmax)
  sys.exit()

plis=[]
for phi in ph:
  for pwj in pw:
    plis.append(phi*(10**6)+pwj)

plis.sort()

hwlis=[]
for hi,wi in hw:
  hwlis.append(hi*(10**6)+wi)

hwlis.sort()
    
c=0
check=0

for pi in plis:
  while pi!=hwlis[c]:
    c+=1
    if c>=len(hwlis):
      check=1
      break
  if check==1:
    break

if check==1:
  print(hmax+wmax)
else:
  print(hmax+wmax-1)


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++) {
      cin >> A.at(i);
  }
  int max = *std::max_element(A.begin(), A.end());
  int min = *std::min_element(A.begin(), A.end());
  cout << max - min << endl;
}


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

int main() {
string s;
cin>>s;
if(s[0]==s[1]){
    cout<<1<<" "<<2<<endl;
    return 0;
}
for(int i=2;i<s.length();i++){
    if(s[i]==s[i-2]||s[i]==s[i-1]){
        cout<<i-1<<" "<<i+1<<endl;
        return 0;
    }
}
cout<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
ll s(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%10;
        n/=10;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    set<ll> v;
    ll k;cin>>k;
    rep(i,1,10)v.insert(i);
    ll now=9;
    rep(i,0,15){
        rep(j,0,301){
            ll ne=j*(now+1)+now;
            v.insert(ne);
        }
        now*=10;
        now+=9;
    }
    vector<ll> ans;
    for(auto e:v){
        double u=(double)e/s(e);
        int r=0;
        for(auto ee:v){
            if(ee<=e)continue;
            double uu=(double)ee/s(ee);
            if(uu<u){
                r=1;
                break;
            }
        }
        if(r==0)ans.push_back(e);
    }
    rep(i,0,k)cout<<ans[i]<<endl;
}







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

int main(){
    int N, K;  cin >> N >> K;
    vector<int> x(N);
    for(int i=0; i<N; i++)
        cin >> x[i];
    
    int ans = 0;
    for(int i=0; i<N; i++){
        ans += min(x[i], abs(x[i]-K))*2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <map>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
main()
{
    int ret=0;
    int n;cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    int l[n]={0};
    rep(i,n-1)
    {
        if(a[i]>=a[i+1])l[i+1]=l[i]+1;
        else l[i+1]=0;
    }
    rep(i,n)ret=max(ret,l[i]);
    cout<<ret<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int N;
    cin >> N;
    printf("ABC%lld\n", N);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m1,d1,m2,d2;
	int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>m1>>d1>>m2>>d2;
	if(d1==month[m1]) cout<<"1";
	else cout<<"0";
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll k, t;
  cin >> k >> t;
  vector<ll> a(t);
  for (int i = 0; i < t; i++) {
    cin >> a[i];
  }

  priority_queue<P> pq;
  for (int i = 0; i < t; i++) {
    pq.push(P(a[i], i));
  }

  ll ans = 0;

  ll prev = -1;
  while (!pq.empty()) {
    P curr = pq.top();
    pq.pop();

    ll ccnt = curr.first;
    ll ci = curr.second;

    if (prev != ci) {
      // 一個とって、前のやつと違う数ならそのまま使う
      prev = ci;

      --ccnt;

      if (ccnt > 0) {
        pq.push(P(ccnt, ci));
      }
    } else if (!pq.empty()) {
      // 前の数と同じのがでてきたら、その次にでかいの数を使う
      P nex = pq.top();
      pq.pop();

      ll ncnt = nex.first;
      ll ni = nex.second;

      prev = ni;

      --ncnt;
      if (ncnt > 0) {
        pq.push(P(ncnt, ni));
      }
      pq.push(P(ccnt, ci));
    } else {
      // 前の数と同じのしかないorその次の数がないなら同じ種類のを食べるしかないので+
      ans++;

      ccnt--;

      if (ccnt > 0) {
        pq.push(P(ccnt, ci));
      }
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
int main(){
  int n;
  cin >> n;
  vector<vector<int> > f(n,vector<int>(10));
  rep(i,n) rep(j,10) cin >> f[i][j];

  vector<vector<int> > p(n,vector<int>(11));
  rep(i,n) rep(j,11) cin >> p[i][j];

  int res = -INF;
 
  for (int bit = 1; bit < (1<<10); bit++) {
    int v = 0;
    rep(i,n) {
      int c = 0;
      rep(j,10) if (bit & (1<<j)) if (f[i][j]) c++;
      v += p[i][c];
    }
    res = max(res,v);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int t=sc.nextInt();
		int a[]=new int[n+1];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
		}
		a[n]=Integer.MAX_VALUE;
		int ans = 0;
		for(int i=1; i<=n; i++) {
			ans += Math.min(a[i]-a[i-1], t);
		}
		System.out.println(ans);
		sc.close();
	}
}




Measured memory_bytes: 64652
S=input()
N=len(S)

Ans1=0
Ans2=0

if N%2==0:
    s1='10'*(N//2)
    s2='01'*(N//2)

    for i in range(N):
        if S[i]!=s1[i]:
            Ans1 += 1
        else:
            Ans2 += 1
    
else:
    s1='10'*(N//2)+'1'
    s2='01'*(N//2)+'0'
    for i in range(N):
        if S[i]!=s1[i]:
            Ans1 += 1
        else:
            Ans2 += 1

print(min(Ans1, Ans2))

Measured memory_bytes: 3316
from collections import Counter

# 累乗 x^n
def pow(x,n):
    global p
    res=1
    prod=x
    while n>0:
        if n%2==1:
            res=(res*prod)%p
        prod=(prod*prod)%p
        n//=2
    return res

p=998244353

N=int(input())
D=list(map(int,input().split())) # 頂点は0-initial

f=True
if D[0]!=0:
    f=False
else:
    C=Counter(D)
    if C[0]>1:
        f=False
    else:
        dmax=max(C)    
        for d in range(1,dmax):
            if d not in C:
                f=False
    if f:
        v=[C[i] for i in range(dmax+1)]
        ans=1
        for d in range(1,dmax):
            ans=(ans*pow(v[d],v[d+1]))%p
if f:
    print(ans)
else:
    print(0)

Measured memory_bytes: 66860
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> 

using namespace std;

int n,root;
long long a[100100];
int head[100100],nxt[200100],to[200100],tot;
int tim[100100];
bool flag = true;

void add(int f,int t){
	to[++tot] = t;
	nxt[tot] = head[f];
	head[f] = tot;
}

void dfs(int pos,int pre)
{
	long long sum = 0,ma = 0;
	for(int i = head[pos];i;i = nxt[i])
		if(to[i] != pre)
		{
			if(tim[to[i]] != 1)
				dfs(to[i],pos);
			sum += a[to[i]];
			ma = max(ma,a[to[i]]);
		}
	long long x2 = sum - a[pos],x1 = a[pos] - x2;
	if(flag && (ma > a[pos] || x1 < 0 || x2 < 0))
		flag = false;
	a[pos] = x1;
}

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)scanf("%lld",&a[i]);
	if(n == 2)
	{
		if(a[1] != a[2])
			printf("NO\n");
		else
			printf("YES\n");
		return 0;
	}
	for(int i = 1;i < n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		tim[x]++,tim[y]++;
		add(x,y);
		add(y,x);
	}
	for(int i = 1;i <= n;i++)
		if(tim[i] != 1)
		{
			dfs(i,0);
			root = i;
			break;
		}
	if(a[root] == 0 && flag)
	{
		printf("YES\n");
	}else
		printf("NO\n");
	return 0;
}

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

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

    int ans = 0;
    for(; n > 0; ans++) n /= k;
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
import sys
input = sys.stdin.readline

def main():
    MOD = 10**9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    if N % 2:
        if C[0] != 1:
            return 0
        for key in C:
            if key == 0:
                continue
            if key % 2 or C[key] != 2:
                return 0
        ret = 1
        for i in range(N // 2):
            ret = ret * 2 % MOD
    else:
        for key in C:
            if key % 2 == 0 or C[key] != 2:
                return 0
    ret = 1
    for i in range(N // 2):
        ret = ret * 2 % MOD
    return ret

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 55644
#include <stdio.h>
#include <string.h>

int main(){
  char S[100001];
  int ans=0;
  scanf("%s",S);
  int d=strlen(S);
  for(int i=1; i<d; i++){
    if(S[i-1]==S[i]){
      ans++;
      if(S[i-1]=='0')S[i]='1';
      else S[i]='0';
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 256
H, W = map(int, input().split())

a = []

# 必要な行だけ読み込む
for i in range(H):
    tmp = list(input())
    if "#" not in tmp:
        continue
    else:
        a.append(tmp)

# 転置して削って転置
a = list(zip(*a))
a = [x for x in a if "#" in x]
a = list(zip(*a))

for i in a:
    print("".join(i))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> p(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  int64_t sum = 0;
  for (int64_t i = 0; i < K; i++) {
    sum += p.at(i);
  }
  int64_t maxsum = sum;
  for (int64_t i = 1; i < N - K + 1; i++) {
    sum += p.at(i + K - 1) - p.at(i - 1);
    if (sum > maxsum) {
      maxsum = sum;
    }
  }
  cout << fixed << setprecision(1);
  double result = (double) (maxsum + K) / (double) 2;
  cout << result << endl;
}

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

int main() {
    string s;

    cin >> s;

    int price = 700;

    for(int i = 0; i < 3; i++) {
        if(s[i] == 'o') {
            price += 100;
        }
    }

    cout << price << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int grid[1100][2200], sum[1100][2200];

int main() {
	int n, k, ans = 0;
	scanf("%d%d", &n, &k);
	for(int i; i < n; ++i) {
		int x, y;
		char c;
		scanf("%d%d %c", &x, &y, &c);
		++grid[x % k][y % k + k * ((x / k % 2) ^ (y / k % 2) ^ (c == 'B'))];
	}
	sum[0][0] = grid[0][0];
	for(int i = 1; i < k * 2; ++i) sum[0][i] = sum[0][i - 1] + grid[0][i];
	for(int i = 1; i < k; ++i) {
		int s = 0;
		for(int j = 0; j < k * 2; ++j) {
			s += grid[i][j];
			sum[i][j] = sum[i - 1][j] + s;
		}
	}
	for(int i = 0; i < k; ++i) for(int j = 0; j < k; ++j){
		int hope = sum[i][j] * 2 - sum[i][j + k] * 2 + sum[i][k * 2 - 1] + sum[k - 1][j + k] - sum[k - 1][j];
		if(ans < hope) ans = hope;
		hope = -sum[i][j] * 2 + sum[i][j + k] * 2 - sum[i][k * 2 - 1] + sum[k - 1][j] - sum[k - 1][j + k] + sum[k - 1][k * 2 - 1];
		if(ans < hope) ans = hope;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 18560
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,1,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n, a, cntm = 1000;
    vector<int> v;
    cin >> n;
    rep(i, n){
        cin >> a;
        int cnt = 0;
        while(a % 2 == 0 && a != 0){
            a /= 2;
            cnt++;
        }
        cntm = min(cnt, cntm);
    }
    cout << cntm << endl;
}



Measured memory_bytes: 256
t = list(input())
a = 0
b = 0

for i in range(len(t)):
    if i == 0 and t[i] == '?':
        t[i] = 'D'
    
    if 0 < i < len(t) - 1 and t[i] == '?':
        if t[i-1] == 'P':
            t[i] = 'D'
        elif t[i+1] == 'P':
            t[i] = 'D'
        else:
            t[i] = 'P'

    if i == len(t) -1 and t[i] == '?':
        t[i] = 'D'

print(''.join(t))

Measured memory_bytes: 10824
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long N,K;
    cin>>N>>K;
    vector<long long> A;
    map<long long , int> m;
    REP(i,N){
        long long tmp;
        cin>>tmp;
        m[tmp]++;
    }
    for (auto x:m){
        A.push_back(x.second);
    }
    sort(A.begin(),A.end());
    int cnt = A.size()-K;
    long long res = 0;
    REP(i,cnt){
        res += A[i];
    }
    cout<<res<<endl;
    return 0;
}

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

int f(int n, int x){
	int ans = 0;
	for(int i=1; i<=n-2; i++){
		for(int j=i+1; j<=n-1; j++){
			int t = x-i-j;
			if(t>j && t<=n)
				ans ++;
		}
	}
	return ans;
}

int main(){
	int n, x;
	while(cin >> n >> x){
		if(n==0 && x==0)
			break;
		cout << f(n, x) << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
using namespace std;
int main()
{
    long long n;
    string name="";
    cin>>n;
    do
    {
        int x=(n-1)%26;
        char ch='a'+x;
        name=ch+name;
        n=(n-1)/26;
    }while(n>0);
    cout<<name<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
using namespace std;
typedef long long ll;

// #define DEBUG

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    string command;
    int n, key;
    list<int> linklist;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> command;
        if (command == "insert")
        {
            cin >> key;
            linklist.push_front(key);
        }
        if (command == "delete")
        {
            cin >> key;
            for (auto itr = linklist.begin(); itr != linklist.end(); itr++){
                if (*itr == key){
                linklist.erase(itr);
                break;
                }
            }
        }
        else if (command == "deleteFirst")
            linklist.pop_front();
        else if (command == "deleteLast")
            linklist.pop_back();
    }

    cout << *linklist.begin();
    for (auto itr = ++linklist.begin(); itr != linklist.end(); itr++){
        cout << " " << *itr;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 34300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
void chmax(ll &a, ll b){
  if( a < b){ swap(a,b);} return ;}
void chmin(ll &a, ll b){
  if( a > b){ swap(a,b);} return ;}
//けんちょん解説AC 
int main(){
ll N,Z,W; cin >> N >>Z>>W; vector<ll> A(N);
  for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  vector<vector<ll>> dp(N, vector<ll> (2));
   ll Y;
  for(ll i = N-1; i >= 0; i--){
    dp[i][0] = -INF;
    if(!i){ Y = W;} else{ Y = A[i-1];}
    chmax(dp[i][0], abs(Y-A[N-1])); //XがA[i+1] ~~ A[N-1]まで全部取ってしまった時
    for(ll j = i+1; j < N; j++){ chmax( dp[i][0], dp[j][1]);}
    
    dp[i][1] = INF;
    ll X;
    if(!i){ X = Z;} else{ X = A[i-1];}
    chmin(dp[i][1], abs(X-A[N-1]));
    
    for(ll j = i+1; j < N; j++){ chmin( dp[i][1], dp[j][0]);}
  }
  
  cout << dp[0][0] << endl; return 0;}
     


Measured memory_bytes: 384
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#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
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    long n, a, b, c;
    scanf("%ld%ld%ld%ld", &n, &a, &b, &c);

    vector<long> t(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &t[i]);
    }

    long  min = INF;
    long j, m, k;
    for(i=0; i<(1<<n); i++) {
        if(i==0) continue;
        long aa = 0, count0=0;
        for(k=0; k<n; k++) {
            if(i & (1<<k)) {
                aa+=t[k]; count0++;
            }
        }        

        for(j=0; j<(1<<n); j=((j|i)+1)&~i) {
            if(j==0) continue;
            long bb = 0, count1=0;
            for(k=0; k<n; k++) {
                if(j & (1<<k)) {
                    bb+=t[k]; count1++;
                }
            }

            for(m=0; m<(1<<n); m=(((m|i|j)+1)&~i)&~j) {
                if(m==0) continue;
                long cc = 0, count2=0;
                for(k=0; k<n; k++) {
                    if(m & (1<<k)) {
                        cc+=t[k]; count2++;
                    }
                }                
                //printf("%ld %ld %ld\n", aa, bb, cc);

                long val = (count0>1? count0-1: 0) + (count1>1? count1-1: 0) +  (count2>1? count2-1: 0);
                val = val * 10 + abs(a - aa) + abs(b - bb) + abs(c - cc);
                min = MIN(min, val);
            }
        }
    }
    printf("%ld\n", min);

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define INF 0x3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define pair pair<int,int>
#define C(a) cout<<a<<endl;
#define CY cout<<"YES"<<endl;
#define CN cout<<"NO"<<endl;
#define Cy cout<<"Yes"<<endl;
#define Cn cout<<"No"<<endl;
#define ull unsigned long long
#define me(a) memset(a,0,sizeof(a));
#define my(a,b) memcpy(a,b,sizeof(b));
#define cio ios::sync_with_stdio(false)
ll mod=1e9+7;
ll gcd(ll a,ll b){return (a%b==0) ? b : gcd(b,a%b);}
ll s[250000];
ll n,k;
inline bool check(int m)
{
    int ans = 0;
    for(int i=0;i<n;i++) 
	{
        if (s[i] != m) ans += s[i] / m;
        if (ans > k) return 0;
    }
    return ans <= k;
}
int main()
{
	ll max1=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>s[i];
		max1=max(max1,s[i]);
	}
	ll l=1,r=max1,mid;
	int m;
    int ans = 1;
    while (l < r) {

        m = (l + r) / 2;
        if (check(m)) {
            r = m;
            ans = m;
        } else l = m + 1;
    }
	cout<<r<<endl;
 	return 0;
}

Measured memory_bytes: 5140
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
a,b = [],[]
for x in l:
    if x[0] == 1:
        a.append(x[1])
    if x[1] == n:
        b.append(x[0])
print ('POSSIBLE' if set(a)&set(b) else 'IMPOSSIBLE')

Measured memory_bytes: 61024
N,M=$<.read.split.map(&:to_i)
mod = 10**9+7

if (N-M).abs > 1
    puts 0
else
    n = 1
    1.upto(N) do |i|
        n = n * i % mod
    end
    m = 1
    1.upto(M) do |i|
        m = m * i % mod
    end
    if N==M
        puts (2*n*m) % mod
    else
        puts (n*m) % mod
    end
end


Measured memory_bytes: 1788
x, n  = map(int, input().split())
if n > 0:
  p = set(map(int, input().split()))
  i = 0
  while True:
    if x - i not in p:
      print(x-i)
      break
    if x + i not in p:
      print(x+i)
      break
    i += 1
else:
  print(x)
    


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

int main() {
    int N,M,Q;
    cin>>N>>M>>Q;
    int a[Q], b[Q], c[Q], d[Q];
    int ans=0;
    for (int i = 0; i < Q; ++i) {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    // 配列の要素数は数値で指定する
    int A[10+1];
    for (A[0] = 1; A[0] <=M ; ++A[0]) {
        for (A[1] = A[0]; A[1] <=M ; ++A[1]) {
            for (A[2] = A[1]; A[2] <=M ; ++A[2]) {
                for (A[3] = A[2]; A[3] <=M ; ++A[3]) {
                    for (A[4] = A[3]; A[4] <=M ; ++A[4]) {
                        for (A[5] = A[4]; A[5] <=M ; ++A[5]) {
                            for (A[6] = A[5]; A[6] <=M ; ++A[6]) {
                                for (A[7] = A[6]; A[7] <=M ; ++A[7]) {
                                    for (A[8] = A[7]; A[8] <=M ; ++A[8]) {
                                        for (A[9] = A[8]; A[9] <=M ; ++A[9]) {

                                            int sum=0;
                                            for (int i = 0; i < Q; ++i) {
                                                int x = b[i] - 1;
                                                int y = a[i] - 1;
                                                if(A[x] - A[y] == c[i])sum += d[i];
                                            }
                                            ans=max(ans,sum);

                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<ans;

    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;

    vector<int> ans(N, 0);
    rep(i, Q) {
        int A;
        cin >> A;
        A--;
        ans[A]++;
    }

    rep(i, N) {
        int result = K - Q + ans[i];
        if (result > 0) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, t;
	cin >> n >> x >> t;
	cout << (((n + x - 1) / x ) * t) << "\n";

	return 0;
}


Measured memory_bytes: 3644
# 大きくなるように取る
# 1 -> 5 -> 6 -> 5かな
# 1 6 12 17 23
N = int(input())
cnt = 0
a = N // 11
amari = N % 11
cnt += a*2
# print(a, amari)
if amari == 0:
    cnt += 0
elif amari <= 6:
    cnt += 1
else:
    cnt += 2
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long K,A,B,N,cnt=0,max=0;
    cin >> K >> A >>B;
    for(int i=A;i<B+1;i++){
        if(i%K==0){
            cout << "OK";
            break;
        }else if(i==B){
            cout << "NG";
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n);
  for (int i = 0; i < a.size(); i++) {
    cin >> a[i];
  }
  for (int i = 0; i < b.size(); i++) {
    cin >> b[i];
  }

  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    int left = min(a[i], b[i]);
    cnt += left;
    a[i] -= left;
    b[i] -= left;

    int right = min(a[i + 1], b[i]);
    cnt += right;
    a[i + 1] -= right;
    b[i] -= right;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll n;cin>>n;
    Graph G(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<ll> que,que2;
    que.push(0);
    que2.push(n-1);

    ll f_can=0,s_can=0;//fennec snuke それぞれの個数
    vector<bool> visit(n,false);
    visit[0]=true;
    visit[n-1]=true;

    while(que.size()+que2.size()!=0){
        ll num=que.size();
        for(ll i=0;i<num;i++){
            ll now=que.front();
            que.pop();            
            for(auto next:G[now]){
                if(visit[next]!=false) continue;
                visit[next]=true;

                //cout<<next<<" ";
                que.push(next);
                f_can++;
            }
        }

        ll num2=que2.size();
        for(ll i=0;i<num2;i++){
            ll now2=que2.front();
            que2.pop();
            for(auto next:G[now2]){
                if(visit[next]!=false) continue;
                visit[next]=true;

                //cout<<next<<" ";
                que2.push(next);
                s_can++;
            }
        }
    }

    if(f_can>s_can) cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;

    return 0;
}

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

int a, p, q, n;

int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}

int search(int np, int nq, int nn, int now, int aa){
	//cout << np << "\t" << nq << "\t" << nn << "\t" << now << "\t" << aa << endl;
	if (nq * p - np * q == 0) return 1;
	else if (nq * p - np * q < 0 || nn < 1) return 0;

	int result = 0;
	for (int i = now; i * aa <= a; i++){
			result += search(np * i + nq, nq * i,nn - 1, i, i * aa);
		
	}

	return result;
}

int main(void){

	while (cin >> p >> q >> a >> n, p, q, a, n){

		cout << search(0, 1, n, q / p, 1) << endl;

	}

	return 0;
}

/*
for(i=0;i<N;i++){
cin >> X[i];
}


for(i=0;i<N;i++){
for(j=0;j<N;j++){
cin >> X[i][j];
}
}
*/

Measured memory_bytes: 1164
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean[] isPrime = new boolean[n*2 + 1];
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i < Math.sqrt(n) + 1; i++) {
            if (isPrime[i]) {
                for (int j = i*2; j < isPrime.length; j+=i) {
                    isPrime[j] = false;
                }
            }
        }
        for (int i = n; i < isPrime.length; i++) {
            if (isPrime[i]) {
                System.out.println(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 23124
import Control.Monad (replicateM)
import Data.List

main :: IO ()
main = do
  [n,m] <- map (read :: String -> Int) . words <$> getLine
  ksi <- map (tail . map (read :: String -> Int) . words) <$> getNLine_ m
  pm <- map (read :: String -> Int) . words <$> getLine
  let pks = zipWith (mySubsequences n) pm ksi
  print $ length $ foldl1 (intersectBy myeq) pks

myeq :: [Int] -> [Int] -> Bool
myeq xs ys = (xs \\ ys) == [] && (ys \\ xs) == []

mySubsequences :: Int -> Int -> [Int] -> [[Int]]
mySubsequences n b xs
  | b == 0 = (++) <$> subsequences ([1..n] \\ xs) <*> (filter (\k -> even $ length k) . subsequences $ xs)
  | b == 1 = (++) <$> subsequences ([1..n] \\ xs) <*> (filter (\k ->  odd $ length k) . subsequences $ xs)

getNLine_ :: Int -> IO [String]
getNLine_ n = replicateM n getLine

Measured memory_bytes: 2300
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 1e2 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes"); exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No"); exit(0); }
void one() { puts("-1"); exit(0); }

int N, W;
int w[maxn], v[maxn];
vector<ll>val[10];

void solve()
{
	ll res = 0;
	sa(N), sa(W);
	ll ind;
	repp(i, 1, N)
	{
		sa(w[i]), sa(v[i]);
		if (i == 1)ind = w[i];
		val[w[i] - w[1]].push_back(v[i]);
	}
	rep(i, 0, 4)
	{
		sort(val[i].begin(), val[i].end(), greater<ll>());
	}
	ll s1 = 0, s2 = 0, s3 = 0, s4 = 0;
	ll ans = 0;
	for (int i = 0; i <= val[0].size(); )
	{
		s2 = 0;
		for (int j = 0; j <= val[1].size(); )
		{
			s3 = 0;
			for (int k = 0; k <= val[2].size();)
			{
				s4 = 0;
				for (int h = 0; h <= val[3].size();)
				{
					ll sum = 1LL * i*(ind)+1LL * j*(ind + 1) + 1LL * k*(ind + 2) + 1LL * h*(ind + 3);
					if (sum <= W)
					{
						ans = max(ans, s1 + s2 + s3 + s4);
					}
					h++;
					if (h >= 1&&h<=val[3].size())s4 += val[3][h - 1];
				}
				k++;
				if (k >= 1 && k <= val[2].size())s3 += val[2][k - 1];
			}
			j++;
			if (j >= 1 && j <= val[1].size())s2 += val[1][j - 1];
		}
		i++;
		if (i >= 1&&i<=val[0].size())s1 += val[0][i - 1];
	}
	printf("%lld\n", ans);
}
int main()
{

	solve();
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();
        Console.WriteLine(n == m ? "Yes":"No");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140