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

long n, k;
double a[200005];

bool c(double m){
  long cnt = 0;
  for(int i=0; i<n; i++){
    cnt += (long)(a[i] / m);
    if((int)(a[i]/m)*m == a[i])  cnt--;
  }
  return cnt <= k;
}

int main(){
  cin >> n >> k;
  for(int i=0; i<n; i++)  cin >> a[i];
  
  double s = 0, t = 1e10;
  for(int i=0; i<1000; i++){
    double mid = (s + t) / 2.0;
    if(c(mid))  t = mid;
    else  s = mid;
  }

  long ans = (long)s;
  if(s - (long)s)  ans++;

  cout << ans << endl;

  return 0;
}


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

#define Bye return 0
#define ll long long

using namespace std;

void solve(){
    int a, b; cin>>a>>b;
    int c = 1;
    while(c<=1009){
        int x = (int) c*0.08;
        int y = (int) c*0.1;

        if(x==a && y==b){
            cout<<c<<endl;
            return;
        }
        c++;
    }
    cout<<"-1"<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >> y[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,m; cin >> n>>m;
	vector<int> p(m),y(m);
	for(int i=0;i<m;i++){
		cin >> p[i]>> y[i];
		p[i]--;
	}
	vector<vector<int>> pre(n);
	for(int i=0;i<m;i++) pre[p[i]].push_back(y[i]);

	for(int i=0;i<n;i++)
		sort(pre[i].begin(),pre[i].end());
	for(int i=0;i<m;i++){
		int num= p[i];
		printf("%06d",num+1);

		int id = lower_bound(pre[num].begin(),pre[num].end(),y[i])-pre[num].begin();
		printf("%06d\n",id+1);
	}

}

Measured memory_bytes: 7808
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    A = LI()
    A = sorted(A)
    ans = 0
    ans += A[1] - A[0] + A[2] - A[1]
    print(ans)

main()



Measured memory_bytes: 10840
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll nax=1e6+5, inf=1e18;
const ld PI = 3.141592653589793, eps = 1e-8;
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
pp get(pp px){
	ll x=px.fi, y=px.se;
	if(x==0 && y==0)
		return {0,0};
	ll g=__gcd(x,y);
	x/=g;
	y/=g;
	if(x<0 && y<0){
		x*=-1;
		y*=-1;
	}
	if(y<0){
		x*=-1;
		y*=-1;
	}
	if(x==0)y=1;
	if(y==0)x=1;
	return {x,y};
}
pp opp(pp px){
	pp py=get(px);
	ll x=-py.se, y=py.fi;
	if(x==0 && y==0)return {0,0};
	ll g=__gcd(x,y);
	x/=g;
	y/=g;
	if(x<0 && y<0){
		x*=-1;
		y*=-1;
	}
	if(y<0){
		x*=-1;
		y*=-1;
	}
	if(x==0)y=1;
	if(y==0)x=1;
	return {x,y};
}
void solve(){
	map<pair<ll,ll>,ll> mapa, vis;
	ll n, ans=1;
	cin>>n;
	vector<pp> v(n);
	rep(i,0,n){
		cin>>v[i].fi>>v[i].se;
		mapa[get(v[i])]++;
	}
	for(auto x : mapa){
		if(x.fi.fi==0 and x.fi.se==0)continue;
		if(vis[x.fi])continue;
		vis[x.fi]=1;
		pp py=opp(x.fi);
		if(mapa.count(py)){
			vis[py]=1;
			ans=mult(ans,add(add(powMod(2,mapa[x.fi]),powMod(2,mapa[py])),hell-1));
		} else {
			ans=mult(ans,powMod(2,mapa[x.fi]));
		}
	}
	ans=add(ans,hell-1);
	ans=add(ans,mapa[{0,0}]);
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

const int MAXN = 405;
typedef unsigned long long ull;
const ull bas = 19260817;

int n, a[MAXN][MAXN];
ull c[MAXN][MAXN], d[MAXN][MAXN];
char str[MAXN];

void init() {
	ull x = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			c[i][j] = a[i][j]*x+c[i-1][j]+c[i][j-1]-c[i-1][j-1];
			x *= bas;
		}
	x = 1;
	for (int j = 1; j <= n; j++)
		for (int i = 1; i <= n; i++) {
			d[i][j] = a[i][j]*x+d[i-1][j]+d[i][j-1]-d[i-1][j-1];
			x *= bas;
		}
}

ull query(ull a[MAXN][MAXN], int x1, int x2, int y1, int y2)
{ return a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1]; }

ull power[MAXN*MAXN*2];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%s", str+1);
		for (int j = 1; j <= n; j++)
			a[i][j] = str[j]-'a'+1;
	}
	init();
	power[0] = 1;
	for (register int i = 1; i <= n*n+n; i++)
		power[i] = power[i-1]*bas;
	int ans = 0;
	for (int A = 1; A <= n; A++) {
		for (int B = 1; B <= n; B++) {
			// cerr << a[A][B] << " ";
			ull curx = query(c, 1, A, 1, B)*power[n*n+n]+query(c, A+1, n, 1, B)*power[n]+query(c, 1, A, B+1, n)*power[n*n]+query(c, A+1, n, B+1, n);
			ull cury = query(d, 1, A, 1, B)*power[n*n+n]+query(d, A+1, n, 1, B)*power[n*n]+query(d, 1, A, B+1, n)*power[n]+query(d, A+1, n, B+1, n);
			curx *= power[(n-A)*n+(n-B)], cury *= power[(n-B)*n+(n-A)];
			// cerr << curx << " " << cury << endl;
			if (curx == cury)
				ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 4224
import Data.List

main = do
  li <- getLine
  let [n,m,x] = map read $ words li
  co <- getContents
  let cass = map (map read . words) $ lines co
  let ans = compute n m x cass
  print ans

compute :: Int -> Int -> Int -> [[Int]] -> Int
compute n m x cass
  | null sucs = -1
  | True      = head (head sucs)
  where
    sucs = filter success $ sort $ foldl step [repeat 0] cass
    step acc cas = acc ++ map (zipWith (+) cas) acc
    success (c:as) = all (x <=) as

Measured memory_bytes: 6740
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int n, m;
int deg[N], cnt[8];
int head[N], nex[N << 1], to[N << 1], cntE;
bool vis[N];

inline void addE(int u, int v) {
	to[++cntE] = v;
	nex[cntE] = head[u], head[u] = cntE;
}

int A, B;
void dfs(int u, int fa) {
	if(u == A && fa) {
		puts("Yes");
		exit(0);
	}
	if(u == B) return;
	for(int i = head[u]; i; i = nex[i]) {
		int v = to[i];
		if(v == fa) continue;
		dfs(v, u);
	}
}

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 1, u, v; i <= m; ++i) {
		scanf("%d %d", &u, &v);
		addE(u, v), addE(v, u);
		++deg[u], ++deg[v];
	}
	
	for(int i = 1; i <= n; ++i)
		if(deg[i] & 1) {
			puts("No");
			return 0;
		} else {
			if(deg[i] > 4) ++cnt[6];
			else if(deg[i] < 4) ++cnt[deg[i]];
			else ++cnt[4];
		}
	
	if(cnt[6] || (cnt[4] > 2)) {
		puts("Yes");
		return 0;
	} else if(cnt[4] == 2) {
		for(int i = 1; i <= n; ++i)
			if(deg[i] == 4) {
				if(!A) A = i;
				else {
					B = i;
					break;
				}
			}
		dfs(A, 0);
	}
	puts("No");
	return 0;
}

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

int main(){
	int N;
	cin>>N;
	vector<long>X(N);
	vector<long>Y(N);
	for(int i=0;i<N;++i){
		cin>>X[i];
		Y[i]=X[i];
	}
	sort(X.begin(),X.end());
	long left=X[N/2-1],right=X[N/2];
	long ans[N];
	for(int i=0;i<N;++i){
		if(Y[i]<=left)ans[i]=right;
		else ans[i]=left;
	}
	for(int i=0;i<N;++i){
		cout<<ans[i]<<endl;
	}
}


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

  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

void solve()
{
  int n;
    cin >> n;
    
   int a[n];
    f(i,n) cin >> a[i];
    
   int res = 0;
    
   map<int,int> mp;
    
   f(i,n)
   {
       res+=mp[i-a[i]];
       mp[i+a[i]]++;
   }
    
   cout <<res;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 27816
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			BigInteger bi1 = new BigInteger(sc.next());
			BigInteger bi2 = new BigInteger(sc.next());
			String ans = "EQUAL";
			if(bi1.compareTo(bi2) > 0) {
				ans = "GREATER";
			}else if(bi1.compareTo(bi2) < 0) {
				ans = "LESS";
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
	
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int a,b; cin >> a >> b;
    int ans = 0;
    for (int i = a;i <= b; ++i) {
        int k = i;
        vector<int> A;
        while (k) {
            A.push_back(k%10);
            k /= 10;
        }
        int sz = A.size();
        bool flag = true;
        rep(i,sz/2) {
            if (A[i] != A[sz - i - 1]) flag = false;
        }
        if (flag) ++ans;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3640
N = int(input())
S = [''] * 2
S[0] = input()
S[1] = input()

MOD = 10 ** 9 + 7

if S[0][0] == S[1][0]:
    ans = 3
    row = True
    skip = False
else:
    ans = 6
    row = False
    skip = True
for i in range(1, N):
    if not skip:
        if S[0][i] == S[1][i]:
            if row:
                ans *= 2
            else:
                ans *= 1
            row = True
        else:
            if row:
                ans *= 2
            else:
                ans *= 3
            row = False
            skip = True
        ans %= MOD
    else:
        skip = False

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n],b[8]={0};
	for(int i= 0; i<n; i++)
	{
		cin>>a[i];
		if(a[i]%4==0)
			b[4]++;
		else if(a[i]%2==0)
			b[2]++;
	}
	ll cnt = 2*b[4]+1;
	cnt += b[2]>0?b[2]-1:0;
	if(cnt>=n)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int i,h,n,a;
  cin >> h >> n;
  for(i=0;i<n;i++){
    cin >> a;
    h-=a;
  }
  if(h>0){
    cout << "No" << endl;
  }
  else if(h<=0){
    cout << "Yes" << endl;
  }
  return 0;
}

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

using namespace std;

#define ll             long long int
#define eb             emplace_back

static const int maxn = 4e5 + 5;
static const ll mod = 1e9 + 7;

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);
      cout << fixed << setprecision(12);


      int k, x;
      cin >> k >> x;
      vector <int> ans;
      int num = x - 1;
      for (int i = 1; i < k; i++)
      {
            ans.eb(num);
            --num;
      }
      ans.eb(x);
      num = x + 1;
      for (int i = 1; i < k; i++)
      {
            ans.eb(num);
            ++num;
      }
      sort(ans.begin(), ans.end());
      for (int x : ans) cout << x << " ";
      cout << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define ll long long
#define lowbit(x) x&(-x)
using namespace std;
const int MAX = 1010;
int c[MAX][MAX];
void add(int x,int y,int k){
    for(int i = x; i < MAX; i += lowbit(i)){
        for(int j = y; j < MAX; j += lowbit(j)){
            c[i][j] += k;
        }
    }
}
int query(int x, int y){
    int sum = 0;
    for(int i = x; i > 0; i -= lowbit(i)){
        for(int j = y; j > 0; j -= lowbit(j)){
            sum += c[i][j];
        }
    }
    return sum;
}
int main(){
	int n, m, q, l, r;
	cin >> n >> m >> q;
	for(int i = 1; i <= m; i ++) {
		cin >> l >> r;
		add(l,r,1);
	}
	while(q--) {
		cin >> l >> r;
		printf("%d\n",query(r,r)-query(l-1,r)-query(r,l-1)+query(l-1,l-1));
	}
	return 0;
}

Measured memory_bytes: 2944
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    string S;
    int N;
    cin >> N >> S;
    int t = S.size();
    rep(i,t) {
        S[i] = S[i] + N;
        if (S[i] - '0' > 42) {
            S[i] = S[i] - 26;
        }
    }
    rep(i, t) {
        cout << S[i];
    }
    cout << endl;
    return 0;
}

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

template <typename Value, typename Time, typename Compare = less<Value>>
class slidemin {
private:
    deque<pair<Value, Time>> deq;
    const Compare compare;

public:
    slidemin(Compare cmp = Compare()): compare(cmp) {}

    void push(Value val, Time t) {
        while(!deq.empty() && !compare(deq.back().first, val)) deq.pop_back();
        deq.emplace_back(val, t);
    }

    void pop(Time t) {
        while(!deq.empty() && deq.front().second < t) deq.pop_front();
    }

    pair<Value, Time> getmin() {
        return deq.front();
    }
};

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

    int cnt = 0;
    for(int i=0; i<=N; ++i) {
        if(S[i] == '1') ++cnt;
        else cnt = 0;
        if(cnt == M) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> dp(N + 1, 1001001001);
    dp[N] = 0;
    slidemin<int, int> mi;
    mi.push(0, 0);
    for(int i=1; i<=N; ++i) {
        if(S[N - i] != '1') {
            dp[N - i] = mi.getmin().first + 1;
            mi.push(dp[N - i], i);
        }
        mi.pop(max(i - M + 1, 0));
    }

    int turn = dp[0];
    int pos = 0;
    for(int i=1; i<=N; ++i) {
        if(dp[i] == turn - 1) {
            cout << i - pos << (i==N ? '\n' : ' ');
            pos = i;
            --turn;
        }
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)

int main() {
    int n,x,y;
    cin >> n >> x >> y;
    vector<int> ans(n-1); // 最短距離がkである(i,j)の組ans[k-1]個
    rep1(i,n) {
        rep1(j,n) {
            if (i <= j) break;
            int d = n;

            // 頂点x,yの間の辺を利用しない場合(一直線)
            d = min(d, abs(i-j));
            // i -> x -> y -> jの順
            d = min(d, abs(i-x)+1+abs(j-y));
            // i -> y -> x -> jの順
            d = min(d, abs(i-y)+1+abs(j-x));
        
            ans[d-1]++;
        }
    }
    rep(i,n-1) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3612
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N, D, X;
  cin >> N >> D >> X;
  while (N--) {
    int a; cin >> a;
    X += (D-1)/a + 1;
  }
  cout << X << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
def comb(n, k):
    x, y = 1, 1
    k = min(k, n-k)
    for i in range(k):
        x *= n - i
        x %= MOD
        y *= i + 1
        y %= MOD
        
    return x*modinv(y) % MOD

def modinv(a):
    b=MOD
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx%MOD

MOD=10**9+7
N,M,K=map(int,input().split())


x=0
for i in range(1,N//2+1):
   x+=2*i*(N-i)
if N%2==0: x-=N*N//4

y=0
for j in range(1,M//2+1):
    y+=2*j*(M-j)
if M%2==0: y-=M*M//4 

ans=comb(N*M-2,K-2)*(x*M*M+y*N*N)%MOD
print(ans)

Measured memory_bytes: 3064
/*
* @author:  codancer
* @createTime:  time
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
int main(){
	int a,b,k;
	cin>>k>>a>>b;
	rep(i,a,b){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
//#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

string s[8];
void solve(int y,int x){
    s[y][x]='0';
    rep(i,1,4){
        int ny=y+i;
        if(0<=ny && ny<=7 && s[ny][x]=='1'){
            solve(ny,x);
        }
    }
    
    rep(i,1,4){
        int ny=y-i;
        if(0<=ny && ny<=7 && s[ny][x]=='1'){
            solve(ny,x);
        }
    }
    
    rep(i,1,4){
        int nx=x+i;
        if(0<=nx && nx<=7 && s[y][nx]=='1'){
            solve(y,nx);
        }
    }
    
    rep(i,1,4){
        int nx=x-i;
        if(0<=nx && nx<=7 && s[y][nx]=='1'){
            solve(y,nx);
        }
    }
}

int main(){
    int n;
    cin>>n;
    
    rep(p,0,n){
        cout<<"Data "+to_string(p+1)+":"<<endl;
        int x,y;
        rep(i,0,8)cin>>s[i];
        cin>>x>>y;
        
        solve(y-1,x-1);
        rep(i,0,8){
            rep(j,0,8){
                cout<<s[i][j];
            }
            cout<<endl;
        }
        
    }
    
    return 0;
}



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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	int N;
	int s;

	cin >> N;
	cin >> s;

	if (N == s)
		rep(i, N) {
		cout << N;
	}
	else if (N > s) {
		rep(i, N) {
			cout << s;
		}
	}
	else {
		rep(i, s) {
			cout << N;
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
// Main.java

import java.util.Scanner;

public class Main {
	public static int func(int n) {
		int f = 0;
		while(n > 0) {
			f += n%10;
			n = n/10;
		}
		return f;
	}

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		int sum = 0;
		for(int n = 1; n <= N; n++) {
			final int f = func(n);
			if(A <= f && f <= B)
				sum += n;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 24020
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		LinkedList<Integer> que=new LinkedList<Integer>();
		int[] wait=new int[100];
		int[] a=new int[17];
		int[] b=new int[17];
		int[] rest=new int[17];

		for(int t=0;; t++){
			// ツ食ツ篠鳴終ツ猟ケツづーツ渉慊外
			for(int i=0; i<17; i++){
				if(--rest[i]<=0){
					a[i]=-1;
				}
			}

			// ツ新ツつオツつ「ツ客
			if(t%5==0&&t<500){
				que.addLast(t/5);
			}

			// ツづつづ淞づァツづェツづゥツつセツつッツづつづ淞づゥ
			for(; !que.isEmpty();){
				int c=que.getFirst();
				int n=c%5==1?5:2;
				for(int i=16; i>=0; i--){
					if(a[i]==-1){
						b[i]=(i==16?0:b[i+1])+1;
					}else{
						b[i]=0;
					}
				}
				int j=-1;
				for(int i=0; i<17; i++){
					if(b[i]>=n){
						j=i;
						break;
					}
				}
				if(j==-1){
					break;
				}
				for(int i=j; i<j+n; i++){
					a[i]=c;
					rest[i]=17*(c%2)+3*(c%3)+19;
				}
				wait[c]=t-5*c;
				que.removeFirst();
			}
			// debug(t, a);
			// debug(que.toArray());

			if(t>500&&que.isEmpty()){
				break;
			}
		}

		for(; sc.hasNext();){
			println(""+wait[sc.nextInt()]);
		}

	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


struct Edge
{
    ll to, cost;
};

void DFS(vector<vector<Edge> > &G, vector<ll> &color, int now){
    queue<ll> que;
    que.push(now);
    while (que.size()){
        int pos = que.front();
        que.pop();
        for (int i = 0; i < G[pos].size(); i++){
            Edge es = G[pos][i];
            if (color[es.to] != -1) continue;
            if (es.cost % 2 == 0){
                color[es.to] = color[pos];
            } else {
                color[es.to] = !color[pos];
            }
            que.push(es.to);
        }
    }
}

int main(){
    int N, u, v; cin >> N >> u >> v;
    u--; v--;
    vector<vector<int> > g(N);
    vector<int> dist(N, MM), Takahashi(N, MM);
    dist[v] = 0;
    for (int i = 0; i < N-1; i++){
        int a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> que;
    que.push(v);

    while (que.size()){
        int pos = que.front();
        que.pop();
        for (int i = 0; i < g[pos].size(); i++){
            int now = g[pos][i];
            if (dist[now] != MM) continue;
            dist[now] = dist[pos] + 1;
            que.push(now);
        }
    }

    Takahashi[u] = 0;
    que.push(u);
    while (que.size()){
        int pos = que.front();
        que.pop();
        for (int i = 0; i < g[pos].size(); i++){
            int now = g[pos][i];
            if (Takahashi[now] != MM) continue;
            Takahashi[now] = Takahashi[pos] + 1;
            que.push(now);
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++){
        if (Takahashi[i] > dist[i]) continue;
        //cout << "now pos ... " << i << ", Takahashi'dist is ... " << Takahashi[i] << ", Aoki's dist is ... " << dist[i] << endl;
        ans = max(ans, dist[i]-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6656
N,M=map(int,input().split())
P=[0 for i in range(M)]
Y=[0 for i in range(M)]
for i in range(M):
    P[i],Y[i]=map(int,input().split())
X=sorted([(Y[i],P[i],i) for i in range(M)])
Z=[(0,0) for i in range(M)]
T=[0 for i in range(N)]
for i in range(M):
    T[X[i][1]-1]+=1
    Z[X[i][2]]=(X[i][1],T[X[i][1]-1])
for seq in Z:
    a=max(0,6-len(str(seq[0])))
    b=max(0,6-len(str(seq[1])))
    print("0"*a+str(seq[0])+"0"*b+str(seq[1]))


Measured memory_bytes: 34508
#include <iostream>

using namespace std;

int main(){
	int n;
	while(cin >> n && n!=0){
		int sum = 0;
		int ans = 0;
		for(int i=2;i<100;i++){
			for(int j=1;j<1000;j++){
				sum = 0;
				for(int k=j;k<j+i;k++){
					sum +=k;
				}
				if(sum==n)ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  int n,a,b,p;
  int first,second,third;
  cin >> n >> a >> b;
  
  first=second=third=0;
  for(int i=0; i<n; i++){
    cin >> p;
    if( p <= a ) first++;
    else if( p <= b ) second++;
    else third++;
  }
  
  cout << min( first, min( second, third ) ) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100000011];
int main()
{
	int n;
	string s;
	cin >>n>>s;
	s=s+s;
	for(int i=0;i<2;i++)
	for(int j=0;j<2;j++)
	{
		a[0]=i;
		a[1]=j;
		for(int l=2;l<n+2;l++)
		{
			if(s[l-1]=='o'&&a[l-1]==0)
			a[l]=1-a[l-2];
			if(s[l-1]=='o'&&a[l-1]==1)
			a[l]=a[l-2];
			if(s[l-1]=='x'&&a[l-1]==0)
			a[l]=a[l-2];
			if(s[l-1]=='x'&&a[l-1]==1)
			a[l]=1-a[l-2];
		}
		if(a[n]==a[0]&&a[n+1]==a[1])
		{
			for(int i=0;i<n;i++)
			cout <<(a[i]?"S":"W");
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 1052
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<1;
  else if(b==0)
    cout<<2;
  else if(c==0)
    cout<<3;
  else if(d==0)
    cout<<4;
  else 
    cout<<5;
  return 0;
}

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

typedef long long ll;
const int mod = 1000000007;
const int MAX_N = 100005;

ll fact[MAX_N];         // 階乗
ll ifact[MAX_N];        // 階乗の逆元

// x^nを求める繰り返し二乗法(累乗の高速化)
// フェルマーの小定理より、逆元を計算するときに用いる。
ll mod_pow(ll x, int n){
    if(n == 0)      return 1;

    ll res = 1;
    while(n > 0){
        if(n & 1)   res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }

    return res;
}

// 階乗とその逆元テーブルを(0-n)まで埋める
void table(int n){
    fact[0] = 1;    // i^0 = 1;
    for(int i = 1; i <= n; ++i){
        fact[i] = fact[i - 1] * i % mod;
    }

    // フェルマーの小定理を利用して、右端の逆元を求める
    // 階乗の(mod-2)乗
    ifact[n] = mod_pow(fact[n], mod - 2);

    // 逆元の性質を利用して、テーブルを埋める
    for(int i = n; i >= 1; --i){
        ifact[i - 1] = ifact[i] * i % mod;
    }
}

// nCrを求める
ll combination(int n, int r){
    if(n < 0 || r < 0 || n < r)     return 0;

    return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, id1 = 0, id2 = 0;
    cin >> n;
    vector<int> a(n+1), cnt(n+1, 0);
    for(int i = 0; i < n+1; ++i){
        cin >> a[i];
        ++cnt[a[i]];
        
        if(cnt[a[i]] == 2)      id2 = i;   
    }
    for(int i = 0; i < n+1; ++i){
        if(a[i] == a[id2]){
            id1 = i;
            break;
        }
    }
    
    table(n+2);
    
    // 重複している数字をxとして、xの左にある数字の個数
    // a = [...x.....x...]
    int num1 = id1;
    // xの右側にある数字の個数
    int num2 = n - id2;

    // 重複している数字：x
    for(int i = 1; i <= n+1; ++i){        // 数字をi個取る
        ll res = combination(n + 1, i) - combination(num1 + num2, i - 1);
        res = (res + mod) % mod;
        cout << res << "\n";
    }
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
    static List<int[]>[] to;
    static long[] dist;
    static int n;
    
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        
        // to: 隣接リスト(無向)
        to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<int[]>();
        }
        for (int i = 0; i < n - 1; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            int dis = sc.nextInt();
            to[p].add(new int[]{q, dis});
            to[q].add(new int[]{p, dis});
        }
        
        // dist: kから各点への最短距離
        int query = sc.nextInt();
        int k = sc.nextInt() - 1;
        dist = new long[n];
        dfs(k, 0, -1);
        
        // p→k→qの最短距離を出力
        while (query-- > 0) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            
            System.out.println(dist[p] + dist[q]);
        }
    }
    
    // 頂点pと隣接する点に自分の値+距離を配る
    public static void dfs(int p, long d, int par) {
        dist[p] = d;
        
        for (int[] q : to[p]) {
            if (q[0] == par) continue;
            dfs(q[0], d + q[1], p);
        }
    }
}


Measured memory_bytes: 179340
//
// Created on 2020/06/07.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int ans = 0;

    while(x > 0 || y > 0){

        if(x > 0 && y > 0){
            if(a + b < 2 * c){
                ans += (a + b);
                x--;
                y--;
            }else{
                ans += 2 * c;
                x--;
                y--;
            }
        }else if(x > 0 && y == 0){
            if(a < 2 * c){
                ans += a;
                x--;
            }else{
                ans += 2 * c;
                x--;
            }
        }else if(x == 0 && y > 0){
            if(b < 2 * c){
                ans +=b ;
                y--;
            }else{
                ans += 2 * c;
                y--;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(map.containsKey(a)) {
                map.put(a, map.get(a) + b);
            }else {
                map.put(a, b);
            }
        }
        long ans = 0l;
        int count = 0;
        while(true) {
            Set<Map.Entry<Integer,Integer>> entries = map.entrySet();
            for(Map.Entry<Integer, Integer> entry : entries) {
                int aa = entry.getKey();
                int bb = entry.getValue();
                for(int i = 0; i < bb; i++) {
                    if(count >= m) {
                        System.out.println(ans);
                        return;
                    }
                    ans += aa;
                    count++;
                }
            }
        }
    }
}

Measured memory_bytes: 65048
a,b = list(map(int, input().split()))

cs = []
cs.append("." * (b+2))
for i in range(a):
  s = "." + input() + "."
  cs.append(s)
cs.append("." * (b+2))

ans = True
for i in range(a):
  for j in range(b):
    if cs[i][j] == "#":
      if cs[i-1][j] == "." and cs[i][j-1] == "." and cs[i+1][j] == "." and cs[i][j+1] == ".":
        ans = False
        break
    if not ans:
      break
  if not ans:
    break
if ans:
  print("Yes")
else:
  print("No")

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

int main(void){
  int n;
  cin >> n;
  if(n == 0){
    cout << 2 << endl;
  }
  else if(n == 1){
    cout << 1 << endl;
  }
  else{
    long long int a_1 = 2;
    long long int a_2 = 1;
    long long int b_1;
    for(int i = 2;i <= n;i++){
      b_1 = a_1+a_2;
      a_1 = a_2;
      a_2 = b_1;
    }
    cout << b_1 << endl;
  }
}


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

int main() {
	string A, B, C;
	cin >> A >> B >> C;
	string ans;
	if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
		ans = "YES";
	}
	else {
		ans = "NO";
	}
	cout << ans << endl;
}


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

#define repr(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define irepr(i,a,b) for(int i=a, i##_len=(b); i>=i##_len; --i)
#define irep(i,n) for(int i=n, i>=0; --i)

#define printline(str) cout << str << "\n"

#define lint longlong

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  if( abs(A-B)%2 != 0){
    printline("IMPOSSIBLE");
    return 0;
  }

  printline(abs(A+B)/2);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    vector<string> v;
    rep(i, S.length()) {
        bool ok = true;
        string I;
        REP(j, 0, i - 1) {
            if (S[j] == '?') I += 'a';
            else I += S[j];
        }
        rep(j, T.length()) {
            if (i + j >= S.length()) {ok = false; break;}
            else if (S[i + j] == T[j] || S[i + j] == '?') I += T[j];
            else {ok = false; break;}
        }
        REP(j, i + T.length(), S.length() - 1) {
            if (S[j] == '?') I += 'a';
            else I += S[j];
        }
        //cout << I << endl;
        if (ok) v.push_back(I);
    }
    sort(v.begin(), v.end());
    if (v.size()) cout << v[0] << endl;
    else cout << "UNRESTORABLE" << endl;

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 1; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


int main(){
  ll r;
  cin>>r;
  cout << fixed << setprecision(10);
  cout<<2*r*3.1415926;
} 


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

using namespace std;

int num[5];
int main()
{
    int a,b,c;
    while(cin >> a >> b >> c)
    {
        num[0]=a;
        num[1]=b;
        num[2]=c;
        sort(num,num+3);
        int t1=(num[2]-num[1])/2;
        int t2=(num[2]-num[0])/2;
        num[0]=num[0]+t2*2;
        num[1]=num[1]+t1*2;
        if(num[0]==num[1])
        {
            if(num[0]==num[2])
                cout << t1+t2 << endl;
            else
                cout << t1+t2+1 << endl;
        }
        else
        {
            cout << t1+t2+2 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
// ABC152E
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

ll m_pow(ll a, ll b){
    ll ret = 1;
    while(b > 0){
        if(b & 1)(ret *= a) %= MOD;
        (a *= a) %= MOD;
        b >>= 1;
    }
    return ret;
}

ll m_inv(ll a){
    ll b = MOD, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD; 
    if (u < 0) u += MOD;
    return u;
}

ll m_div(ll x){
    return m_pow(x, MOD - 2);
}

int main(){

    for(ll N; cin >> N;){
        V A(N);
        rep(i, N)cin >> A[i];
        map<ll, ll>cnt;
        for(auto a : A){
            map<ll, ll>tmp;
            ll x = a;
            for(ll j = 2; j * j <= x; j++){
                while(x % j == 0){
                    x /= j;
                    tmp[j]++;
                }
            }
            if(x > 1)tmp[x]++;
            for(auto p : tmp)chmax(cnt[p.first], p.second);            
        }
        ll m = 1;
        for(auto p : cnt)m = (m * m_pow(p.first, p.second)) % MOD;
        ll sum = 0;
        for(auto a : A){
            ll tmp = (m * m_inv(a)) % MOD;
            sum = (sum + tmp) % MOD;
        }
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include <iomanip>
#include<algorithm>
using namespace std;
int main()
{
	int h[1000],w[1000],n=1000,i=0;
	for(;i<n;i++)//????????\????????¨
	{	cin>>h[i]>>w[i];//?????´????¬¬i?????°??????0,0?????????????????¢???????????°???,??????i?°±??????????????\???????°??????°???,?????\????????\?????????.h????????????w?????????

	if(h[i]==0&&w[i]==0)
		break;
    }
	//??????1??°h-1????????????????????????1???h-1?????????????????????,??????????????????????????°??????
    for(int j=0;j<i;j++)
	{
		for(int k=1;k<=h[j];k++)
			{
				for(int m=1;m<=w[j];m++)
				{
					if(k%2==1&&m%2==1)
					cout<<"#";
				if(k%2==0&&m%2==0)
					cout<<"#";
					if(k%2==1&&m%2==0)
						cout<<".";
						if(k%2==0&&m%2==1)
							cout<<".";
						if(m==w[j])
							cout<<endl;



				}
				if(k==h[j])
							cout<<endl;//??¨????????¢????????????cout<<endl?????\??????????????????????????¨?????????),?????????????????\?????????





		}


	
	
	}



	




	}

Measured memory_bytes: 3068
#include <cstdio>
int main() {
	int n, x, num4 = 0, num1 = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (x % 4 == 0) {
			num4++;
		} else if (x % 2 == 1) {
			num1++;
		}
	}
	if (num4 >= n / 2 || num4 == num1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n, cnt[27], cur[27];

int main()
{
	for(int i=0;i<26;i++) cnt[i] = 100;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		for(int j=0;j<26;j++) cur[j] = 0;
		char tmp[55];
		scanf("%s",tmp);
		int len = strlen(tmp);
		for(int j=0;j<len;j++) cur[tmp[j]-'a']++;
		for(int j=0;j<26;j++) cnt[j] = min(cnt[j], cur[j]);
	}
	for(int i=0;i<26;i++) {
		for(int j=0;j<cnt[i];j++) putchar('a'+i);
	}
	puts("");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

int main() {
	ll N, M;
	cin >> N >> M;

	vector<vector<ll>> g(N + 1);
	vector<ll> in(N + 1, 0);

	repn(i, N + M - 1) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		in[b]++;
	}

	vector<ll> dis(N + 1, 0);
	queue<ll> q;
	repn(i, N) {
		if (in[i] == 0) { q.push(i); dis[i] = 0; }
	}

	while (!q.empty()) {
		ll v = q.front();
		q.pop();

		for (ll w : g[v]) {
			dis[w] = max(dis[w], dis[v] + 1);
			in[w]--;
			if (in[w] == 0) { q.push(w); }
		}
	}

	//repn(v, N) cout << dis[v]<<endl;

	vector<ll> ans(N + 1, 0);
	repn(v, N) {
		for (ll w : g[v]) {
			if (dis[w] == dis[v] + 1) { ans[w] = v; }
		}
	}

	repn(i, N) cout << ans[i] << endl;

	

	
	
	system("PAUSE");

}

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

int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    double a,b;
    cin>>a>>b;
    if(b==1) {
    	cout<<0;
    	return 0 ;
    }

    int x = ceil((b-a)/(a-1));
    cout<<x+1;

	return 0;		
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/




int main() {

int N;
cin>>N;
if(N%1000==0){
  cout<<0<<endl;
}
else{
  cout<<1000-N%1000<<endl;
}

return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int cnt[212345];

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N) scanf("%d", &A[i]), ++cnt[A[i]];
	
	ll sum = 0;
	REP(i, 212345) sum += (ll)cnt[i] * (cnt[i] - 1) / 2;
	REP(i, N) {
		ll c = cnt[A[i]] - 1;
		printf("%lld\n", sum - c);
	}
	
	return 0;
}


Measured memory_bytes: 3712
MAX = 8
INIT = "1 1 1 1 1 1 1 1 1 2 2 2 4 4 4 6 6 6 5 5 5 3 3 3 3 3 3 3 3 3"
LEFT, RIGHT, TOP, BOTTOM = (0..3).to_a

def rotate(cube, direction)
  swap = Array.new
  case direction
    when LEFT
      swap << [1, 24] << [4, 27] << [7, 30] << [10, 21] << [16, 18]
    when RIGHT
      swap << [3, 22] << [6, 25] << [9, 28] << [12, 19] << [13, 15]
    when TOP
      swap << [1, 28] << [2, 29] << [3, 30] << [15, 16] << [19, 21]
    when BOTTOM
      swap << [7, 22] << [8, 23] << [9, 24] << [13, 18] << [10, 12]
  end
  swap.map!{|i, j| [i - 1, j - 1]}

  result = cube.split
  swap.each do |i, j|
    result[i], result[j] = result[j], result[i]
  end
  result*" "
end

def bfs(init, limit)
  memo = Hash.new
  q = Array.new << [0, init]
  until q.empty?
    depth, cube = q.shift
    break if limit < depth
    memo[cube] = depth unless memo[cube]
    memo[cube] = [memo[cube], depth].min
    [LEFT, RIGHT, TOP, BOTTOM].each do |d|
      q << [depth + 1, rotate(cube, d)]
    end
  end
  memo
end

memo = bfs(INIT, MAX / 2)
gets.to_i.times do
  memo2 = bfs(gets.chomp, MAX / 2)
  p memo.each.map{|key, value| value + (memo2[key] ? memo2[key] : MAX)}.min
end

Measured memory_bytes: 6156