akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>



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


map<string, int> mp;
#define ll long long

int main() {
    int n;
    cin >> n;
    int l[200];
    rep(i, 2*n) {
        cin >> l[i];
    }
    sort(l, l +2* n);
    int ans = 0;
    for (int i = 0; i < n*2; i += 2) {
        ans += l[i];
  }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
AA = [[0,0] for i in range(N)]
for i in range(N):
  AA[i][0] = A[i]
  AA[i][1] = i + 1
B = sorted(AA)
BB = [B[i][1] for i in range(N)]
BB2 = [str(s) for s in BB]
print(" ".join(BB2))

Measured memory_bytes: 30052
import sys

sys.setrecursionlimit(10 ** 6)


def dfs(v, c):
    flgs[v] = c
    for i in range(len(G[v])):
        if flgs[G[v][i]] == c:
            return False
        if flgs[G[v][i]] == 0 and not dfs(G[v][i], -c):
            return False

    return True


if __name__ == '__main__':
    N, M = map(int, input().split())
    G = [[] for _ in range(N + 1)]
    for i in range(M):
        a, b = map(int, input().split())
        G[a].append(b)
        G[b].append(a)

    # 二部グラフ判定をする
    bi_flg = True
    flgs = [0 for _ in range(N + 1)]
    for i in range(1, N + 1):
        if flgs[i] == 0:
            if not dfs(i, 1):
                bi_flg = False

    if bi_flg:
        # 二部グラフならBW-M
        print(flgs.count(1) * flgs.count(-1) - M)
    else:
        # 二部グラフでないなら全辺-M
        print((N * (N - 1) // 2) - M)


Measured memory_bytes: 31144
#include <iostream>

int main(void) {
  int S;
  std::cin >> S;
  int Y = S / 100;  Y = (1 <= Y && Y <= 12);
  int M = S % 100;  M = (1 <= M && M <= 12);
  if (Y && M) {
    std::cout << "AMBIGUOUS";
  } else if (Y) {
    std::cout << "MMYY";
  } else if (M) {
    std::cout << "YYMM";
  } else {
    std::cout << "NA";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
int main(){
    int n,ans=INF;
    cin>>n;
    int w[n];
    rep(i,n){
        cin>>w[i];
    }
    int sum[n+1];sum[0]=0;
    for(int i=1;i<=n;i++){
        sum[i]=sum[i-1]+w[i-1];
    }
    for(int i=1;i<n;i++){
        ans=min(ans,abs(sum[i]-(sum[n]-sum[i])));
    }
    cout<<ans<<endl;
    return 0;   
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, C;
    long long K;
    cin >> A >> B >> C >> K;
    if (K % 2 == 0) cout << A - B << endl;
    else cout << B - A << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S,str = "CF";
    cin >> S;
    int cnt = 0;
    for(char c:S){
        if(c == str[cnt]){
            cnt++;
        }
        if(cnt == 2){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
n ,k =map(int,input().split())
a = list(map(int,input().split()))
p = {i for i in range(n)}
now = 1
ok = [0 for i in range(n)]
cou = 1
ok[0] = 1
while True:
    cou += 1
    nex = a[now-1]
    if ok[nex-1] == 0:
        ok[nex-1] = cou
    elif ok[nex-1] != 0:
        break
    now = nex
    if cou == k+1:
        print(nex)
        exit()

lost = k - (ok[nex-1]-1)
lokz = cou - ok[nex-1]

p = lost%lokz
ans = ok.index(ok[nex-1]+p)+1
print(ans)

Measured memory_bytes: 37996
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<vector<int>> Graph;

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

	sort(a, a + 3);

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

	return 0;
}

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

int main(void) {
    double x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    printf("%.5f\n", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));
    return 0;
}


Measured memory_bytes: 3196
import bisect
import math
N,K = map(int,input().split(' '))
two_list = [ 2**i for i in range(18)]

rate = 0
for i in range(1,N+1):
    threshold = math.ceil(K/i) 
    two_idx = bisect.bisect_left(two_list,threshold)
    rate += 1 / N / two_list[two_idx]
print(rate)
    

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <queue>

using namespace std;

vector<int> v;
double func(int i)
{
	if (i == 0)
	{
		return v[i];
	}

	return (func(i - 1) + v[i]) / 2.0;
}

int main()
{
	int N;
	cin >> N;
	v.resize(N);
	for (int i = 0; i < N; i++)
	{
		cin >> v[i];
	}

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

	double ans = func(N - 1);

	cout << ans << endl;

	return 0;
 
}

Measured memory_bytes: 256
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=105;
const int maxw=1e5+5;

int n,m;
int w[maxn],v[maxn];
ll dp[maxn][maxw];

int main(){
	scanf("%d%d",&n,&m);
	REP(i,1,n) scanf("%d%d",w+i,v+i);
	dp[0][0]=0;
	REP(i,1,n){
		REP(j,0,m){
			dp[i][j]=dp[i-1][j];
			if(j>=w[i]) dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
		}
	}
	printf("%lld\n",dp[n][m]);
	return 0;
}


Measured memory_bytes: 79360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// Inputs
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int A[] = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = scan.nextInt();
		}
		int q = scan.nextInt();
		int m[] = new int[q];
		for (int i = 0; i < q; i++) {
			m[i] = scan.nextInt();
		}
		
		// Calculate & outputs
		for (int i = 0; i < q; i++) {
			if (isSumOf(m[i], A, 0, 0)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}

	private static boolean isSumOf(int x, int[] A, int index, int curSum) {
		if (x == curSum) return true;
		if (index == A.length) return false;
		if (isSumOf(x, A, index + 1, curSum + A[index])) return true;
		if (isSumOf(x, A, index + 1, curSum)) return true;
		return false;
	}

}



Measured memory_bytes: 26696
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e6 + 1;
const int MOD = 1e9 + 7;

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

int p_col[N];
int p_row[N];

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

	fill(p_col, p_col + N, -1);
	fill(p_row, p_row + N, -1);

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		p_row[x] = i;
	}
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		x--;
		p_col[x] = i;
	}
	int ans = 1;
	int cnt = 0;
	int free_col = 0;
	int free_row = 0;
	for (int i = n * m - 1; i >= 0; i--) {
		if (p_row[i] != -1 && p_col[i] != -1) {
			free_row++;
			free_col++;
		} else if (p_row[i] != -1) {
			ans = mul(ans, free_col);
			free_row++;
		} else if (p_col[i] != -1) {
			ans = mul(ans, free_row);
			free_col++;
		} else {
			ans = mul(ans, sub(mul(free_col, free_row), cnt));
		}
		cnt++;
	}
	cout << ans << '\n';
}



Measured memory_bytes: 11016
N = gets.chomp.to_i
mat = []
N.times do |n|
    s,p = gets.chomp.split(" ")
    mat << [s,p.to_i, n+1]
end

mat.sort! do |a,b|
    (a[0] <=> b[0] ).nonzero? || (b[1] <=> a[1])
end
puts mat.map{|n| n[2]}

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


def check_one(balls, partition):
    l_head = 0
    r_head = 0

    for i in xrange(10):
        ball = balls[i]
        # 左に入る場合
        if partition[i] == 1:
            if l_head > ball:
                # NG
                return False
            else:
                # OK
                l_head = ball
        # 右に入る場合
        else:
            if r_head > ball:
                # NG
                return False
            else:
                # OK
                r_head = ball

    # 最後まで return False しなかった
    return True


def generate_partitions():

    total = []

    for i in xrange(2**10):
        bin = [0] * 10
        for b in xrange(10):
            bin[b] = i >> b & 1

        total.append(bin)

    return total


def check_total(balls, total):
    for p in total:
        if check_one(balls, p):
            return True

    return False


def main():
    num_data_set = int(raw_input())

    for i in xrange(num_data_set):
        balls = map(int, raw_input().strip().split())
        total = generate_partitions()
        if check_total(balls, total):
            print 'YES'
        else:
            print 'NO'


main()

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

using namespace std;

#define MOD 1000000007

#define ll long long

#define FOR(i, a, b) for (int i=a; i<(b); i++)

#define FORd(i, a, b) for (int i=a; i<(b); --i) 

string t;

void solve(){

    int n=t.size();

    FOR (i,0,n){

        cout << t[i];

    }

    if (t[n-1]=='s') cout << 'e';

    cout << "s";

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cin >> t;

    solve();

    return 0; 

}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;

namespace program
{
    class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine((input[0] * 3 + input[1]) / 2);
		}
	}
}

Measured memory_bytes: 13268
#include <stdio.h>
int main(){

  int a,b,i,k;

  while(1){
  scanf("%d %d",&a,&b);
if(a==0 && b==0)break;

  for(i=0;i<a;i++){
    for(k=0;k<b;k++){
    printf("#");
  } 
  printf("\n");

 
  }
  printf("\n");
  }
 

  return 0;
  }

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

int main() {
	string s;
    cin >> s;
    int a;
    int z;
    for(int i=0;i<s.size();i++){
      if(s.at(i)=='A'){
        a = i;
        break;
      }
    }
    for(int i=a;i<s.size();i++){
      if(s.at(i)=='Z'){
        z = i;
      }
    }
    cout << z-a+1 << endl;        
}


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

using namespace std;

int main(){
    int d,g;
    cin >> d >> g;
    int p[d];
    int c[d];
    for(int i=0;i<d;i++){
        cin >> p[i] >> c[i];
    }
    int ans=1e9;

    for(int i=0;i<(1<<d);i++){
        int score=0;
        int num=0;
        int rest_max=-1;
        for(int j=0;j<d;j++){
            //最下位bitが1or0
            if((i>>j) & 1){
                score+=100*p[j]*(j+1)+c[j];
                num+=p[j];
            }else{
                rest_max=j;
            }
        }
        if(score<g){
            int s1=100*(rest_max+1);
            int need=(g-score+s1-1)/s1;
            if(need>=p[rest_max]) continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    cout << ans;

    return 0;
}


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

int main(){
  long N;
  cin >> N;
  long tmp = N;
  string str = "";
  while(tmp > 0){
    str =  (char)((tmp + 25) % 26 + 97) + str;
    if(tmp == 26) break;
    tmp = (tmp - ((tmp +25) % 26)) / 26;  
  }
  
  cout << str << endl;
}

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

using namespace std;
int main() {
	int n, a, res = 0;

	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		if (i % 2 != 0 && a % 2 != 0) {
			res++;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if((a & 1) != (b & 1)){
		cout << "IMPOSSIBLE";
		return 0;
	}
	cout << (a + b) / 2;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; ++i)cin >> a[i];
	vector<bool>color(8, false);
	int c=0,sub=0;
	for (int i = 0; i < n; ++i) {
		if (a[i] >= 3200) {
			++sub;
			continue;
		}
		color[a[i] / 400] = true;
	}
	for (int i = 0; i < 8; ++i) {
		if (color[i])++c;
	}if (c == 0) {
		++c;//0色はありえない
		--sub;
	}
	cout << c<<" " << c + sub << endl;
	return 0;
}

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

using ll = long long int;

ll N, W, v[60], w[60], m[60];
const ll X = 2;
const ll S = 60 * 60 * X;
const ll INF = 1LL << 60;
ll dp[S + 10];

ll solve() {
  fill(dp, dp + S + 10, INF);
  dp[0] = 0;
  for(ll i=0; i<N; i++) {
    ll t = min(X, m[i]); m[i] -= t;
    for(ll k=0; t>0; k++) {
      ll c = min(t, 1LL << k);
      t -= c;

      for(ll j=S; j>=c*v[i]; j--) {
        dp[j] = min(dp[j], dp[j-c*v[i]] + c*w[i]);
      }
    }
  }

  vector<int> ord(N);
  iota(ord.begin(), ord.end(), 0);
  sort(ord.begin(), ord.end(), [&](int i, int j) {
      return v[i] * w[j] > v[j] * w[i];
  });

  ll ret = 0;
  for(int i=0; i<=S; i++) {
    if(dp[i] > W) continue;
    ll rest = W - dp[i], sum = i;

    for(int k=0; k<N; k++) {
      int id = ord[k];
      ll lim = m[id];

      ll sub = min(lim, rest / w[id]);
      rest -= sub * w[id];
      sum += sub * v[id];
    }
    ret = max(ret, sum);
  }
  return ret;
}

int main() {
  cin >> N >> W;
  for(int i=0; i<N; i++) {
    cin >> v[i] >> w[i] >> m[i];
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <cmath>
using namespace std;
int weishu(long long int a)
{
	int sum=0;
	while (a)
	{
		sum++;
		a/=10;
	}
	return sum;
}
int main()
{
	long long int x,s;
	cin>>x;
	int l=int(sqrt(x));
	for (int i=l;i>0;i--)
	{
		if (x%i==0)
		{
			s=x/i;
			break;
		}
	}
	cout<<weishu(s)<<endl;
	return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

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

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,m;cin>>n>>m&&n|m;){
		int sum=1900*m+100*(n-m);
		int den=1<<m;
		cout<<sum*den<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;cin>>s;
   int count=0;
   for(int i=0;i<s.length();i++)
   { if(s[i]=='7')
     count++;

   }
   if(count==0)
    cout<<"No";
   else
    cout<<"Yes";
return 0;
}


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

int main(){
   int n;
   cin >> n;
   vector<string> s(n);
   for(int i = 0; i < n; i++){
      cin >> s[i];
   }
   int a = 0;
   int b = 0;
   int c = 0;
   int d = 0;
   for(int i = 0; i < n; i++){
      if(s[i] == "AC") a++;
      else if(s[i] == "WA") b++;
      else if(s[i] == "TLE") c++;
      else if(s[i] == "RE") d++;
   }

   cout << "AC x " << a << endl;
   cout << "WA x " << b << endl;
   cout << "TLE x " << c << endl;
   cout << "RE x " << d << endl;
   return 0;
}

Measured memory_bytes: 6424
#include <cstdio>
int main(){
	int n;
	scanf("%d", &n);
	int a[n], b[n], c[n - 1], sum = 0;
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < n; i++){
		scanf("%d", &b[i]);
		sum += b[i];
	}
	for (int i = 0; i < n - 1; i++) scanf("%d", &c[i]);
	for (int i = 1; i < n; i++){
		if (a[i] == a[i - 1] + 1) sum += c[a[i] - 2];
	}
	printf("%d", sum);
}

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

// int dp(vector<int>& h, vector<int>& mem, int n) {

//     if(n == 0 || n == 1) {
//         mem[n] = abs(h[n] - h[0]);
//         return mem[n];
//     }
//     int x = mem[n-1] > -1 ? mem[n-1] : dp(h, mem, n-1);
//     int y = mem[n-2] > -1 ? mem[n-2] : dp(h, mem, n-2);
//     mem[n] = min(x + abs(h[n]-h[n-1]), y + abs(h[n]-h[n-2]));
//     return mem[n];

// }

int main() {
    int n;
    cin >> n;
    vector<int> height(n, 0);
    vector<int> mem(n, -1);
    for(int i = 0; i < n; i++) {
        cin >> height[i];
    }
    mem[0] = 0;
    mem[1] = abs(height[1] - height[0]);
    for(int i = 2; i < n; i++) {
        mem[i] = min(mem[i-1] + abs(height[i] - height[i-1]), mem[i-2] + abs(height[i] - height[i-2]));
    }
    cout << mem[n-1];
    return 0;
} 

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

S=input()
c=0
for i in range(len(S)):
    if i%2==0: #奇数、Lが踏みづらい
        if S[i]=="L":
            c+=1
    else: #偶数、Rが踏みづらい
        if S[i]=="R":
            c+=1
if c>0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 2940
import java.util.*;	
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m= sc.nextInt();
		int[] x = new int[n];int[] y = new int[n];
		int[] mx = new int[m];int[] my = new int[m];
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		for(int i = 0;i < m;i++) {
			mx[i] = sc.nextInt();
			my[i] = sc.nextInt();
		}
		int max, a, ans;
		for(int i = 0;i < n;i++) {
			max = Math.abs(x[i]-mx[0])+Math.abs(y[i]-my[0]);
			ans = 1;
			for(int k = 1;k < m;k++) {
				a = Math.abs(x[i]-mx[k])+Math.abs(y[i]-my[k]);
				if(max > a) {
					max = a;
					ans = k+1;
				}
			}
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAX = 100000;

int main(){
    string s;
    cin >> s;
    if(s[s.size()-1] == '3'){
        cout << "bon" << endl;
        return 0;
    }
    else if(s[s.size()-1] == '0' || s[s.size()-1] == '1' || s[s.size()-1] == '6' || s[s.size()-1] == '8'){
        cout << "pon" << endl;
        return 0;
    }
    else{
        cout << "hon" << endl;
        return 0;        
    }

    return 0;
}

Measured memory_bytes: 3624
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();

    let (n, k) = (line[0], line[1]);
    let mut hopes: Vec<(usize, usize)> = vec![];
    for _ in 0..n{
        let mut line = read_as_string();
        let color = line.pop().unwrap();
        let line = line.trim().split_whitespace().map(|c| usize::from_str(c).unwrap())
            .collect::<Vec<usize>>();
        let (x, mut y) = (line[0], line[1]);

        if color == 'W'{
            y += k;
        }

        hopes.push(((x%(2*k))+k+1, (y%(2*k))+k+1));
    }

    let mut acc_map = vec![vec![0;4*k+1];4*k+1];

    for &hope in &hopes{
        acc_map[hope.1][hope.0] += 1;
    }

    //accumulate
    for i in k+1..4*k+1{
        for j in k+1..4*k+1{
            acc_map[i][j] += acc_map[i-1][j] + acc_map[i][j-1] - acc_map[i-1][j-1];
        }
    }

    /*
    for row in acc_map.iter().rev(){
        println!("{:?}", row);
    }
    */
    let mut ans = 0;

    for i in k+1..2*k+1{
        for j in k+1..2*k+1{
            let mut cur_ans = 0;
            //println!("i = {}, j = {}", i, j);
            let ru_list = vec![
                (j+k-1,   i+k-1),
                (j+2*k-1, i-1),
                (j+2*k-1, i+2*k-1),
                (j-1,     i+2*k-1),
                (j-1,     i-1)
            ];
            //println!("{:?}", ru_list);
            for ru in ru_list{
                cur_ans += acc_map[ru.0][ru.1] + acc_map[ru.0-k][ru.1-k] - acc_map[ru.0-k][ru.1] - acc_map[ru.0][ru.1-k]
            }
            //println!("n = {}, cur_ans = {}, ans = {}", n, cur_ans, ans);
            ans = cmp::max(cmp::max(n- cur_ans, cur_ans), ans);
            //println!("n = {}, cur_ans = {}, ans = {} DONE", n, cur_ans, ans);
            /*
            if cur_ans > ans{
                ans = cur_ans;
            }
            */
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 153852
#include <cstdio>
using namespace std;
int dx[] = { 1 , -1 , 0 ,  1 };
int dy[] = { 0 ,  1 , 1 , -1 };

int main(){
	int n;
	for(int i=1 ; scanf("%d", &n ) , n ; i++ ){
		int f[11][11] ;
		
		for(int x=0, y=0, dir=0, j=0 ; j<n*n ; j++ ){
			f[y][x] = j+1;
			x += dx[ dir ];
			y += dy[ dir ];
			if( dir == 0 && y == n-1 ){
				dir = 3;
			}else if( dir == 0 && y == 0 ){
				dir = 1;
			}else if( dir == 1 && y == n-1 ){
				dir = 0;
			}else if( dir == 1 && x == 0 ){
				dir = 2;
			}else if( dir == 2 && x == n-1 ){
				dir = 1;
			}else if( dir == 2 && x == 0 ){
				dir = 3;
			}else if( dir == 3 && x == n-1 ){
				dir = 2;
			}else if( dir == 3 && y == 0 ){
				dir = 0;
			}
		}
		printf("Case %d:\n", i );
		for(int y=0 ; y<n ; y++ ){
			for(int x=0 ; x<n ; x++ ){
				printf("%3d", f[y][x] );
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 0
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

using ull = unsigned long long;

int T;
ull N, A, B, C, D;

unordered_map<ull, ull> dp;
ull solve(ull n){
    if(n == 0) return 0;
    if(dp.count(n)) return dp[n];
    ull ret = LLONG_MAX;
    if(n <= 18'000'000'000LL) ret = min(ret, n*D);
    if(n >= 2) ret = min(ret, solve(n/2) + n%2*D + A);
    if(n >= 3) ret = min(ret, solve(n/2+1) + (2-n%2)*D + A);
    if(n >= 3) ret = min(ret, solve(n/3) + n%3*D + B);
    if(n >= 2) ret = min(ret, solve(n/3+1) + (3-n%3)*D + B);
    if(n >= 5) ret = min(ret, solve(n/5) + n%5*D + C);
    if(n >= 2) ret = min(ret, solve(n/5+1) + (5-n%5)*D + C);
    return dp[n] = ret;
}

signed main(){
    cin >> T;
    while(T--){
        dp.clear();
        cin >> N >> A >> B >> C >> D;
        cout << solve(N) << endl;
    }
}

Measured memory_bytes: 4192
#include<iostream>
using namespace std;
#define Max 500000
#define Half 250003
#define terminal 999999999999
typedef long long llong;
llong a[Max];
llong left_a [Half];
llong right_a [Half];
llong cnt=0;
int mergelr(llong a[],int left,int mid,int right){
    int n_left=0,n_right=0,pre_left=0,pre_right=0;
    for(int i=left;i<mid;i++){
        left_a[n_left++]=a[i];
    }
    left_a[n_left]=terminal;
    for(int i=mid;i<right;i++){
        right_a[n_right++]=a[i];
    }
    right_a[n_right]=terminal;
    for(int i=left;i<right;i++){
        cnt++;
        if(left_a[pre_left]<=right_a[pre_right]){
            a[i]=left_a[pre_left++];
        }
        else
            a[i]=right_a[pre_right++];
    }
    return 0;
}
int MergeSort(llong a[],int left,int right){
    int mid=(left+right)/2;
    if((right-left)<=1)
        return 1;
    MergeSort(a,left,mid);
    MergeSort(a,mid,right);
    mergelr(a,left,mid,right);
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    MergeSort(a,0,n);
    for(int i=0;i<n-1;i++)
        cout<<a[i]<<" ";
    cout<<a[n-1];
    cout<<endl;
    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 10824
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s1[100100],s2[100100];

int main(){
	int cnt=0;
	cin>>s1;
	int len=strlen(s1);
	for(int i=len-1;i>=0;i--){
		s2[cnt]=s1[i];
		if(s2[cnt]=='q')
			s2[cnt]='p';
		else if(s2[cnt]=='p')
			s2[cnt]='q';
		else if(s2[cnt]=='b')
			s2[cnt]='d';
		else if(s2[cnt]=='d')
			s2[cnt]='b';
		cnt++;
	}
	for(int i=0;i<len;i++){
		if(s1[i]!=s2[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
} 

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

using namespace std;

int main(void)
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a == b && a != c){
		printf("Yes\n");
	}
	else if(a == c && a != b){
		printf("Yes\n");
	}
	else if(b == c && a != b){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


/**
 * AIZU ONLINE JUDGE
 * 3127 Gag
 *  2020/5/1
 */
public class Main {


    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();

        long sum = 0;
        for(int i = 0; i < N; i++) {
            int v = sc.nextInt();
            sum += v - i - 1;
        }
        System.out.printf("%d\n", sum);

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();

        instance.systemin.close();
    }


}




Measured memory_bytes: 69848
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  int N=T.size();
  int M=S.size();
  for(int i=0;i<N;i++){
    cout<<S.at(i)<<T.at(i);
  }
  if(N!=M){
    cout<<S.at(M-1)<<endl;
  }
  else{
    cout<<""<<endl;
  }
}
    

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

int main(){
    int n;
    cin >> n;
    int min_ = 1e9;
    int max_ = 1 - min_;
    for (int i = 0; i < n; i++) {
        int R;
        cin >> R;
        if (i > 0) max_ = max(R - min_, max_);
        min_ = min(R, min_);
    }
    cout << max_ << endl;
    return 0;
}

Measured memory_bytes: 3072
import itertools


def distance(route_index: tuple, points: list):
	sum_distance = 0
	for i in range(len(route_index) - 1):
		p1_x = points[route_index[i]][0]
		p1_y = points[route_index[i]][1]

		p2_x = points[route_index[i + 1]][0]
		p2_y = points[route_index[i + 1]][1]

		X = p2_x - p1_x
		Y = p2_y - p1_y

		sum_distance += (X ** 2 + Y ** 2) ** (1 / 2)
	return sum_distance


points = []
N = int(input())
for i in range(N):
	point = input()
	points.append((int(point.split(" ")[0]), int(point.split(" ")[1])))

route_index_list = list(itertools.permutations(range(N)))

sum_distance = 0
for route_index in route_index_list:
	sum_distance += distance(route_index, points)

print(sum_distance / len(route_index_list))


Measured memory_bytes: 8180
#include <stdio.h>

int main(void){

  char a,b;
  scanf("%c %c", &a, &b);
  int answer = 1;
  if (a == 'D') {
    answer *= -1;
  }
  if (b == 'D') {
    answer *= -1;
  }
  if (answer == 1) {
    printf("H\n");
  } else {
    printf("D\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin>>a>>b>>c;
    
    if(a > b) swap (a, b);
    if(b > c) swap (b,c);
    if(a > b) swap (a, b);
    cout<<a<<" "<<b<<" "<<c<<endl;

}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    string s;
    cin >> s;
    int N = s.length();

    if(N == 1){
        cout << "0" << endl;
        return 0;
    }

    vector<int > t_s(N, 0);
    vector<int > p1(N, 0);
    vector<int > p2(N, 0);

    for(int i = 1; i <= N; i++){
        if(s.substr(i-1,1) == "0"){
            t_s[i-1] = 0;
        }else{
            t_s[i-1] = 1;
        }  

        if(i % 2 == 0){
            p1[i-1] = 1;
            p2[i-1] = 0;
        }else{
            p1[i-1] = 0;
            p2[i-1] = 1;            
        }  
    }

    int ans1 = 0;
    int ans2 = 0;
    for(int i = 0; i < N; i++){
        if(t_s[i] == 0 && p1[i] == 1){
            ans1++;
        }
        if(t_s[i] == 1 && p1[i] == 0){
            ans1++;
        }
        if(t_s[i] == 0 && p2[i] == 1){
            ans2++;
        }
        if(t_s[i] == 1 && p2[i] == 0){
            ans2++;
        }
    }
    
    if(ans1 > ans2){
        cout << ans2 << endl;
    }else{
        cout << ans1 << endl;
    }

} 

Measured memory_bytes: 1664
def oturi(now, kingaku):
    coin = now // kingaku
    if coin:
        now -= coin * kingaku
    return now, coin

while True:
    n = int(input())
    if n == 0:
        break
    now = 1000 - n
    coin = 0
    now, c = oturi(now, 500)
    coin += c
    now, c = oturi(now, 100)
    coin += c
    now, c = oturi(now, 50)
    coin += c
    now, c = oturi(now, 10)
    coin += c
    now, c = oturi(now, 5)
    coin += c
    now, c = oturi(now, 1)
    coin += c
    print(coin)


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

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  fenwick_tree<int64_t> bit(n);
  for (int i = 0; i < n; i++) {
    bit.add(i, a.at(i));
  }
  for (int i = 0; i < q; i++) {
    int type;
    cin >> type;
    if (type == 0) {
      int p, x;
      cin >> p >> x;
      bit.add(p, x);
    } else {
      int l, r;
      cin >> l >> r;
      cout << bit.sum(l, r) << endl;
    }
  }
}


Measured memory_bytes: 10176
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
    double x1,x2,y1,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
double f(int q, double x){
    return (x * x * x - q) / (3 * x * x);
}

double root(int q){
    double x = q / 2.0;    
    while (fabs(x * x * x - q) >= 0.00001 * q) {
        x = x - f(q, x);
    }
    return x;
}

int main(void){
    int q;
    while(scanf("%d\n", &q) != EOF) {
        if(q == -1) break;
        printf("%.6f\n", root(q));
    }
    return 0;
}



Measured memory_bytes: 1920
import java.util.*;

public class Main {
	static class BIT {
		int L;
		long[] min;
		public BIT(int N) {
			L = 1;
			while(L<N) {
				L<<=1;
			}
			min = new long[L*2-1];
			Arrays.fill(min, Long.MAX_VALUE);
		}
		public void set(int x, long v) {
			int p = L-1+x;
			min[p] = v;
			while(p>0) {
				p=(p-1)/2;
				min[p] = Math.min(min[p*2+1], min[p*2+2]);
			}
		}
		public long getMin(int a, int b) {
			return getMin(a, b, 0, L, 0);
		}
		
		public long getMin(int a, int b, int l, int r, int idx) {
			if(r<=a || b<=l)
				return Long.MAX_VALUE;
			else if(a<=l && r<=b)
				return min[idx];
			else
				return Math.min(getMin(a, b, l,(l+r)/2,idx*2+1), getMin(a, b, (l+r)/2,r,idx*2+2));
		}
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int E = sc.nextInt();
		int T = sc.nextInt();
		long[] x = new long[N+1];
		for(int i=0; i<N; i++)
			x[i+1] = sc.nextInt();
		
		long[] dp = new long[N+1];
		BIT bit = new BIT(N+1);
		bit.set(0, E+(E-x[1])*2);
		int j=0;
		for(int i=1; i<=N; i++) {
			while((x[i]-x[j+1])*2>T)
				j++;
			
			long min = bit.getMin(0, j);
			dp[i] = Math.min(min-(E-x[i])*3, dp[j]+x[i]-x[j]+T);
			if(i<N)
				bit.set(i, dp[i]+E-x[i]+(E-x[i+1])*2);
		}
		
		System.out.println(dp[N]+E-x[N]);
		sc.close();
	}
}


Measured memory_bytes: 33892
#include <bits/stdc++.h>
#define dummy1 -2000000000000000000
#define dummy2 -4000000000000000001
#define dummy3 -3000000000000000002
using namespace std;

long long n, m, cnt = 0, ans;
vector<pair<long long, long long>> edge[1005];
long long memo[1005] = {0};
long long sum[1005] = {0};
bool used[1005] = {0};

void prians(bool answer) {
  if(answer)
    cout << "inf" << endl;
  else
    cout << ans << endl;
}
bool solve();
long long recall(long long now, long long nsum);
bool ch(long long x);

int main() {
  cin >> n >> m;
  for(int i = 0; i < n; ++i) sum[i] = memo[i] = dummy1;
  for(int i = 0; i < m; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    edge[a].push_back(make_pair(b, c));
  }
  prians(solve());
  return 0;
}

bool solve() {
  ans = recall(0, 0);
  return (ans == dummy2);
}

long long recall(long long now, long long nsum) {
  if(memo[now] != dummy1) return memo[now];
  if(used[now]) {
    if(nsum > sum[now] && ch(now))
      return memo[now] = dummy2;
    return dummy3;
  }
  sum[now] = nsum;
  used[now] = 1;
  long long nans = dummy3;
  if(edge[now].size() == 0) {
    if(now == n - 1) return memo[now] = 0;
    return memo[now] = dummy3;
  }
  for(long long i = 0; i < edge[now].size(); ++i) {
    pair<long long, long long> nextp = edge[now][i];
    long long data =
        recall(nextp.first, nsum + nextp.second);
    if(data == dummy2) {
      nans = dummy2;
      break;
    }
    if(data == dummy3) continue;
    nans = max(nans, data + nextp.second);
  }
  if(now == n - 1 && nans != dummy2) return memo[now] = 0;
  return memo[now] = nans;
}

bool ch(long long x) {
  bool isused[1005] = {0};
  queue<long long> qu;
  qu.push(x);
  used[x] = 1;
  while(qu.size() > 0) {
    long long now = qu.front();
    qu.pop();
    for(long long i = 0; i < edge[now].size(); ++i) {
      long long nextl = edge[now][i].first;
      if(nextl == n - 1)
        return 1;
      else if(!isused[nextl]) {
        isused[nextl] = 1;
        qu.push(nextl);
      }
    }
  }
  for(int i = 0; i < n; ++i)
    if(isused[i]) memo[i] = dummy3;
  return 0;
}

Measured memory_bytes: 384
#include<map>
#include<set>
#include<ctime>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
#define IT iterator
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

//math
ll mult(ll a,ll b,ll p) {
	a=(a%p+p)%p; b=(b%p+p)%p;
	ll c=(ld)a*b/p;
	return a*b-c*p;
}
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}
ll Power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=mult(c,a,mod);
		b /= 2; a=mult(a,a,mod);
	}
	return c;
}

char s[N],ch[3]="PD";
int f[N][2],p[N][2];

void dfs(int x,int y) {
	if(!x) return ;
	dfs(x-1,p[x][y]);
	putchar(ch[y]);
}

int main() {
	scanf("%s",s+1); int n=strlen(s+1);
	for(int i=1;i<=n;i++) {
		int c=s[i];
		f[i][0]=f[i][1]=-555;
		if(c=='D'||c=='?') {
			f[i][1]=0;
			if(f[i-1][0]+2>=f[i][1]) f[i][1]=f[i-1][0]+2,p[i][1]=0;
			if(f[i-1][1]+1>=f[i][1]) f[i][1]=f[i-1][1]+1,p[i][1]=1;
		}
		if(c=='P'||c=='?') {
			f[i][0]=0;
			for(int j=0;j<2;j++)
				if(f[i-1][j]>=f[i][0])
					f[i][0]=f[i-1][j],p[i][0]=j;
		}
	}
	if(f[n][0]>=f[n][1]) dfs(n,0);
	else dfs(n,1);
	return 0;
}




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

#define mod 1000000007
typedef long long ll;

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

int main()
{
    calcFacAndInv(1000000);
    ll n , k;
    cin >> n >> k;
    for ( int i=1; i<=k ; i++){
        if(n-k <i-1) {
            cout << 0 <<endl;
            continue;
        }
    ll x= ncr(n-k+1, i);
    ll ans = ncr(k-1, i-1);
    ans = (ans*x)% mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 15872
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

using namespace std;


int main() {
    vector<string> a;
    int n, l;
    cin >> n >> l;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        a.push_back(s);
    }
    sort(a.begin(), a.end());
    string s = "";
    for (int i = 0; i < n; ++i)
        s += a[i];
    cout << s;
    return 0;
}


Measured memory_bytes: 256
/*
▄▄▄▄▄▄   ▄▄▄▄                      ▄▄▄▄▄                               
██▀▀▀▀██ ▀▀██                      ██▀▀▀██                             
██    ██   ██    ██    ██  ▄████▄  ██    ██  ▄████▄  ██▄████▄  ▄████▄  
███████    ██    ██    ██ ██▄▄▄▄██ ██    ██ ██▀  ▀██ ██▀   ██ ██▄▄▄▄██ 
██    ██   ██    ██    ██ ██▀▀▀▀▀▀ ██    ██ ██    ██ ██    ██ ██▀▀▀▀▀▀ 
██▄▄▄▄██   ██▄▄▄ ██▄▄▄███ ▀██▄▄▄▄█ ██▄▄▄██  ▀██▄▄██▀ ██    ██ ▀██▄▄▄▄█ 
▀▀▀▀▀▀▀     ▀▀▀▀  ▀▀▀▀ ▀▀   ▀▀▀▀▀  ▀▀▀▀▀      ▀▀▀▀   ▀▀    ▀▀   ▀▀▀▀▀  
*/
# include <cstdio>
# include <iostream>
# include <algorithm>

using namespace std ; 

typedef long long lint ; 
typedef long double ntrl ; 

# define MAXN 100010
# define MAXM 100010
# define INF 0x3f3f3f3f

///global variable///
int n ; 
/////*/

///basic function///
inline lint min ( lint x , lint y ) { return x < y ? x : y ; }
inline lint max ( lint x , lint y ) { return x > y ? x : y ; }
inline void swap ( lint &x , lint &y ) { x ^= y , y ^= x , x ^= y ; }
inline bool isltr ( char x ) { return ( 'A' <= x && x <= 'Z' ) || ( 'a' <= x && x <= 'z' ) ; }
inline bool isnum ( char x ) { return ( '0' <= x && x <= '9') ; }
/////*/

///fast read///
inline lint readlint ( )
{
	lint val = 0 , sign = 1 ; char tmp = getchar ( ) ; 
	while ( ! isnum ( tmp ) ) { if ( tmp == '-' ) { sign = - sign ; } tmp = getchar ( ) ;  } 
	while ( isnum ( tmp ) ) { val = ( val << 1 ) + ( val << 3 ) + tmp - 48 ; tmp = getchar ( ) ; } 
	return val * sign ; 
}
inline char readlter ( ) 
{
	char tmp = getchar ( ) ; 
	while ( ! isltr ( tmp ) )
		tmp = getchar ( ) ; 
	return tmp ; 
}
/////*/

///problem///
struct rbt
{
	int x ; 
	int r ; 
} a [ MAXN ] ; 
inline bool cmp ( rbt x , rbt y )
{
	return x . r + x . x < y . r + y . x  ; 
}
/////*/

int main ( )
{
	n = readlint ( ) ; 
	for ( int i = 1 ; i <= n ; i ++ )
	{
		a [ i ] . x = readlint ( ) ; 
		a [ i ] . r = readlint ( ) ; 
	}

	sort ( a + 1 , a + n + 1 , cmp ) ; 

	int now = 0 , 
		end = a [ n ] . x + a [ n ] . r ; 
	int top = 1 ; 
	int joined = 0 ; 
	
	while ( now < end )
	{
		if ( top > n )
		{
			break ; 
		}
		if ( now <= ( a [ top ] . x - a [ top ] . r < 0 ? 0 : a [ top ] . x - a [ top ] . r ) )
		{
			now = a [ top ] . x + a [ top ] . r ; 
			++ joined ; 
		}
		else
		{
			++ top ; 
		}
	}

	printf ( "%d" , joined ) ; 

	printf ( "\n" ) ; 
	return 0 ; 
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION

//BELOW
void solve(void)
{
  int A,B,C;
  cin>>A>>B>>C;
  int MAX = max(A,max(B,C));
  int ANS = 0;
  while(A +1 < MAX)
  {
    A += 2;
    ANS++;
  }

    while(B +1 < MAX)
  {
    B += 2;
    ANS++;
  }

    while(C +1 < MAX)
  {
    C += 2;
    ANS++;
  }
  // DEBUG(A,B,C);

  if(3*MAX - A -B-C == 0)
  {
    cout<<ANS<<endl;
    return;
  }
  else if (3*MAX - A -B-C == 2)
  {
    cout<<ANS+1<<endl;
    return;
  }
  else
  {
    cout<<ANS+2<<endl;
    return;
  }
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll n,x,ans=0;
    cin>>n;
    rep(i,n){
        cin>>x;
        for(;x%2==0;x/=2,ans++);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 300
#define X 998244353
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
using namespace std;
int n,m,a[N+5],f[N+5][N+5][N+5];char s[N+5];
int main()
{
	RI i,j,k,cnt=1;for(scanf("%s",s+1),n=strlen(s+1),i=1;i<=n;++i) s[i]^'0'?++a[cnt]:++cnt;//转化
	RI p;scanf("%d",&m),m=min(n,m),f[0][0][0]=1;//初始化
	for(i=0;i^cnt;++i) for(j=0;j<=m;++j) for(k=0;k<=m;++k) if(f[i][j][k])//枚举状态，如果状态能达到再去刷表
	{
		Inc(f[i+1][j][k],f[i][j][k]);//不操作
		for(p=m-j;p;--p) Inc(f[i+1][j+p][k+p],f[i][j][k]);//加上一个数
		for(p=min(a[i+1],k);p;--p) Inc(f[i+1][j][k-p],f[i][j][k]);//减去一个数
	}
	RI t=0;for(i=0;i<=m;++i) Inc(t,f[cnt][i][0]);return printf("%d\n",t),0;//输出答案
}


Measured memory_bytes: 58252
#include <stdio.h>

int main(void) {
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(0<=x-r && 0<=y-r && x+r<= W && y+r<= H) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
return 0;
}

Measured memory_bytes: 584