akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
struct scc{
    int N;
    vector<vector<int>> G, rG;
    vector<bool> used;
    vector<int> temp;
    vector<int> order;//分解後のトポロジカル順序
    vector<vector<int>> cnt;
    scc(int V){
        G.resize(V);
        rG.resize(V);
        N = V;
        order.resize(V);
    }
    void add(int s, int t){
        G[s].push_back(t);
        rG[t].push_back(s);
    }
    void dfs(int s){
        used[s] = true;
        for(int j: G[s]){
            if(!used[j]) dfs(j);
        }
        temp.push_back(s);
    }
    void rdfs(int s, int k){
        used[s] = true;
        order[s] = k;
        for(int j: rG[s]){
            if(!used[j]) rdfs(j, k);
        }
    }
    int solve(){//分解後の頂点数を返す
        used.resize(N, false);
        for(int i = 0; i < N; i++){
            if(!used[i]) dfs(i);
        }
        used.assign(N, false);  
        int k = 0; 
        for(int i = (int)temp.size() - 1; i >= 0; i--){ //番号が大きい方から順にdfs
            if(!used[temp[i]]) {
                rdfs(temp[i], k);
                k++;
            }
        }
        cnt.resize(k);
        for(int i = 0; i < N; i++){
            cnt[order[i]].push_back(i);
        }
        return k;
    }
};
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    scc scc(N);
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        scc.add(a, b);
    }
    int k = scc.solve();
    cout << k << endl;
    for(int i = 0; i < k; i++){
        int size = scc.cnt[i].size();
        cout << size << ' ';
        for(int j = 0; j < size; j++){
            if(j != size - 1) cout << scc.cnt[i][j] << ' ';
            else cout << scc.cnt[i][j] << endl;
        }
    }
}

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

int main(){
  int n,W;
  cin>>n>>W;
  int val[n], w[n];
  for(int i=0;i<n;i++)
    cin>>w[i]>>val[i];
  long long int dp[n+1][W+1];
	
  for(int i=0;i<=n;i++){
	for(int j=0;j<=W;j++){
      	if(i==0 || j==0)
      		dp[i][j]=0;
      	else if(j>=w[i-1])
          	dp[i][j] = max(val[i-1] + dp[i-1][j-w[i-1]], dp[i-1][j]);
        else
      		dp[i][j] = dp[i-1][j];
      	
    }
  }
  cout<<dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 79104
N, M = map(int, input().split())
dic = {}
for i in range(M):
  a, b = map(int, input().split())
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
  if b in dic:
    dic[b] += 1
  else:
    dic[b] = 1
for i in range(1, N + 1):
  if i not in dic:
    print(0)
  else:
    print(dic[i])


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

int fact[N], infact[N];

int qmi(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)	res = (ll)res * a % mod;
		a = (ll)a * a % mod;
		b >>= 1;
	}
	return res;
}

void init()
{
	fact[0] = 1, infact[0] = 1;
    for(int i = 1; i < N; ++i)
    {
        fact[i] = (ll)fact[i - 1] * i % mod;
        infact[i] = (ll)infact[i - 1] * qmi(i, mod - 2) % mod;
    }
}

ll C(int a, int b)
{
	return (ll)fact[a] * infact[b] % mod * (ll)infact[a - b] % mod;
}

int main()
{
	int k;
	string s;
	cin >> k >> s;
	
	int len = s.length();
	int n = k + len;
	init();						// 预处理阶乘 
	
	ll ans = 0;
	for(int i = len; i <= n; i++)
	{
		ll t = C(i - 1, len - 1) * qmi(25, i - len) % mod * (ll)qmi(26, n - i) % mod;
		ans = (ans % mod + t % mod) % mod;
	}
	cout << ans << endl;
	return 0;
}



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

double nageru(int i){
    double t=0;
    while(k>i){
        i*=2;
        t+=1;
    }
    return t;
}

  
int main(){
    
    cin>>n>>k;
    double ans=0.0;

    rep2(1,i,n+1){
        ans+=pow(0.5,nageru(i))/(double)n;
    }

    cout<<setprecision(15)<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int a, b, ans;
  char op;

  while(1){
    std::cin >> a >> op >> b;
    if(op == '?'){ break; }
    switch(op){
    case '+': ans = a + b; break;
    case '-': ans = a - b; break;
    case '*': ans = a * b; break;
    case '/': ans = a / b; break;
    }
    std::cout << ans << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	string s1,s2;
	cin>>s1>>s2;
	bool b=1;
	for(int i=0;i<s1.length();i++){
		if(s1[i]!=s2[i])b=0;
	}
	if(b)puts("Yes");
	else puts("No");
} 

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

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;



int main()
{
    ll N;

    cin >> N;

    vector <ll> a(N);

    REP(i,N)
    {
        cin >> a[i];
    }

    ll cnt = 0;

    ll tori = N;

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

    ll mae = a[0];

    if(a[0] > 100000)
    {
        cout << N << endl;
        return 0;
    }

        
    cnt = 1;

    bool flg = false;

    for(ll i = 1; i < N; ++i)
    {

        if(mae == a[i])
        {
            cnt++;
        }
        else
        {
            if(cnt >= mae)
            {
                tori -= cnt - mae;
            }
            else
            {
                tori -= cnt;
            }
            cnt = 1;
            mae = a[i];
        }

        if(a[i] > 100000)
        {
            tori -= N - i; 
            flg = true;

            break;
        }
    }

    //末尾処理
    if(flg != true)
    {
        if(cnt >= mae)
        {
            tori -= cnt - mae;
        }
        else
        {
            tori -= cnt;
        }
    }
    
    cout << N - tori << endl;

}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int M, N, R, V[8], d[200][200];
int main(){
  int RZTsC2BF, i, j, k, res, tmp;
  rd(N);
  rd(M);
  rd(R);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<R;Lj4PdHRW++){
      rd(V[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<(R-1) + 1;KL2GvlyY++){
      V[KL2GvlyY]--;
    }
  }
  sort(V, V+R);
  {
    int Q5VJL1cS;
    for(Q5VJL1cS=0;Q5VJL1cS<(N-1) + 1;Q5VJL1cS++){
      {
        int e98WHCEY;
        for(e98WHCEY=0;e98WHCEY<(N-1) + 1;e98WHCEY++){
          d[e98WHCEY][Q5VJL1cS] = 1073709056;
        }
      }
    }
  }
  {
    int cTE1_r3A;
    for(cTE1_r3A=0;cTE1_r3A<(N-1) + 1;cTE1_r3A++){
      d[cTE1_r3A][cTE1_r3A] = 0;
    }
  }
  for(RZTsC2BF=0;RZTsC2BF<M;RZTsC2BF++){
    rd(i);
    rd(j);
    rd(k);
    i--;
    j--;
    d[i][j] = d[j][i] = k;
  }
  for(k=0;k<N;k++){
    for(i=0;i<N;i++){
      for(j=i+1;j<N;j++){
        d[j][i] =chmin(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
  res = 1073709056;
  do{
    tmp = 0;
    {
      int FmcKpFmN;
      for(FmcKpFmN=1;FmcKpFmN<(R-1) + 1;FmcKpFmN++){
        tmp += d[V[FmcKpFmN]][V[FmcKpFmN - (1) + (0)]];
      }
    }
    chmin(res, tmp);
  }
  while(next_permutation(V,V+R));
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// int N, M, R, V[8];
// int d[200][200];
// {
//   int i, j, k;
//   int res, tmp;
// 
//   rd(N,M,R,V(R));
//   V[0..R-1]--;
//   sort(V, V+R);
//   d[0..N-1][0...N-1] = int_inf;
//   d[0..N-1][0..N-1] = 0;
//   rep(M){
//     rd(i,j,k);
//     i--; j--;
//     d[i][j] = d[j][i] = k;
//   }
//   rep(k,N) rep(i,N) rep(j,i+1,N) d[j][i] = d[i][j] <?= d[i][k]+d[k][j];
// 
//   res = int_inf;
//   do{
//     tmp = 0;
//     tmp += d[V[1..R-1]][V[0..]];
//     res <?= tmp;
//   }while(next_permutation(V,V+R));
// 
//   wt(res);
// }


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

long long GCD(long long X, long long Y) { return (Y == 0 ? X : GCD(Y, X % Y)); }

int main() {
	long long N, COUNT = 0;
	cin >> N;
	vector<long long> V(N);
	for (int i = 0; i < N; i++) cin >> V[i], COUNT += V[i];
	if (N % 2 == 0) {
		cout << (COUNT % 2 == 0 ? "Second" : "First") << endl;
		return 0;
	}
	bool NOW = true;
	long long Odd;
	while (1) {
		COUNT = 0, Odd = 0;
		for (int i = 0; i < N; i++) {
			COUNT += V[i];
			if (V[i] % 2 == 1) Odd++;
		}
		if (COUNT % 2 == 0) {
			cout << (NOW ? "First" : "Second") << endl;
			return 0;
		}
		if (Odd >= 3) {
			cout << (NOW ? "Second" : "First") << endl;
			return 0;
		}
		for (int i = 0; i < N; i++) {
			if (V[i] % 2 == 1) {
				if (V[i] == 1) {
					cout << (NOW ? "Second" : "First") << endl;
					return 0;
				}
				V[i]--;
			}
		}
		long long G = GCD(V[0], V[1]);
		for (int i = 2; i < N; i++) G = GCD(G, V[i]);
		for (int i = 0; i < N; i++) V[i] /= G;
		NOW = !NOW;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

// エラトステネスの篩[2,n]を列挙 O(nloglogn)
vector<lint> sieve_of_eratosthenes(lint n) {
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (lint i = 2; i*i <= n; ++i)
        if (is_prime[i])
            for (lint k = i+i; k <= n; k += i)
                is_prime[k] = false;
    vector<lint> primes;
    for (lint i = 2; i <= n; ++i)
        if (is_prime[i])
            primes.push_back(i);
    return primes;
}

// 素因数分解
map<lint,lint> factors(lint n, vector<lint> const & primes) { 
    map<lint,lint> result;
    for (lint p : primes) {
        if (n < p * p) break;
        while (n % p == 0) {
            result[p] += 1;
            n /= p;
        }
    }
    if (n != 1) result[n] += 1;
    return result;
}

int main(void) {
    lint n; cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    const int MOD = 1e9 + 7;
    vector<lint> primes = sieve_of_eratosthenes(n);
    map<lint, lint> mp;
    repeat_from_to(i, 2, n) {
        map<lint, lint> res = factors(i, primes);
        for(auto &e : res) {
            mp[e.first] += e.second;
        }
    }
    
    lint ans = 1;
    for(auto &e: mp) {
        ans *= (e.second + 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
    
}

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

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

	int n = s.size();

	bool flag = true;
	{
		string t = s;
		reverse(t.begin(), t.end());

		flag &= (s == t);
	}
	{
		string t = s.substr(0, n / 2), u = t;
		reverse(u.begin(), u.end());

		flag &= (t == u);
	}
	{
		int l = (n + 1) / 2, r = n;

		string t = s.substr(l, r - l + 1), u = t;
		reverse(u.begin(), u.end());

		flag &= (t == u);
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int w[10][4],h[10][4],pn[10],pc[10],pj[10],sx[10][4],f[10],da[10][20][4],e[21],md[20],can[20][20][10]; 
int mx,my,n2;

void find() {
	int x,y,i,j,k,p;
	for (i=0;i<n2;i++) for (x=0;x<20;x++) for (y=0;y<20;y++) can[y][x][pn[i]]=0; 
	for (i=0;i<n2;i++) 
		for (j=0;j<4;j++)
			for (y=0;y<=my-h[pn[i]][j];y++)
				for (x=0;x<=mx-w[pn[i]][j];x++) {
                   for (k=0; k<h[pn[i]][j]; k++) {
				   p=da[pn[i]][k][j]*e[x];
				   if ((md[y+k]+p) != (md[y+k] | p)) break;
				   }
				   if (k==h[pn[i]][j]) can[y][x][pn[i]]=1;
				}
	}



int ans(int n,int y) {
	int i,j,k,p,x;
	for (i=y;i<my;i++) for (j=0;j<mx;j++) if ((md[i] & e[j])==0) { x=j; y=i; j=i=99; } 
	for (i=0;i<n2;i++) {
		for (j=0;j<4;j++) if (can[y][x-sx[pn[i]][j]][pn[i]]==1) break;
		if (f[i]==1 || j==4) continue;
		for (j=0;j<pj[pn[i]];j++) {
			if (x<sx[pn[i]][j] || x-sx[pn[i]][j]+w[pn[i]][j]>mx || y+h[pn[i]][j]>my) continue; 
            for (k=0; k<h[pn[i]][j]; k++) {
				p=da[pn[i]][k][j]*e[x-sx[pn[i]][j]];
				if ((md[y+k]+p) != (md[y+k] | p)) break;
			    }
			    if (k == h[pn[i]][j]) {
				if (n==0) return 1;
				f[i]=1;
				for (k=0; k<h[pn[i]][j]; k++) md[y+k]+=da[pn[i]][k][j]*e[x-sx[pn[i]][j]];
			    p=ans(n-1,y);
				f[i]=0;
				for (k=0; k<h[pn[i]][j]; k++) md[y+k]-=da[pn[i]][k][j]*e[x-sx[pn[i]][j]]; 
				if (p==1) return 1;
	     		}  
		}
	}		
return 0;
}

int main() {
 char mp[22];
 int i,j=1,k,n,x,y,mc,p,ch[1024];
 for (i=0;i<21;i++) { e[i]=j; j*=2;} 
 while(true) {
 cin >> my >> mx;
 if ( mx==0 && my==0) break; 
 mc=0;
 for (i=0;i<my;i++) {
	 cin >> mp;
	 md[i]=0;
	 for (j=0; j<mx ; j++) if (mp[j]=='#') md[i]+=e[j]; else mc++;
 }

 cin >> n;
 for (i=0;i<10;i++) for (j=0;j<20;j++) for (k=0;k<4;k++) da[i][j][k]=0;
 for (i=0;i<n;i++) {
  cin >> h[i][0] >> w[i][0];
  pc[i]=0; pj[i]=4;

  for (j=0;j<h[i][0];j++) {  cin >> mp;
  for (k=0;k<w[i][0];k++) if (mp[k]=='#') { da[i][j][0]+= e[k]; pc[i]++;}
  }

  for (j=0; j<3; j++) {
	  h[i][j+1]=w[i][j]; w[i][j+1]=h[i][j];
	  for (y=0;y<h[i][j];y++) for (x=0;x<w[i][j];x++) if ((da[i][y][j] & e[x]) > 0 ) da[i][x][j+1]+=e[w[i][j+1]-y-1];
  }
  for (j=0;j<4;j++) for (k=0;k<w[i][j];k++) if ((da[i][0][j] & e[k])>0) { sx[i][j]=k; k=99;} 
  p=0;
  for (k=0;k<2;k++) {
	  for (y=0;y<h[i][k];y++) if (da[i][y][k]!=da[i][y][k+2]) break;
      if (y==h[i][k]) p++;
  }
  if (p==2) pj[i]=2;
  if (h[i][0]==h[i][1]) {
  for (y=0;y<h[i][0];y++) if (da[i][y][0]!=da[i][y][1]) break;
  if (y==h[i][0]) pj[i]=1;
  }
 }
 for (i=0;i<1024;i++) ch[i]=0;
 cin >> n; 
 for (i=0;i<n;i++) {
   cin >> n2; p=0; k=0;
   for (j=0; j<n2; j++)  { cin >> pn[j]; pn[j]--; p+=pc[pn[j]]; k+=e[pn[j]];}
   find();
   if ( p!=mc || ch[k]==2) cout << "NO" << endl; else
	   if (ans(n2-1,0)==1 || ch[k]==1) { cout << "YES" << endl; ch[k]=1;}  else { cout << "NO" << endl; ch[k]=2;}
   }
}
 return 0;
 }

Measured memory_bytes: 1184
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

class Program
{
	static void Main(string[] args)
	{

		int a = int.Parse(Console.ReadLine());
		int b = 1000 - (a % 1000);
		if (b == 1000) b = 0;

		Console.WriteLine(b);

	}

}

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

int main()
{
	ios::sync_with_stdio(false);
	
	int ans,n,k;
	cin>>n>>k;
	
	ans=(n-1)/(k-1);
	
	if((n-1)%(k-1)!=0)
		ans++;
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n >> m;
  if(n*m % 2 != 0)puts("Odd");
  else puts("Even");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define N 4
using namespace std;
int a[N], b[N - 1], c[N - 1];

void solve(int j){
    if(j == N - 1){
        int sum = a[0];

        for(int i = 1; i < N; i ++){
            sum += a[i] * c[i - 1];
        }
        if (sum == 7){
            for(int i = 0; i < N - 1; i ++){
                b[i] = c[i];
            }
        }
        return ;
    }else{
        c[j] = 1;
        solve(j + 1);
        c[j] = -1;
        solve(j + 1);
    }
}


int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    for(int i = 0; i < N; i ++){
        a[N - i - 1] = n % 10;
        n /= 10;
    }
    solve(0);
    if(b[0] != 0){
        cout << a[0];
        for(int i = 1; i < N; i ++){
            if(b[i - 1] == 1){
                cout << "+";
            }else{
                cout << "-";
            }
            cout << a[i];
        }
        cout << "=7" << endl;
    }else{
        cout << "error" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func sum(n int) int {
	sum := 0
	for i := 1; i-1 < n; i++ {
		sum += i
	}
	return sum
}

func main() {
	var n, l int
	fmt.Scan(&n, &l)

	all := l*n + sum(n-1)
	if l >= 0 {
		fmt.Println(all - l)
	} else if l+n-1 >= 0 {
		fmt.Println(all)
	} else {
		fmt.Println(all - (l + n - 1))
	}
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int n,a[110];
int main(){
	n=gi();
	for(int i=1;i<=n;i++)a[i]=gi();int ans=1e9;
	for(int x=-100;x<=100;x++){
		int ret=0;
		for(int i=1;i<=n;i++)
			ret+=(a[i]-x)*(a[i]-x);
		ans=min(ans,ret);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) std::cout << (x) << std::endl;
#define printa(x,n) for(int i = 0; i < n; i++){ std::cout << (x[i]) << " ";} std::cout << std::endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ std::cout << x[i][j] << " ";} std::cout << std::endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ std::cout << "(" << x[i].first << ", " << x[i].second << ") "; } std::cout << std::endl;
#define INF (1e18)
#define ll long long
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define __max(a,b) (((a) > (b)) ? (a) : (b))
#define __min(a,b) (((a) < (b)) ? (a) : (b))
class Plot {
public :
	int64_t x = 0;
	int64_t y = 0;
	Plot() :Plot(0, 0) {}
	Plot(int64_t x, int64_t y) {
		this->x = x;
		this->y = y;
	}
};
 
double Distance(int x1, int y1, int x2, int y2) {
	return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}
 
//階乗 
int fact(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}
 
int main()
{
	std::string in;
	std::cin >> in;
	int test = 0;
	if (in.compare("SUN") == 0) {
		test = 7;
	}
	if (in.compare("MON") == 0) {
		test = 6;
	}
	if (in.compare("TUE") == 0) {
		test = 5;
	}
	if (in.compare("WED") == 0) {
		test = 4;
	}
	if (in.compare("THU") == 0) {
		test = 3;
	}
	if (in.compare("FRI") == 0) {
		test = 2;
	}
	if (in.compare("SAT") == 0) {
		test = 1;
	}
  	std::cout << test;
	return 0;
}

Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.append(x)
b.append(y)
a =sorted(a)
b =sorted(b)
if a[-1]<b[0]:
    print('No War')
else:
    print('War')

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

void solve(){
	
	int n,k ;
	cin>>n>>k ;

	ll arr[n] ;
	for(int i=0;i<n;i++){
		cin>>arr[i] ;
	} 

	ll answer=1e18 ;

	for(int i=0;i+k<=n;i++){
		ll l=arr[i]; 
		ll r=arr[i+k-1] ;

		if(l>=0){
			answer=min(answer,r) ;
		}
		else if(r<=0){
			answer=min(answer,-l) ;

		}
		else{
			answer=min(answer,2*(-l)+r) ;
			answer=min(answer,2*r-l) ;
		}
 
	}

	cout<<answer ;

}	

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 4356
h, w, d = map(int, input().split())
A = []
for i in range(h):
    A.append(list(map(int, input().split())))
q = int(input())

I = [0] * (w * h + 1)
for i in range(h):
    for j in range(w):
        I[A[i][j]] = (i, j)
D = [0] * (h * w + 1)
for i in range(d + 1, h * w + 1):
    D[i] = D[i - d] + abs(I[i][0] - I[i - d][0]) + abs(I[i][1] - I[i - d][1])
s = []
g = []
for i in range(q):
    s, g = map(int, input().split())
    print(D[g] - D[s])


Measured memory_bytes: 19500
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto& i: a)
#define fl(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define rfl(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        forloop(n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define copy(a,b)         copy(all(a),back_inserter(b));
#define section(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));

const long long INF64 = 1e18;





void solve()
 { 
   int n,W;
   cin>>n>>W;
   vec<pair<int,int> >v;
  // int mv=0;
   fl(i,0,n-1)
     {
     	int w,x;
     	cin>>w>>x;
     	v.pb({w,x});
     	

     }
     int dp[1000008];
      // fill(dp,dp+10000007,INF64);
     for(int i=0;i<=1000007;i++)
     	  dp[i]=INF64;
       dp[0]=0;
       for(int i=0;i<n;i++)
       	  {
       	  	for(int j=1000007;j>=v[i].S;j--)
       	  	   {
       	  	   	dp[j]=min(dp[j],dp[j-v[i].S]+v[i].F);
       	  	   }
       	  }
     int ans=0;
       	   for(int i=0;i<=1000007;i++)
       	   	  {
                  if(dp[i]<=W)
                  	 ans=max(ans,i);
       	   	  }
       	   	  cout<<ans;
       	   	  
       

 }



  








 



signed main()
{fast
	int t;
   //cin>>t;
	t=1;

	while(t--)
		 {
		 	solve();
		 }
}












Measured memory_bytes: 8192
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	string s, t;
	cin >> s >> t;
	t.pop_back();
	cout << (s == t ? "Yes" : "No");
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 500000

enum Type{
	HIGH,
	LOW,
	UNDEFINED,
};

struct Info{
	int value,loc;
};

struct Data{
	Type type;
	int need_num;
};

int N,M,length,root;
int base[100000];
int parent[NUM];
Info info[100000];
Data data[NUM];

bool is_OK(int base_value){

	int count = 0;
	for(int i = 0; i < N; i++){
		if(info[i].loc == -1 && info[i].value >= base_value)count++;
	}

	for(int i = 0; i < length; i++){
		data[i].type = UNDEFINED;
		data[i].need_num = 1;
	}

	for(int i = 0; i < N; i++){
		if(base[i] != -1){
			if(base[i] >= base_value){
				data[i].type = HIGH;
			}else{
				data[i].type = LOW;
			}
		}
	}

	int loc[3] = {0,1,2};
	int num_HIGH,num_LOW,add;
	int work[3],sum;

	while(true){

		num_HIGH = 0,num_LOW = 0;

		for(int i = 0; i < 3; i++){
			if(data[loc[i]].type == HIGH){
				num_HIGH++;
			}else if(data[loc[i]].type == LOW){
				num_LOW++;
			}
		}

		if(num_HIGH >=2){

			data[parent[loc[0]]].type = HIGH;
			data[parent[loc[0]]].need_num = 0;

		}else if(num_LOW >= 2){

			data[parent[loc[0]]].type = LOW;
			data[parent[loc[0]]].need_num = 0;

		}else{
			add = 2-num_HIGH;

			for(int i = 0; i < 3; i++)work[i] = BIG_NUM;

			for(int i = 0; i < 3; i++){
				if(data[loc[i]].type == UNDEFINED){
					work[i] = data[loc[i]].need_num;
				}
			}

			sort(work,work+3);

			sum = 0;
			for(int i = 0; i < add; i++)sum += work[i];

			data[parent[loc[0]]].need_num = sum;
		}

		if(parent[loc[0]] == root)break;

		for(int i = 0; i < 3; i++){
			loc[i] += 3;
		}
	}

	if(data[root].type == HIGH)return true;
	if(data[root].type == LOW)return false;

	return count >= data[root].need_num;
}

int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++){
		base[i] = -1;
		info[i].loc = -1;
	}

	int maximum = 0,minimum = BIG_NUM;

	for(int i = 0; i < M; i++){
		scanf("%d %d",&info[i].value,&info[i].loc);
		info[i].loc--;
		base[info[i].loc] = info[i].value;
		maximum = max(maximum,info[i].value);
		minimum = min(minimum,info[i].value);
	}

	for(int i = 0; i < N-M; i++){
		scanf("%d",&info[M+i].value);
		maximum = max(maximum,info[M+i].value);
		minimum = min(minimum,info[M+i].value);
	}

	for(int i = 0; i < NUM; i++){
		parent[i] = -1;
	}

	int index = N;
	queue<int> Q;
	for(int i = 0; i < N; i++){
		Q.push(i);
	}

	int A,B,C;

	while(Q.size() != 1){
		A = Q.front();
		Q.pop();
		B = Q.front();
		Q.pop();
		C = Q.front();
		Q.pop();

		parent[A] = index;
		parent[B] = index;
		parent[C] = index;

		Q.push(index);
		index++;
	}

	length = index;
	index--;
	root = index;

	int left = minimum,right = maximum,m = (left+right)/2;
	int ans = minimum;

	while(left <= right){
		if(is_OK(m)){
			ans = m;
			left = m+1;
		}else{
			right = m-1;
		}
		m = (left+right)/2;
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 7700
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[derive(PartialEq, Debug, Clone)]
pub struct UnionFindNode {
  pub par: usize,
  pub rank: usize,
}

#[derive(PartialEq, Debug, Clone)]
pub struct UnionFind(pub Vec<UnionFindNode>);

impl UnionFind {
  //初期化
  pub fn new(size: usize) -> UnionFind {
    let mut vec = Vec::new();
    for i in 0..size {
      vec.push(UnionFindNode { par: i, rank: 0 });
    }

    UnionFind(vec)
  }

  //根を求める
  pub fn find(&mut self, x: usize) -> usize {
    if self.0[x].par == x {
      x
    } else {
      let par = self.0[x].par;
      let v = self.find(par);
      self.0[x].par = v;
      v
    }
  }

  //xとyの集合を併合
  pub fn unite(&mut self, x: usize, y: usize) {
    let x = self.find(x);
    let y = self.find(y);
    if x == y {
      return;
    }

    if self.0[x].rank < self.0[y].rank {
      self.0[x].par = y;
    } else {
      self.0[y].par = x;
      if self.0[x].rank == self.0[y].rank {
        self.0[x].rank += 1;
      }
    }
  }

  //xとyが同じ集合に属するか
  pub fn same(&mut self, x: usize, y: usize) -> bool {
    self.find(x) == self.find(y)
  }
}

fn main() {
  input! {
  n: usize,
  m: usize,
  mut friend: [(Usize1,Usize1); m],
  }
  let mut uf = UnionFind::new(n);

  for i in 0..m {
    uf.unite(friend[i].0, friend[i].1);
  }

  let mut veccnt = vec![0;n];
  for i in 0..n {
    veccnt[uf.find(i) as usize] += 1;
  }

  let max  =veccnt.iter().max().unwrap();

    println!("{}", max);

}


Measured memory_bytes: 11432
# 単純な組み合わせだと計算量がO(n**2)となってしまうので工夫が必要
# 小さい順にK番目の値を求めよ
# ⇄ 判定条件「x以下のものがK個以上ある」を満たす最小のxを求めよ
# ⇄ ・判定条件を満たす最小のx：2分探索 (-10**18 ~ 10**18)
# 　 ・「数列から２個選んだ積がx以下のものが何個あるかを数えて、K個以下か判定せよ」：片方を固定して2分探索で数えていく
import sys
input = sys.stdin.readline

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A = sorted(A)
ok, ng = 10**18, -10**18

# 判定条件を満たす最小のx：2分探索 (-10**18 ~ 10**18)
while ok - ng > 1:
    mid = (ok + ng) // 2
    # 数列から２個選んだ積がx以下のものが何個あるかを数える
    s = 0
    t = 0
    for i in range(N):
        if A[i] > 0:
            # 固定したA[i]が正の場合、積の数列
            # A[i]*A[0], A[i]*A[1], ... , A[i]*A[n-1]
            # つまり、{A[i]*A[j]} j=0~n-1 という数列は単調増加
            # j=JOKの時が「x以下」という条件を満たす最大値とすると、条件を満たす個数はJNG個である
            # 図解すると、
            # x以下(OK), x以下(OK), ..., x以下(OK), xより大きい(NG),...,xより大きい(NG)
            # <------------ JNG個 --------------><----------- N - JNG個 ----------->
            # 二分探索でこの境界値Jを求めにいく
            jok, jng = -1, N
            while jng - jok > 1:
                jmid = (jok + jng) // 2
                if A[i] * A[jmid] <= mid:
                    jok = jmid
                else:
                    jng = jmid
            s += jok + 1
        elif A[i] < 0:
            # 固定したA[i]が負の場合、積の数列
            # A[i]*A[0], A[i]*A[1], ... , A[i]*A[n-1]
            # は単調減少。
            # j=JOKの時が、「x以下」という条件を満たす最小のJだとすると、条件を満たす個数はJ+1個である
            # 図解すると、
            # xより大きい(NG), xより大きい(NG), ..., xより大きい(NG), x以下(OK),...,x以下(OK)
            # <--------------------- JOK個 ---------------------><----- N-JOK個 ------->
            jng, jok = -1, N
            while jok - jng > 1:
                jmid = (jok + jng) // 2
                if A[i] * A[jmid] <= mid:
                    jok = jmid
                else:
                    jng = jmid
            s += (N - jok)
        elif mid >= 0:
            s += N
        if A[i] * A[i] <= mid:
            t += 1
    # 求めたsは条件を満たす順列の個数なので、組み合わせの個数にするために/2する
    total = (s - t) // 2
    # それがK個以上あるかを判定する
    if total >= K:
        ok = mid
    else:
        ng = mid
print(ok)


Measured memory_bytes: 103896
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,r;
  cin>>n;

  while(n>0)
  {
      r=n%10;
      if(r==7)
      {
          cout<<"Yes\n";
          break;
      }
      n=n/10;
  }
  if(r!=7)
    cout<<"No\n";
}


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

int main() {
  int N, Q;
  long K;
  cin >> N >> K >> Q;
  
  vector<int> A(Q);
  vector<long> point(N, 0);
  
  for(int i = 0; i < Q; i++) {
    cin >> A.at(i);
    point.at(A.at(i) - 1) += 1;
  }
  
  for(int i = 0; i < N; i++) {
    if(Q - point.at(i) >= K) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
    
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << w*h / 2;
	if (w / 2 == x && h / 2 == y) {
		cout << " 1" << endl;
	}
	else {
		cout << " 0" << endl;
	}
	return(0);
}

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

using namespace std;
vector<vector<int> > edge(100000+1, vector<int>(0));
vector<int> dist(100000+1, -1);
vector<int> path(0);
vector<int> color(100000+1, -1);
int n;
int num;

bool dfs(int curr){
	if (curr == n)
		return true;

	for (int i = 0; i < edge[curr].size(); i++){
		if (dist[edge[curr][i]] == -1){
			path.push_back(edge[curr][i]);
			dist[edge[curr][i]] = dist[curr] + 1;
			if(dfs(edge[curr][i]))
				return true;
			else {
				path.pop_back();
			}
		}
	}

	return false;
}

void dfs2(int curr){
	num += color[curr];
	for (int i = 0; i < edge[curr].size(); i++){
		if (color[edge[curr][i]] == -1){
			color[edge[curr][i]] = color[curr];
			dfs2(edge[curr][i]);
		}
	}
}


int main(void){
	cin >> n;


	int a, b;
	for (int i = 0; i < n-1; i++){
		cin >> a >> b;

		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	dist[1] = 0;
	dfs(1);


	color[1] = 1;
	for (int i = 0; i < path.size(); i++){
		if (i < path.size()/2)
			color[path[i]] = 1;
		else
			color[path[i]] = 0;
	}

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

	if (num > n/2)
		cout << "Fennec" << endl;
	else
		cout << "Snuke" << endl;

}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout);
    int m = pow(10,9)+7;
    long long n; cin>>n;
    long long freq[n+1]={};
    
    for(int i=2;i<=n;i++)
    {
        int cur = i;
        for(int j=2;j<=i;j++)
        {
            while(cur%j==0)
            {
                freq[j]++;
                cur/=j;
            }
        }
    }

    long long ans = 1;

    for(int i=2;i<=n;i++)
    {
        ans*=(freq[i]+1);
        ans%=m;
    }
    
    cout<<ans;

    //for(int i=1;i<=n;i++) cout<<freq[i]<<endl;
}

Measured memory_bytes: 3656
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]

# k台以内のトラックで運べる荷物の個数
# P: ひとつのトラックに積載できる最大量
def check(P):
	i = 0
	for j in range(k):
		s = 0
		while s + w[i] <= P:
			s += w[i]
			i += 1
			if i == n:
				return n
	return i

# 二部探索
left = 0
right = 100000 * 10000
while right - left > 1:
	mid = (left + right) // 2
	v = check(mid)
	if v >= n:
		right = mid
	else:
		left = mid

print(right)


Measured memory_bytes: 9560
#include "cstdio"
#include "cstring"
using namespace std;
int main()
{
    //freopen("input.txt","r",stdin);
   	int i,j;
   	for(i=1;i<=9;i++)
   	{
   		for(j=1;j<=9;j++)
   		{
   			printf("%dx%d=%d\n",i,j,i*j);
   		}
   	}
    return 0;
};

Measured memory_bytes: 924
<?php
/**
 * Created by PhpStorm.
 * User: ramia
 * Date: 2016/09/24
 * Time: 21:00
 */
class STD {
	static function input(){
		$line = trim(fgets(STDIN));
		return $line;
	}

	static function output( $text ){
		echo $text."\n";
	}
}

//while(true){
	$hoge = STD::input();
	$result = substr($hoge,0,4).' '.substr($hoge,4);

	STD::output($result);
//}

?>

Measured memory_bytes: 3704
#include <iostream>
#include <bits/stdc++.h>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <iomanip>
#define initrand mt19937 mt_rand(time(0));
#define rand mt_rand()
#define int long long
#define INF 10000000000000
#define mid(l, u) ((l+u)/2)
#define lchild(i) (i*2 + 1)
#define rchild(i) (i*2 + 2)
using namespace std;
signed main(){
    int n, k;
    cin>>n>>k;
    int a[n];
    for(int i =0 ;i<n;i++) cin>>a[i];
    int l = 1;
    int u = 1e9;
    int ans = 1e9;
    while(l<=u){
        int m = mid(l, u);
        int total = 0;
        for(int j = 0;j<n;j++){
            int pieces = ((a[j] + (m-1))/m);
            total += pieces - 1;
        }
        if(total > k){
            l = m+1;
        }
        else{
            ans = min(ans, m);
            u = m-1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5104
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n, a, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		ans += a-1;
	}
	cout << ans << endl;
	return 0;
}


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

typedef struct {
	int x;
	int y;
	int value;
}Point;

Point Real[300*300+1];
int main(void) 
{
	
	int H,W,D,Q,a,b,k,l,m,number;
	scanf("%d%d%d",&H,&W,&D);
	for(k=0;k<=H*W;k++)
	{
		Real[k].value = 0;
	}
	for(a=0;a<H;a++)
	 {
	 	for(b=0;b<W;b++)
	 	{
	 		scanf("%d",&number);
	 		 Real[number].x = a;
	 		 Real[number].y = b;
	 	}
	 }
	 for(l=D+1;l<=H*W;l++)
	 {
	 	Real[l].value = Real[l-D].value + abs(Real[l].x-Real[l-D].x) 
	 	+abs(Real[l].y - Real[l-D].y);
	 }
	 scanf("%d", &Q);
	 for(m=0;m<Q;m++)
	 {
	 	scanf("%d%d", &a,&b);
	 	printf("%d\n",(Real[b].value-Real[a].value));
	 }
}

Measured memory_bytes: 2048
H, W = map(int, input().split())
d = [list(input()) for _ in range(H)]

for h in range(H):
    for w in range(W):
        if d[h][w] == '.':
            continue
        if w + 1 < W:
            if d[h][w + 1] == '#':
                continue
        if h + 1 < H:
            if d[h + 1][w] == '#':
                continue
        if -1 < w - 1:
            if d[h][w - 1] == '#':
                continue
        if -1 < h -1:
            if d[h - 1][w] == '#':
                continue
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
//#define int long long 
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	string s1,s2;
	cin>>s1>>s2;
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	if(s==s1) a--;
	else if(s==s2) b--;
	cout<<a<<" "<<b<<endl;
	
 
 
 
 
 
 
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        a: i32,
        b: i32,
        h: i32,
    }
    let ans = (a+b)*h/2;
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    int N;
    string S, T;
    cin >> N >> S >> T;

    int64_t ans;
    if(S[0] == T[0]) {
        ans = 3;
    } else {
        ans = 6;
    }

    for(int i=1; i<N; i++) {
        if(S[i] == T[i]) {
            if(S[i-1] == T[i-1]) {
                ans *= 2;
            }
        } else if(S[i-1] == T[i-1]) {
            ans *= 2;
        } else if(S[i-1] != S[i]) {
            ans *= 3;
        }
        ans %= MOD;
    }

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


Measured memory_bytes: 256
import java.util.Scanner;
 public class Main { 
   public static void main(String[] args) {
        double pi = 3.141592653589;
        double r;
        Scanner scan = new Scanner(System.in);
        r = scan.nextDouble();
        System.out.printf("%6f %6f",(pi*r*r),(2*pi*r));
 
    }
 
} 


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h + 2, string(w + 2, '#'));
    string ss;
    int wall_count = 0;
    for (int i = 1; i <= h; i++) {
        cin >> ss;
        s[i] = "#" + ss + "#";
        for (int j = 0; j < w; j++) {
            if (ss[j] == '#') {
                wall_count++;
            }
        }
    }

    deque<tuple<int, int, int>> q;
    q.emplace_back(1, 1, 0);
    s[1][1] = '@';

    bool ok = false;
    int r, c, cnt;
    while (!q.empty()) {
        auto kns = q.front(); q.pop_front();
        tie(r, c, cnt) = kns;
        if (r == h && c == w) {
            ok = true;
            break;
        }

        if (s[r + 1][c] == '.') {
            q.emplace_back(r + 1, c, cnt + 1);
            s[r + 1][c] = '@';
        }
        if (s[r - 1][c] == '.') {
            q.emplace_back(r - 1, c, cnt + 1);
            s[r - 1][c] = '@';
        }
        if (s[r][c + 1] == '.') {
            q.emplace_back(r, c + 1, cnt + 1);
            s[r][c + 1] = '@';
        }
        if (s[r][c - 1] == '.') {
            q.emplace_back(r, c - 1, cnt + 1);
            s[r][c - 1] = '@';
        }

    }

    if (ok) {
        cout << (w * h) - wall_count - (cnt + 1) << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,d=0;
  cin>>a;
  vector<int> b(a),c(a);
  fo(i,a)
    cin>>b[i];
  fo(i,a)
    cin>>c[i];
  for(int i=0;i<a;i++)
    d+=max<int>(0,b[i]-c[i]);
  cout<<d<<endl;
}


Measured memory_bytes: 256