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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

void run() {
    int n;
    string s[2];
    cin >> n;
    cin >> s[0] >> s[1];
    
    ll ans = 1;
    const int BEGIN = 0;
    const int VERT = 1;
    const int HOR = 2;
    int last = BEGIN;
    int i = 0;
    while (i < n) {
        if (s[0][i] == s[1][i]) {
            if (last == BEGIN) ans = mult(ans, 3);
            else if (last == VERT) ans = mult(ans, 2);
            else ans = mult(ans, 1);
            last = VERT;
            i++;
        } else {
            if (last == BEGIN) ans = mult(ans, 6);
            else if (last == VERT) ans = mult(ans, 2);
            else ans = mult(ans, 3);
            last = HOR;
            i += 2;
        }
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    
    int r, d, x;
    cin >> r >> d >> x;
    REP(i , 10){
        x = r*x -d;
        cout << x << endl;
    }
}


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

int main() {
  string s;
  cin>>s;
  if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        if (num%2 == 1) {
            System.out.println(num/2+1);
        } else {
            System.out.println(num/2);
        }

    }
}


Measured memory_bytes: 20948
#line 1 "agc043_b.cpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
using P = std::pair<int, int>;
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vi a(n);
  string s;
  cin >> s;
  REP(i, n) { a[i] = s[i] - '1'; }

  int one = 0;
  REP(i, n) {
    if ((n - 1) == (i | (n - 1 - i))) {
      one = (one ^ (a[i] % 2));
    }
  }
  if (one == 1) {
    cout << 1 << endl;
    return 0;
  }

  REP(i, n) {
    if (a[i] == 1) {
      cout << 0 << endl;
      return 0;
    }
  }

  int two = 0;
  REP(i, n) {
    a[i] /= 2;
    if ((n - 1) == (i | (n - 1 - i))) {
      two = (two ^ (a[i] % 2));
    }
  }

  if (two == 1) {
    cout << 2 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 5252
import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

def main():
    N,K = list(map(int,input().split()))
    A = list(map(int,input().split()))
    #A = [0]*1000
    #print(*A)
    #print(len(A))
    for k in range(min(K,200)):
        buf = [0]*N
        for i in range(N):
            if i-A[i]>=0:
                buf[i-A[i]] += 1
            else:
                buf[0] += 1
            if i+A[i]+1<N:
                buf[i+A[i]+1] -= 1
            #print(buf)

        #print(buf)

        b = 0
        B = []
        for i in range(N):
            b+=buf[i]
            B.append(b)

        A = B

    print(*A)

if __name__ == '__main__':
    main()




Measured memory_bytes: 188448
use std::io::{ stdin, stdout, BufRead, Write };

const SP   : u8 = b' ';
const LF   : u8 = b'\n';
const ZERO : u8 = b'0';

#[inline(always)]
fn uitoa(mut n: usize, buf: &mut Vec<u8>) {
  buf.clear();
  if n == 0 {
    buf.push(ZERO);
    return;
  }

  while n > 0 {
    buf.push((n % 10) as u8 + ZERO);
    n /= 10;
  }

  buf.reverse();
}

#[inline(always)]
fn atoui(s: &[u8]) -> usize {
  let mut n = 0;
  for b in &s[..] { n = n * 10 + (b - ZERO) as usize; }
  n
}

#[inline(always)]
fn vec_write_with(buf: &mut Vec<u8>, s: &mut Vec<u8>, b: u8) {
  s.push(b);
  buf.write(s).unwrap();
}

fn main() {
  let stdin = stdin();
  let mut stdin = stdin.lock();

  let mut buf = Vec::with_capacity(500 * 2);
  let len = stdin.read_until(SP, &mut buf).unwrap();
  buf.truncate(len - 1);
  let h = atoui(&buf);

  buf.clear();
  let len = stdin.read_until(LF, &mut buf).unwrap();
  buf.truncate(len - 1);
  let w = atoui(&buf);

  let mut num = Vec::with_capacity(3);
  let mut ans = Vec::new();
  let mut n   = 0;

  let mut odd = 0;
  let mut x   = 0;
  let mut y   = 0;

  for i in 0..h {
    buf.clear();
    stdin.read_until(LF, &mut buf).unwrap();

    if i % 2 == 0 {
      for j in 0..w {
        if odd != 0 {
          uitoa(y + 1, &mut num);
          vec_write_with(&mut ans, &mut num, SP);

          uitoa(x + 1, &mut num);
          vec_write_with(&mut ans, &mut num, SP);

          uitoa(i + 1, &mut num);
          vec_write_with(&mut ans, &mut num, SP);

          uitoa(j + 1, &mut num);
          vec_write_with(&mut ans, &mut num, LF);

          n += 1;
        }
        odd ^= buf[j * 2] & 1;
        y = i;
        x = j;
      }
    } else {
      for mut j in 0..w {
        j = w - 1 - j;

        if odd != 0 {
          uitoa(y + 1, &mut num);
          vec_write_with(&mut ans, &mut num, SP);

          uitoa(x + 1, &mut num);
          vec_write_with(&mut ans, &mut num, SP);

          uitoa(i + 1, &mut num);
          vec_write_with(&mut ans, &mut num, SP);

          uitoa(j + 1, &mut num);
          vec_write_with(&mut ans, &mut num, LF);

          n += 1;
        }
        odd ^= buf[j * 2] & 1;
        y = i;
        x = j;
      }
    }
  }

  let stdout = stdout();
  let mut stdout = stdout.lock();

  uitoa(n, &mut buf);
  buf.push(LF);
  stdout.write(&buf).unwrap();

  stdout.write(&ans).unwrap();
  stdout.flush().unwrap();
}


Measured memory_bytes: 8188
import collections as c
ip = lambda : map(int, input().split())
# ##############
N,K,Q = ip()
am = {}
for i in range(Q):
    a = int(input())
    am[a] = am.get(a,0) + 1
for i in range(1,1+N):
    if K - Q + am.get(i,0) > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9436
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll A[3*Nmax];

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

	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > former;
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > latter;
	vector<bool> in_latter(3*N);

	ll former_sum = 0;
	ll latter_sum = 0;
	for(int i=0; i<N; i++){
		former.push(make_pair(A[i], i));
		former_sum += A[i];
	}
	for(int i=N; i<3*N; i++){
		latter.push(make_pair(A[i], i));
	}
	for(int i=0; i<N; i++){
		ll a=latter.top().first;
		int n=latter.top().second;
		latter_sum += a;
		in_latter[n] = true;
		latter.pop();
	}

	ll ans = former_sum - latter_sum;
	for(int i=N; i<2*N; i++){
		former.push(make_pair(A[i], i));
		ll a = former.top().first;
		former.pop();
		former_sum += A[i] - a;

		if(in_latter[i]){
			ll b;
			int n;
			while(!latter.empty()){
				b = latter.top().first;
				n = latter.top().second;
				latter.pop();
				if(n > i) break;
			}
			latter_sum += b - A[i];
			in_latter[n] = true;
		}

		ans = max(ans, former_sum-latter_sum);
	}

	cout << ans << endl;




	return 0;
}


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


int main() {
    long long A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    if(min(A,B) >= C*2){
        cout << max(X,Y)*2*C<< endl;
    }else if(A+B >= C*2){
        if(X>=Y){
            cout << (min(A,C*2)*(X-Y)) + (C*2*Y) << endl;
        }else{
            cout << (min(B,C*2)*(Y-X)) + (C*2*X) << endl;
        }
    }else{
        cout << (A*X)+(B*Y) <<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int begin = sc.nextInt();
		int end = sc.nextInt();

		long cnt = 0;
		for (int i = begin; i <= end; i++) {
			String us = String.valueOf(i);
			String ret = new StringBuffer(us).reverse().toString();

			if (us.equals(ret)) {
				cnt++;
			}
		}

		System.out.println(cnt);
		sc.close();
	}

}


Measured memory_bytes: 38868
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

N,K=map(int, sys.stdin.readline().split())
if K==1:
    print 0
    quit()
A=map(int, sys.stdin.readline().split())
A=map(lambda a: (a-1)%K, A)

S=[0]
for a in A:
    S.append( (S[-1]+a)%K )   #累積和

d=dict()    #要素：要素の数を持つ

ans=0
for i in range(N+1):
    x=S[i]%K
    if i==0:
        d[x]=1
    else:
        if x in d:
            ans+=d[x]   #自分より前に同じ出現した、自分と同じ要素の数を答えに追加
            d[x]+=1
        else:
            d[x]=1      
        if 0<=i-K+1:
            x_head=S[i-K+1]%K  #長さK-1の範囲で配列Sを見るため、１つ進んだら一番先頭の要素を辞書から削除する
            d[x_head]-=1

print ans
        

Measured memory_bytes: 80368
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e5,mod=1e9+7 ;


int main ()
{
    FASTIO;
    vll Pre(100,0);
    for(int i=1;i<100;i++){
       Pre[i] = Pre[i-1] + i;
    }
    ll n ,ans=0;
    cin >> n ;
    ll t=n;
    for(ll i=2;i*i<=t;i++){
        int cnt=0;
        while(n%i==0){
            n /= i;
            cnt++;
        }
        ans += upper_bound(all(Pre),cnt)-Pre.begin() - 1;
    }
    if(n!=1)ans++;
    cout << ans << endl;
    return 0;
}
/**


*/


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  char n = S[0];
  int result = 0;
  rep(i, S.length()) if (S[i]!=n) { n=S[i]; result++; }
  cout << result << endl;
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	if (n / 100 == 1) 
		n = n + 800;
	else if (n / 100 == 9) 
		n = n - 800;
	if ((n % 100)/10 == 1) 
		n = n +80;
	else if ((n %100) / 10 == 9) 
		n = n - 80;
	if (n % 10 == 1) 
		n = n + 8;
	else if (n % 10 == 9) 
		n = n - 8;

	cout << n << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

const bool NOT_FREE = true;
const bool FREE = false;

const int N = 8;
int k;
int board[8][8];
int row[8];
bool col[8];
bool dpos[15];
bool dneg[15];

inline void init_board() {
  for (int i = 0; i < 8; i++) {
    row[i] = -1;
    col[i] = FREE;
  }
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++)
      board[i][j] = FREE;
  for (int i = 0; i < 15; i++) {
    dpos[i] = dneg[i] = FREE;
  }
}

void printBoard() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (board[i][j] == NOT_FREE) {
        cout << 'Q';
      } else {
        cout << '.';
      }
    }
    cout << endl;
  }
}

void putQueen(int i) {
  if (i == N) {
    printBoard();
    return;
  }
  if (row[i] == -1) {
    for (int j = 0; j < N; j++) {
      if (col[j] == NOT_FREE || dpos[i + j] == NOT_FREE ||
          dneg[i - j + N - 1] == NOT_FREE) {
        continue;
      }
      row[i] = j;
      col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
      board[i][j] = NOT_FREE;
      putQueen(i + 1);
      row[i] = -1;
      board[i][j] = FREE;
      col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
  } else {
    putQueen(i + 1);
  }
}

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

  init_board();
  cin >> k;
  for (int i = 0; i < k; i++) {
    int r, c;
    cin >> r >> c;
    row[r] = c;
    col[c] = NOT_FREE;
    dpos[r + c] = NOT_FREE;
    dneg[r - c + N - 1] = NOT_FREE;
    board[r][c] = NOT_FREE;
  }

  putQueen(0);
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>//B - Count ABC 
using namespace std;

int n,c;
string s;

int main()
{
	while(cin>>n>>s)
	{
	  c=0;
	  for(int i=0;i<n;i++)
	   {
		if(s[i]=='A')
		 if(s[i+1]=='B'&&s[i+2]=='C')
		   {
		     c++;
		     i+=2;
		   }
	    }
	   printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 3748
N = input()
H = map(int, input().split())
last_h = float('inf')
ans, cnt = 0, -1
for h in H:
  if last_h >= h:
    cnt += 1
  else:
    if ans < cnt:
      ans = cnt
    cnt = 0
  last_h = h
print(ans if ans > cnt else cnt)

Measured memory_bytes: 11132
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,k;
  cin>>a>>b>>k;
  if(a>=k)
  cout<<a-k<<" "<<b;
  
  else if(k>a && k<=a+b)
  {
  	cout<<0<<" "<<b+a-k;
  }
  else
  cout<<0<<" "<<0;
}


Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const H=input[1].split(' ').map(e=>{
    return e-0;
  });
  var max=Infinity;
  for(var i=N-1;i>=0;i--){
    if(H[i]<=max){
      max=H[i];
    }else if(H[i]>max+1){
      console.log('No');
      return;
    }
  }
  console.log('Yes');

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 39916
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();

			for(int i = 1; i <= 9; i++) {
				for(int j = 1; j <= 9; j++) {
					if(i * j == N) {
						System.out.println("Yes");
						return;
					}
				}
			}
			
			System.out.println("No");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

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

	int b;
	cin >> b;

	if ((a * b % 2) == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

    bool flg = true;
    int cnt = 0;
    while(flg){
        flg = false;
        for(int i=N-1;i>0;i--){
            if(a[i] < a[i-1]){
                swap(a[i], a[i-1]);
                flg = true;
                cnt++;
            }
        }
    }
    

    for(int i=0;i<N-1;i++) cout << a[i] << ' ';
    cout << a[N-1] << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>//stayCalmNeverSettle
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define szof(x) ((int)x.size())
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii; 
int const INF = (int)1e9+1e3;
ll const INFL = (ll)1e18+1e6;

const int N = 1e5+5;
ll w[101],v[101];
ll dp[N][101];
void solve(){
	int n,W;
	cin >> n >> W;
	ll max_v = 0;
	for(int i=1;i<=n;i++){
		cin >> w[i] >> v[i];
		max_v+=v[i];
	}
	for(int i=0;i<=n;i++){
		dp[0][i] = 0;
	}
	for(int i=1;i<=max_v;i++){
		dp[i][0] = INFL;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=max_v;j++){
			dp[j][i] = dp[j][i-1];
			if(v[i]<=j){
				dp[j][i] = min(dp[j][i],dp[j-v[i]][i-1]+w[i]);
			}
		}
	}
	// for(int i=0;i<=max_v;i++){
	// 	for(int j=0;j<=n;j++){
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	// cout << endl;
	// cout << endl;
	for(int j=max_v;j>0;j--){
		for(int i=1;i<=n;i++){
			if(dp[j][i]<=W){
				cout << j << endl;
				return;
			}
		}
	}
}   
    
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

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

int main() {
  string n;
  ll k;
  cin>>n>>k;
  if(n.size()<k){
    cout<<0<<endl;
    return 0;
  }
  ll ans=0;
  for(ll i=1;i<n.size();i++){
    if(i<k) continue;
    else {
      if(k==1) ans+=9;
      else if(k==2) ans+=81*(i-1);
      else ans+=729*(i-1)*(i-2)/2;
    }
  }
  if(k==1) ans+=(n.at(0)-'0');
  if(k==2) {
    ans+=(n.at(0)-'0'-1)*9*(n.size()-1);
    for(int i=1; i<n.size();i++){
      if(n.at(i)=='0') continue;
      else{
        ans+=(n.at(i)-'0');
        ans+=9*(n.size()-1-i);
        break;
      }
    }
  }
  if(k==3){
    ans+=(n.at(0)-'0'-1)*81*(n.size()-1)*(n.size()-2)/2;
    for(int i=1; i<n.size()-1;i++){
      if(n.at(i)=='0') continue;
      else{
        ans+=(n.at(i)-'0'-1)*9*(n.size()-i-1)+81*(n.size()-i-1)*(n.size()-i-2)/2;
        for(int j=i+1;j<n.size();j++){
          if(n.at(j)=='0') continue;
          else {
            ans+=(n.at(j)-'0');
            ans+=9*(n.size()-1-j);
            break;
          }
        }
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int n,ar[100];
    cin>>n;
    for(int i=0;i<n;i++) cin>>ar[i];
    sort(ar,ar+n);
    int ans=1e9;
    for(int i=ar[0];i<=ar[n-1];i++)
    {
        int tmp=0;
        for(int j=0;j<n;j++)
            tmp+=(ar[j]-i)*(ar[j]-i);
        ans=min(tmp,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  int ans = -A[0];
  for (int i = 1; i < N - 1; i++)
  {
    if (A[i] < 0) ans -= A[i];
    else ans += A[i];
  }
  ans += A[N - 1];
  cout << ans << endl;

  int now = A[0];
  for (int i = N - 2; i >= 1; i--)
  {
    if (A[i] < 0) break;
    cout << now << " " << A[i] << endl;
    now = now - A[i];
  }

  cout << A[N - 1] << " " << now << endl;
  now = A[N - 1] - now;

  for (int i = 1; i < N - 1; i++)
  {
    if (A[i] >= 0) break;
    cout << now << " " << A[i] << endl;
    now = now - A[i];
  }
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n)
	{
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	double ans = v[0];
	for(int i = 1; i < n; i++)
	{
		ans = (ans+v[i])/2;
	}
	printf("%.10f\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(){
	while(true){
		int t;
		int one_num = 0;
		int ans = 0;
		vector< int > cards;
		
		scanf("%d", &t);
		if(t==0)
			break;
		cards.push_back( t );
		while( true ){
			char c;
			scanf("%c", &c);
			if( c == '\n' )
				break;
			else{
				scanf("%d", &t);
				cards.push_back( t );
			}
		}
		sort( cards.begin(), cards.end(), greater<int>() );
		for(unsigned int i = 0; i < cards.size(); ++i){
			one_num += cards[i] == 1 ? 1 : 0;
		}
		for(unsigned int i = 0; i < cards.size(); ++i){
			cards[i] = cards[i] > 10 ? 10 : cards[i];
			if( cards[i] == 1 ){
				int tt = one_num * 11;
				while( ans + tt > 21 ){
					tt -= 10;
				}
				if( tt < one_num )
					ans = 22;
				else
					ans = ans + tt;
				break;
			}else{
				ans += cards[i];
			}
		}
		printf("%d\n", ans > 21 ? 0 : ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<queue>
#define For(i,j,k)  for(int i=j;i<=k;++i)
#define Dow(i,j,k)  for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e9
#define pb push_back
#define local freopen("in.in","r",stdin);
#define c(p1,p2)  ((p1-1))*m+(p2)
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read()
{
	int t=0,f=1;char c=gc();
	while(!isdigit(c))  {if(c=='-') f=-1;c=gc();}
	while(isdigit(c))   t=t*10+c-'0',c=gc();
	return t*f;
}
inline void write(ll p1){if(p1<0) {putchar('-');write(-p1);return;}if(p1>=10)    write(p1/10);putchar(p1%10+'0');}
inline void writeln(ll p1){write(p1);puts("");}
inline void write_p(ll p1){write(p1);putchar(' ');}

ll Get(int p1,int p2){return p2>=p1?p2+1:p2;}
ll p1,p2,q;
inline bool check(ll sum)
{
	int mid=sum/2;
	For(i,mid-200,mid+200)
		if ((Get(p1,i)*Get(p2,sum-i+1)>=p1*p2)&&(i>0&&i<=sum))	return 0;
	return 1;
}
int main()
{
	q=read();
	For(szbakking,1,q)
	{
		p1=read();
		p2=read();
		ll l=0,r=2e9;
		while (l<r)
		{
			int m=(l+r+1)>>1;
			if (check(m))
				l=m;else r=m-1;
		}
		writeln(l);
	}
}

Measured memory_bytes: 256
import math
from bisect import bisect_left, bisect_right

Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

is_prime = [False for _ in range(100001)]
is_prime[3] = True
primes = [3]
for n in range(5, 100001, 2):
    prime = True
    i = 2
    while i < int(math.sqrt(n)) + 1:
        if n % i == 0:
            prime = False
            break
        i += 1
    if prime:
        primes.append(n)
        is_prime[n] = True

like = []
for p in primes:
    if p == 3:
        like.append(p)
        continue
    q = (p+1)//2
    if is_prime[q]:
        like.append(p)

for l, r in LR:
    ans = bisect_right(like, r) - bisect_left(like, l)
    print(ans)

Measured memory_bytes: 29420
S = input()
T = input()
if len(T) > len(S):
    print('UNRESTORABLE')
    exit()

cands = []
for i in range(len(S)-len(T)+1):
    for c1,c2 in zip(T,S[i:]):
        if c1 == c2: continue
        if c2 == '?': continue
        break
    else:
        tmp = S[:i] + T + S[i+len(T):]
        cands.append(tmp.replace('?','a'))
if cands:
    print(sorted(cands)[0])
else:
    print('UNRESTORABLE')

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

int main() {
	int n,k,r,s,p;
	string t;
	cin>>n>>k;
	cin>>r>>s>>p;
	cin>>t;
	
	ll point=0;
	for(int i=0;i<k;i++){//k回目までは単純でおｋ
		if(t[i]=='r')point+=p;
		if(t[i]=='s')point+=r;
		if(t[i]=='p')point+=s;
	}
	for(int i=k;i<n;i++){
		if(t[i-k]==t[i]){
			if(t[i]=='r')t.replace(i,1,"x");
			if(t[i]=='s')t.replace(i,1,"x");
			if(t[i]=='p')t.replace(i,1,"x");
			continue;
		}
		if(t[i]=='r')point+=p;
		if(t[i]=='s')point+=r;
		if(t[i]=='p')point+=s;
	}
	/*
	for(int i=2*k;i<n;i++){
		if(t[i-k]==t[i]&&t[i-2*k]!=t[i])continue;
		if(t[i]=='r')point+=p;
		if(t[i]=='s')point+=r;
		if(t[i]=='p')point+=s;
	}
	*/
	
	cout<<point<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(b/10==0)
    b+=10*a;
  else if(b/100==0)
    b+=100*a;
  else
    b+=1000*a;
  a=sqrt(b);
  if(a*a==b)
    puts("Yes");
  else
    puts("No");
  return 0;  
}


Measured memory_bytes: 128
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
string s;
int n,a, b, c, d;
signed main() {
	cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;
	bool f = false;
	int cnt = a;
	while (cnt < c) {
		int memo = cnt;
		if (s[cnt + 1] != '#')cnt++;
		else if (cnt + 2 < s.size() && s[cnt + 2] != '#')cnt += 2;
		if (memo == cnt) {
			puts("No");
			return 0;
		}
	}
	cnt = b;
	while (cnt < d) {
		int memo = cnt;
		if (s[cnt + 1] != '#')cnt++;
		else if (cnt + 2 < s.size() && s[cnt + 2] != '#')cnt += 2;
		if (memo == cnt) {
			puts("No");
			return 0;
		}
	}
	if (d < c) {
		for (int i = b - 1; i < d; i++) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')f = true;
		}
		if (!f) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 640
program abc161b
   implicit none
   integer :: m, n
   integer, allocatable ::  a(:), b(:)
   integer :: i
   real(8) :: m4

   read(*,*) n, m
   allocate(a(n), b(n))
   a(:) = 0
   b(:) = 0
   read(*,*) a(:)

   m4 = 1d0 / (4d0*m) * dble(sum(a))

   do i = 1, n
      if (m4 > a(i)) then
         b(i) = 0
      else
         b(i) = 1
      end if
   end do

   if (sum(b) >= M) then
      print *, "Yes"
   else
      print *, "No"
   end if

end program abc161b


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  string s;
  cin >> s;
  if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

	return 0;
}

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

int main(){
	int a, b, k, i;
	cin>>a>>b>>k;
	if((b-a+1)<2*k){
		for(i=a; i<=b; i++){
			cout<<i<<endl;
		}
	}
	else{
		for(i=0; i<k; i++){
			cout<<a+i<<endl;
		}
		for(i=0; i<k; i++){
			cout<<b-k+1+i<<endl;
		}
	}
	return 0;
}


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

int main(){
  long long x; cin >> x;
  for(long long i = 0; i < 1000; i++){
  for(long long j = -1000; j < 1000; j++){
  
  	long long a = i*i*i*i*i;
  	long long b = j*j*j*j*j;
  
  	if(a-b==x){
    	cout << i << " " << j << endl;
    	return 0;
    }
  }
  }
  //cout << 2 << endl;
}

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

int main() {
  int h, w, tmp = 0;
  string s[50];
  cin >> h >> w;
  for (int i = 0; i < h; i++) cin >> s[i];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      tmp = 0;
      if (s[i].at(j) == '.') {
        if (i != 0 && j != 0) {if (s[i-1].at(j-1) == '#') tmp++;}
        if (i != 0) {if (s[i-1].at(j) == '#') tmp++;}
        if (i != 0 && j < w - 1) {if (s[i-1].at(j+1) == '#') tmp++;}
        if (j != 0) {if (s[i].at(j-1) == '#') tmp++;}
        if (j < w - 1) {if (s[i].at(j+1) == '#') tmp++;}
        if (i < h - 1 && j != 0) {if (s[i+1].at(j-1) == '#') tmp++;}
        if (i < h - 1) {if (s[i+1].at(j) == '#') tmp++;}
        if (i < h - 1 && j < w - 1) {if (s[i+1].at(j+1) == '#') tmp++;}
        cout << tmp;
      }
      else if (s[i].at(j) == '#') cout << '#';
    }
  cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
long long arr[MAX];
int main()
{
    long long x;
    cin >> x;
    for(long long i=0;i<=1000;i++){
        for(long long j=-1000;j<=1000;j++){
            if(i*i*i*i*i - j*j*j*j*j == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}



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

int main(){
  int e;
  while(cin >> e,e){
    int x,y,z;
    int m = 10000;
    for(int i=0; i*i*i<=e; ++i){
      for(int j=0; j*j<=e-(i*i*i); ++j){
	int k = e - j*j - i*i*i;
	    m = min(m,i+j+k);
	    
      }
    }
    cout << m << endl;
  }
  return 0;
}
	    
	    
	    



Measured memory_bytes: 3064
N = list(map(int,input().split()))
count = 0
for i in range(min(N[0],N[1]),-1,-1):
  if count>N[2]:
    break
  elif i!=0 and N[0]%i==0 and N[1]%i==0:
#    ans.append(i)
    count+=1
  if count==N[2]:
    print(i)
    count+=1

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            Console.WriteLine(N / 3);
        }
    }
}


Measured memory_bytes: 11092
s = input()
n = len(s)

succession = 1
max_succession = 0

anal = [0]*n
l_tmp = 1
judge = 1

for i in range(1,n):
    if s[i] == "R":
        if s[i-1] == "R":
            succession += 1
            if  max_succession < succession:
                max_succession = succession
        else:
            anal[l_tmp] = succession
            succession = 1
    else:
        if s[i-1] == "L":
            succession += 1
            if  max_succession < succession:
                max_succession = succession
        else:
            anal[i-1] = succession
            succession = 1
            l_tmp = i
anal[l_tmp] = succession
#print(anal,l_tmp)

for i in range(n-1):
    if judge == 0:
        judge = 1
        continue
    else:
        if anal[i] != 0:
            if abs(anal[i+1] - anal[i]) >= 1:
                if max(anal[i+1],anal[i]) % 2 != 0:
                    if anal[i+1] > anal[i]:
                        tmp = (anal[i+1]+anal[i])
                        anal[i+1] = tmp // 2 + tmp%2
                        anal[i] = tmp // 2
                    else:
                        tmp = (anal[i+1]+anal[i])
                        anal[i+1] = tmp // 2
                        anal[i] = tmp //2 + tmp%2
                else:
                    if anal[i+1] > anal[i]:
                        tmp = (anal[i+1]+anal[i])
                        anal[i+1] = tmp // 2 
                        anal[i] = tmp // 2 + tmp%2
                    else:
                        tmp = (anal[i+1]+anal[i])
                        anal[i+1] = tmp // 2 + tmp%2
                        anal[i] = tmp //2 
                        
            judge = 0
            
for i in range(n):
    print(anal[i],end=" ")
print()

Measured memory_bytes: 4992
def selectionSort(a, n):
    count = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if i != minj:
            count += 1
    return count


def main():
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    count = selectionSort(a, n)
    print(' '.join([str(x) for x in a]))
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 7740
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using ll = long long int;

int main(int argc,char *argv[])
{
	ll a,b,c,d;
	std::cin >> a >> b >> c >> d;

	while (true)
	{
		c -= b;
		if (c <= 0) {  std::cout << "Yes" << std::endl; break; }
		a -= d;
		if (a <= 0) {  std::cout << "No" << std::endl; break; }
	}

	return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
main()
{
  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  int i=0;
  if(a==b && a!=c) printf("Yes");
  else if(a==c && a!=b) printf("Yes");
  else if(b==c && a!=b) printf("Yes");
  else printf("No");

  return 0;
}
  


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll h,w,k; cin>>h>>w>>k;
    vector<string> s(h);
    rep(i,h) cin>>s[i];
    ll ans=0;
    rep(is,1<<h)rep(js,1<<w){
        ll cnt=0;
        rep(i,h)rep(j,w){
            if(is&1<<i) continue;
            if(js&1<<j) continue;
            if(s[i][j]=='#') ++cnt;
        }
        if(cnt==k) ++ans;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
import std.stdio, std.string, std.conv, std.algorithm, std.math;

struct P { int x,y; }
void main()
{
    int n = readln.chomp.to!int;
    foreach(_; 0 .. n)
    {
        P[] rooms;
        P cur;
        while(true)
        {
            auto inp = readln.split.map!(to!int);
            if(!inp[0] && !inp[1]) break;
            cur.x += inp[0];
            cur.y += inp[1];
            rooms ~= cur;
        }
        int dis = 0;
        P farRoom;
        foreach(room; rooms)
        {
            int d = room.x * room.x + room.y * room.y;
            if(dis < d || (dis == d && farRoom.x < room.x))
            {
                dis = d;
                farRoom = room;
            }
        }
        writeln(farRoom.x, " ", farRoom.y);
    }
}

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

bool judgePrimeNumber( int a )
{
    for( int i = 2; i <= sqrt(a); i++ )
        if( a % i == 0 )
            return false;
    return true;
}

int main()
{
    int n;

    while( cin >> n )
    {
        if( n == 0 )
            break;
        if( judgePrimeNumber(n) )
            cout << 0 << endl;
        else
        {
            int a = n + 1, b = n - 1;
            while( judgePrimeNumber(a) == false )
                a++;
            while( judgePrimeNumber(b) == false )
                b--;
            cout << a - b << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3020
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <fstream>

using namespace std;

template<class T> inline T cabs(const T &x) { return x > 0 ? x : (-x); }
template<class T> inline T gcd(const T &x, const T &y) { return (y == 0) ? x : gcd(y, x % y); }
template<class T> inline T sgn(const T &x) { return (x > 0) - (x < 0); }

#define dbg(x) cout << #x << " = " << (x) << endl
#define dbg2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define dbg3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl
#define dbg4(x,y,z,w) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #w << " = " << w << endl

#define out(x) cout << (x) << endl
#define out2(x,y) cout << (x) << " " << (y) << endl
#define out3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define out4(x,y,z,w) cout << (x) << " " << (y) << " " << (z) << " " << (w) << endl

const int maxN = 100000 + 10;

int N, M;
vector<int> adj[maxN << 1];
bool vst[maxN << 1];

void dfs(int u) {
    vst[u] = 1;
    for(int i = 0; i < (int)adj[u].size(); i ++) {
        if( vst[ adj[u][i] ] == false ) {
            dfs(adj[u][i]);
        }
    }
}

int main()
{
    scanf("%d %d", &N, &M);
    int ki, mi;
    for(int i = 1; i <= N; i ++) {
        scanf("%d", &ki);
        for(int j = 1; j <= ki; j ++) {
            scanf("%d", &mi);
            adj[i].push_back(mi + N);
            adj[mi + N].push_back(i);
        }
    }
    memset(vst, 0, sizeof(vst));
    dfs(1);
    for(int i = 1; i <= N; i ++) {
        if( vst[i] == false ) {
            out("NO");
            return 0;
        }
    }
    out("YES");
    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
const int BASE = 1e9 + 7;

long long c[2020][2020];

int main()
{
  for (int i = 0; i <= 2000; i++)
    for (int j = 0; j <= i; j++)
      c[i][j] = j ? (c[i - 1][j - 1] + c[i - 1][j]) % BASE : 1;

  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++)
    if (n == k) cout << (i == 1) << endl;
    else
    {
      long long ans = (c[n - k - 1][i - 1] * 2 + c[n - k - 1][i]) % BASE;
      if (i > 1)
        ans = (ans + c[n - k - 1][i - 2]) % BASE;
      ans = ans * c[k - 1][i - 1] % BASE;
      cout << ans << endl;
    }
}


Measured memory_bytes: 30336
#include <bits/stdc++.h>
using namespace std;
typedef pair<char,int> P;
char S[1000001];
vector<P> V;
int main() {
    scanf("%s",S);
    char ch=S[0];
    int cnt=0;
    for(int i=0;S[i]!='\0';i++) {
        if(ch==S[i]) {
            cnt++;
        }else {
            V.push_back(P(ch,cnt));
            cnt=1;
            ch=S[i];  
        }
    }
    V.push_back(P(ch,cnt));
    int ans=0;
    for(int i=0;i+2<V.size();i++) {
        if(V[i].first!='J'||V[i+1].first!='O'||V[i+2].first!='I') continue;
        if(V[i].second>=V[i+1].second&&V[i+2].second>=V[i+1].second) {
            ans=max(ans,V[i+1].second);
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 11820
n,m = map(int, input().split())
ans = []

for i in range(2,m+1,2):
    ans.append([n-(i//2),(i//2)])
for i in range(1,m+1,2):
    ans.append([n//2-(i-1)//2,n//2+1+(i-1)//2])
for i in range(m):
    print(*ans[i])

Measured memory_bytes: 22592
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int n,m,c;
  cin>>n>>m>>c;
  vector<int>b(m);
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  vector<vector<int>>a(n,vector<int>(m));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j]; 
    }
  }
  
  int y=0;
  for(int i=0;i<n;i++){
    long long int x=0;
    for(int j=0;j<m;j++){
      x+=a[i][j]*b[j];
    }
    x+=c;
    if(x>0){
      y++;
    }
  }
  cout<<y<<endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int>A(N);
  for(int i = 1; i < N; i++)cin >> A.at(i);
  vector<int>ans(N);
  for(int i = 1; i < N; i++){
    ans.at(A.at(i) - 1) += 1;
  }
  for(int i = 0; i < N; i++){
    cout << ans.at(i) << endl;
  }
}


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

int main() {
  int K,X;
  cin >> K >> X;
  int a = max(X-K+1,-1000000);
  cout << a;
  while (a <= X+K-1-1 && a <= 1000000-1) {
    a++;
    cout << " " << a;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
 
static const double EPS = 1e-8;
 
int tx[] = {1,0};
int ty[] = {0,1};
 
int main(){
	int sum=0;
    for(int i=0;i<4;i++){
		int t;
		scanf("%d",&t);
		sum += t;
	}
	printf("%d\n%d\n",sum/60,sum%60);
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, h, w;

int solve() {
    return (n - h + 1) * (n - w + 1);
}

void input() {
    cin >> n >> h >> w;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3148
N, M, X = map(int, input().split())
A = list(map(int,input().split()))
for i in range(M-1):
  if A[0] > X or A[M-1] < X:
    print(0)
    break
  elif A[i] < X < A[i+1]:
    print(min(i+1, M-i-1))
    break

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int input;
	vector<int> cases;
	vector<int>::iterator pv;

	while (1)
	{
		cin >> input;

		if (input == 0) break;
		cases.push_back(input);
	}

	pv = cases.begin();
	int count = 1;

	while (pv != cases.end())
	{
		cout << "Case " << count << ": " << *pv << endl;
		++pv;
		++count;
	}

	return 0;
}


Measured memory_bytes: 3184
while True:
    n,k=[int(i) for i in input().split()]
    if n==0 and k==0:
        break
    a=[int(input()) for i in range(n)]
    s=sum(a[0:k])
    ma=s
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        if s>ma:
            ma=s
    print(ma)



Measured memory_bytes: 9880
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

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

  cout << min(n, min((n % k), abs((n % k) - k))) << endl;
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  B - Bishop
//
//  Created by Hashizo on 2020/03/14.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {
	ll ans = 0;


	ll h,w;
	cin >> h >> w;

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


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def inv(x):
    return pow(x, MOD-2, MOD)

def nPk(n,k):
    return kaijo[n] * inv(kaijo[n-k]) % MOD

def nCk(n,k):
    return nPk(n,k) * inv(kaijo[k])

MOD = 10**9+7

kaijo = [0] * 400020
kaijo[0] = 1
for i in range(1, len(kaijo)):
    kaijo[i] = kaijo[i-1] * i % MOD

n,k = get_nums_l()

if k >= n-1:
    print(nCk(n+n-1, n) % MOD)
    exit()

# 0人の部屋=zがk以下であるような人数の並べ方の個数

# z=0 1
# z=1 nC1 * (n-1)H1
# z=2 nC2 * (n-2)H2
# z=3 nC3 * (n-3)H3
# z   nCz * (n-z)Hz

ans = 1
for z in range(1,k+1):
    ans += nCk(n,z) * nCk(n-1, z)

print(ans%MOD)

Measured memory_bytes: 45288
const isZero = (x: number) => x === 0 ? 1 : 0;

const  main = (standardInput) => {
  const  lengthList: string[] = standardInput.split(' ');
  const x: number = Number.parseInt(lengthList[0]);
  console.log(isZero(x))
  	
}
 
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));

Measured memory_bytes: 29560