akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

const int MAX_N = 2e5;

vector<int> x[MAX_N];

int solve(int n){
    vector<int> flag(n,0);
    for(int j : x[0]){
        flag[j] = 1;
    }
    for(int j : x[n-1]){
        if(flag[j]){
            return 1;
        }
    }
    return 0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        x[a].emplace_back(b);
        x[b].emplace_back(a);
    }
    cout << (solve(n) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


Measured memory_bytes: 12784
#include <bits/stdc++.h>
     
#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()
     
using namespace std;
using ll = long long;
using P = pair<int, int>;
     
template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }
     
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

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

  for( int bit = 0; bit < 1 << ( N - 1 ); bit++ ){
    int t = s[0] - '0';
    REP( i, N - 1 ){
      if( bit >> i & 1 ){
        t += s[i + 1] - '0';
      }else{
        t -= s[i + 1] - '0';
      }
    }
    if( t == 7 ){
      cout << s[0];
      REP( i, N - 1 ){
        if( bit >> i & 1 ){
          cout << '+' << s[i + 1];
        }else{
          cout << '-' << s[i + 1];
        }
      }
      cout << "=7" << endl;

      return 0;
    }
  }
}


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

struct Card {char suit, value;};

void bubbleSort(struct Card A[], int N) {
    int flag = 1;
    while (flag) {
        flag = 0;
        for (int j = N-1; j > 0; j--) {
            if (A[j].value < A[j-1].value) {
                swap(A[j], A[j-1]);
                flag = 1;
            }
        }
    }
    
}

void selectionSort(struct Card A[], int N) {
    int minj;
    
    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (A[j].value < A[minj].value) minj = j;   
        }
        if (i != minj) {
            swap(A[i], A[minj]);
        }
    }
}

void trace(struct Card A[], int N) {
    for (int k = 0; k < N; k++) {
        if (k > 0) cout << ' ';
        cout << A[k].suit << A[k].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for (int i = 0; i < N; i++) C2[i] = C1[i];

    bubbleSort(C1, N);
    selectionSort(C2, N);

    trace(C1, N);
    cout << "Stable" << endl;
    trace(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    return 0;

    
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		boolean checkStart = true;

		while (checkStart) {

			// 二次元配列作成
			int[][] map = new int[12][12];

			// 島の数をカウントする変数
			int countIsland = 0;

			// 入力された値を配列に格納
			for (int row = 0; row < 12; row++) {
				// 入力された数字を一列づつ文字列として変数に格納
				String lineOfNum = scan.nextLine();

					for (int column = 0; column < 12; column++) {
						// 入力された数値を二次元配列に格納
						map[row][column] = (int) lineOfNum.charAt(column) - 48;
					}
			}

			for (int row = 0; row < 12; row++) {
				for (int column = 0; column < 12; column++) {

					// 起点が黒(1)の時
					if (map[row][column] == 1) {

						// チェック済みか判別のため、-1に書き換える
						map[row][column] = -1;
						// 島のフラグを立てるメソッド
						check(row, column, map);
						countIsland++;
					}
				}
			}
			System.out.println(countIsland);

			if(scan.hasNextLine()){
				//空行の空読み
					scan.nextLine();
			}else{
				break;
			}

		}
		scan.close();
	}

	// 引数:行, 列, 二次元配列map
	static void check(int row, int column, int[][] map) {

		// 起点の上側の変数
		int rowUp = row - 1;

		if (rowUp >= 0) {

			// リストの要素の上の値が黒(1)になるとき
			if (map[rowUp][column] == 1) {

				// チェック済みか判別のため、数値を-1に書き換える
				map[rowUp][column] = -1;

				check(rowUp, column, map);
			}
		}

		// 起点の右側の変数
		int columnRight = column + 1;

		if (0 <= columnRight && columnRight < 12) {

			// 配列の要素の右の値が黒(1)になるとき
			if (map[row][columnRight] == 1) {

				map[row][columnRight] = -1;

				check(row, columnRight, map);
			}
		}

		// 起点の下側の変数
		int rowDown = row + 1;

		if (rowDown < 12) {

			// 配列の要素の右の値が黒(1)になるとき
			if (map[rowDown][column] == 1) {

				map[rowDown][column] = -1;

				check(rowDown, column, map);
			}
		}

		// 起点の左側の変数
		int columnLeft = column - 1;

		if (columnLeft >= 0) {

			// 配列の要素の左の値が黒(1)になるとき
			if (map[row][columnLeft] == 1) {

				map[row][columnLeft] = -1;

				check(row, columnLeft, map);
			}
		}
	}
}



Measured memory_bytes: 26076
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[110000];

int main(){
	int N, M;
	cin >> N >> M;
	string S;
	cin >> S;
	for(int i = 0; i <= N; i++){
		DP[i] = INF;
	}
	DP[N] = 0;
	queue<P> que;
	que.push(P(N, 0));
	for(int i = N - 1; i >= 0; i--){
		if(S[i] == '1'){
			continue;
		}
		while(true){
			if(que.empty()){
				cout << -1 << endl;
				return 0;
			}
			P p = que.front();
			if(i + M >= p.first){
				break;
			}
			que.pop();
		}
		DP[i] = que.front().second + 1;
		que.push(P(i, DP[i]));
	}
	/*
	for(int i = 0; i <= N; i++){
		cout << DP[i] << " ";
	}cout << endl;
	*/
	int pos = 0;
	int cur = DP[0];
	for(int i = 1; i <= N; i++){
		if(DP[i] != INF && DP[i] != cur){
			cout << i - pos;
			pos = i;
			cur = DP[i];
			if(i != N){
				cout << " ";
			}else{
				cout << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1920
import itertools
def resolve():
    H,W,K = map(int,input().split())
    bi = []
    bj = []
    for i in range(H):
        row = input()
        for j in range(W):
            if row[j]=='#':
                bi.append(i)
                bj.append(j)
    
    dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
    # 行を削除してみる
    count = 0

    row_iters = [itertools.combinations(range(H), i) for i in range(0,H+1)]
    for row_iter in row_iters:
        for target_rows in row_iter:
            row_del_position = [i_position for i_position, i in enumerate(bi) for target_row in target_rows if i == target_row]
            #new_bi = dellist(bi, row_del_position)
            new_bj = dellist(bj, row_del_position)
            if len(new_bj)>=K:
                #print('bi>=K')
                #print(target_rows)
                #print(new_bi, new_bj)
                column_iters = [itertools.combinations(range(W), i) for i in range(0,W+1)]
                for column_iter in column_iters:
                    for target_columns in column_iter:
                        column_del_position = [j_position for j_position, j in enumerate(new_bj) for target_column in target_columns if j == target_column]
                        #new_bi2 = dellist(new_bi, column_del_position)
                        new_bj2 = dellist(new_bj, column_del_position)
                        
                        if len(new_bj2) == K:
                            #print('bi==K')
                            #print(target_columns)
                            count +=1
    print(count)
resolve()

Measured memory_bytes: 74772
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-20;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[110000];
int t[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a-1;i++){
		t[i]=p[i+1]-p[i]-1;
	}
	std::sort(t,t+a-1);
	reverse(t,t+a-1);
	int ret=p[a-1]-p[0]+1;
	for(int i=0;i<b-1;i++)ret-=t[i];
	printf("%d\n",ret);
}


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

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int sum = 0;
	for (int i = 0; i < k; i++)
	{
		sum += p[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3564
MOD = 2019
s = list(input())
s.reverse()
n = len(s)
lis = [0] * 2020
ans = 0
x = 1
tot = 0
for i in range(n):
    lis[tot] += 1
    tot += int(s[i]) * x
    tot %= MOD
    ans += lis[tot]
    x *= 10
    x %= MOD
print(ans)


Measured memory_bytes: 77588
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n = int(input())
    if n%2 == 1:
        print(0)
        exit(0)
    
    def count(k, n):
        now = k
        cnt = 0
        while now <= n:
            cnt += n//now
            now *= k
        return cnt

    n //= 2
    ans = count(5, n)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9076
var
  i,j,c,d,b,y:longint;
a:array[0..105,0..105] of char;
x:array[0..105,0..105] of longint;
begin
  readln(b,y);
for i:=1 to b do begin
  for j:=1 to y do
  read(a[i,j]);
  readln;
  end;
for i:=1 to b do
  begin
  for j:=1 to y do begin if a[i,j]<>'#' then begin
if a[i+1,j]='#' then  inc(x[i,j]);
if a[i+1,j+1]='#' then inc(x[i,j]);
if a[i+1,j-1]='#' then inc(x[i,j]); 
if a[i-1,j]='#' then inc(x[i,j]); 
if a[i-1,j+1]='#' then inc(x[i,j]);
if a[i-1,j-1]='#' then inc(x[i,j]);
if a[i,j-1]='#' then inc(x[i,j]);
if a[i,j+1]='#' then inc(x[i,j]);
end;
end;
end;
for i:=1 to b do begin
for j:=1 to y do
if a[i,j]='#' then write('#')
else
write(x[i,j]);
writeln;
end;
end.

Measured memory_bytes: 128
#include <stdio.h>
int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);

if((a==7&&b==5&&c==5)||(b==7&&a==5&&c==5)||(c==7&&b==5&&a==5))
printf("YES");
else
printf("NO");



return 0;  
}

Measured memory_bytes: 128
//666yuchen
#include<bits/stdc++.h>
using namespace std;
string st;
int ans,s,b;
int main()
{
  cin>>st;
  for(int i=0;i<st.size();i++)
    if(s==b){s++;if(st[i]=='p')ans--;}
      else{b++;if(st[i]=='g')ans++;}
  cout<<ans;
  return 0;
}

Measured memory_bytes: 512
k = 36
K = 1<<k
nu = lambda L: int("".join([bin(K+a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [int(a, 2) if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(len(X)*2-1)]]

P = 200003
g = 2
D = {}
E = []
s = 1
for i in range(P - 1):
    E.append(s)
    D[s] = i
    s = s * g % P

N = int(input())
A = [int(a) for a in input().split()]
X = [0] * (P - 1)
ans = 0
for a in A:
    if a:
        ans -= a ** 2 % P
        X[D[a]] += 1

XX = li(st(nu(X) ** 2))
for i in range(P-2):
    XX[i] += XX[i+P-1]

for i, x in enumerate(XX[:P-1]):
    ans += E[i] * x
print(ans // 2)

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

int main() {
  int a,b,c,d,k=1,sum,n=0;
  cin >>a;
  b=a;
  c=a;
  
  while(b>0){
    b/=10;
    n++;
  }b=a;
  
  while(c>0){
    
    for(int i=0;i<n-k;i++){
    b/=10;
    }
    sum+=b;
    
    for(int i=0;i<n-k;i++){
    b*=10;
    }
    c-=b;
    b=c;
    k++;
  }
  
  if(a%sum==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  
}


Measured memory_bytes: 256
n,m = map(int, input().split())
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
ans = 0
def check(x, li):
    k = format(x, 'b')
    while len(k) < 3:
        k = '0' + k
    p = []
    for i in k:
        if i == '0':
            p.append(-1)
        else:
            p.append(1)
    tmp = [sum(li[i][j] * p[j] for j in range(3)) for i in range(n)]
    tmp.sort(reverse=True)
    return sum(tmp[:m])
    


for i in range(8):
    ans = max(ans, check(i, data))
print(ans)

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

const int N = 105, W = 1e5+5;
int n, w;
long long dp[N][W];
std::pair<int, int> a[N];

int32_t main() {
  scanf("%d%d", &n, &w);

  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a[i].first, &a[i].second);

  std::sort(a, a+n);
  
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= w; j++) {
      const int wt = a[i].first, v = a[i].second;
      dp[i][j] = wt > j ? dp[i-1][j] : std::max(v + dp[i-1][j-wt], dp[i-1][j]);
    }
  }

  printf("%lld\n", dp[n][w]);
  return 0;
}


Measured memory_bytes: 79360
import math
def primes(n):
    max = math.sqrt(n)
    candidates = [i for i in range(2, n+1)]
    primes = []
    while candidates[0] <= max:
        primes.append(candidates[0])
        candidates = [candidates[i] for i in range(len(candidates)) if candidates[i] % candidates[0] != 0]
    primes.extend(candidates)
    return primes

def resolve():
    N = int(input())
    _primes = primes(55555)
    ans = []
    for p in _primes:
        if p%5==1:
            ans.append(p)
            if len(ans) == N:
                break
    print(" ".join(map(str, ans)))

    
if '__main__' == __name__:
    resolve()


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2-x1, dy = y2-y1;
	cout << x2-dy << " " << y2+dx << " " << x1-dy << " " << y1+dx << endl;

	return 0;
}

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

typedef struct {
    int time;
    int weight;
} EVENT;

int compare(const void *a, const void *b)
{
    EVENT *x, *y;
    
    x = (EVENT *)a;
    y = (EVENT *)b;
    
    if (x->time != y->time){
        return (x->time - y->time);
    }
    
    return (x->weight - y->weight);
}

int main(void)
{
    EVENT in[200];
    int i, j;
    int n;
    int m, a, b;
    int flag;
    int s;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        j = 0;
        for (i = 0; i < n; i++){
            scanf("%d%d%d", &m, &a, &b);
            in[j].weight = m;
            in[j++].time = a;
            in[j].weight = -1 * m;
            in[j++].time = b;
        }
        
        qsort(in, 2 * n, sizeof(EVENT), compare);
        
        i = s = 0;
        flag = 1;
        while (i != 2 * n){
            s += in[i++].weight;
            if (s > 150){
                flag = 0;
                break;
            }
        }
        
        if (flag){
            printf("OK\n");
        }
        else {
            printf("NG\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

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

int main() {
    int N;
    cin >> N;
    
    int A[100010];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int g = A[0];
    for (int i = 1; i < N; i++) {
        g = gcd(g, A[i]);
    }
    cout << g << endl;
}

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

int main(){
    int n,max=0,id;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
        if(max<a[i]){
            max = a[i];
            id = i;
        }
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i = 0;i < n;i ++){
        if(i==id)   cout << a[1] << endl;
        else        cout << a[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define test() ll t;cin>>t;while(t--)
#define MOD 1000000007
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

int main() {
    SPEED;
    //CODE
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	ll dp[n]={0};
	dp[1]=abs(a[1]-a[0]);
	for(ll i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i-2]-a[i]));
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <queue>
#include <stdlib.h>
#include <algorithm>

using namespace std;

struct city {
    long long prefecture;
    long long year;
    long long where;
    string id;

    city(long long p, long long y, long long w){
        prefecture = p;
        year = y;
        id = "";
        where = w;
    }
};

bool operator<(const city& c1, const city& c2 ){
    if(c1.prefecture < c2.prefecture)
        return true;
    if(c1.prefecture > c2.prefecture)
        return false;
    return c1.year < c2.year;
}

bool operator>(const city& c1, const city& c2){
    return !(c1 < c2);
}

bool operator==(const city& c1, const city& c2){
    return c1.year == c2.year;
    // return c1.year == c2.year && c1.prefecture == c2.prefecture;
}

string padzero(long long num){
    string s = to_string(num);
    string pad = "0";
    string ret = "";
    ret.reserve(12);
    for(int i = 0; i < 6 - s.length();i++){
        ret += pad;
    }
    ret += s;
    return ret;
}

string makeID(long long p, long long num){
    string s = padzero(p);
    s += padzero(num);
    return s;
    // return sprintf("%06d%6d", p+1,num+1);
}

long long binary_search(city c, vector<city> v){
    long long l = 0, r = v.size()-1;
    long long m = (l+r)/2;
    while(l < r) {
        if(v[m] == c){
            return m;
        }
        if(v[m] < c){
            l = m+1;
            m = (l + r)/2;
        } else {
            r = m-1;
            m = (l + r)/2;
        }
    }
    return r;
}

int main() {
    long long n,m; cin >> n >> m;
    vector<vector<city> > cities;
    vector<city> tmp;
    vector<city> v;
    long long tmp1,tmp2;
    for(long long i = 0; i < n; i++){
        cities.push_back(tmp);
    }
    for(long long i = 0; i < m; i++){
        cin >> tmp1;
        cin >> tmp2;
        city tmp = city(tmp1,tmp2,i);
        cities[tmp1-1].push_back(tmp);
        v.push_back(tmp);
    }
    for(long long i = 0; i < n;i++){
        sort(cities[i].begin(), cities[i].end());
    }
    for(long long i = 0; i < n; i++){
        for(long long j = 0; j < cities[i].size(); j++){
            v[cities[i][j].where].id = makeID(i+1,j+1);
        }
    }
    // for(long long i = 0; i< m;i++){
    //     for(long long j = 0; j < cities[v[i].prefecture-1].size();j++){
    //         if(v[i] == cities[v[i].prefecture-1][j]){
    //             // v[i].id = makeID(v[i].prefecture,j+1);
    //             printf("%06lld%06lld\n", v[i].prefecture,j+1);
    //         }
    //     }
    //     // printf("%06lld%06lld\n", v[i].prefecture, binary_search(v[i], cities[v[i].prefecture-1])+1);
    // }
    for(long long i = 0; i < m;i++){
        cout << v[i].id << endl;
    }
}


Measured memory_bytes: 17132
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
int lift[(int)1e5 + 10][20] = {0};
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    vi dis(n);
    FOR(i, n)cin >> dis[i];
    int j = 0;
    int l; cin >> l;
 //   cout << endl << endl;
    FOR(i, n){
       while(j < dis.size()- 1 && dis[j+1] <= dis[i] + l){
        j++;
       } 
       lift[i][0] = j;
//       cout << i << " " << j <<endl;
    }
    for(int i = 1; i <= 16; i++){
        FOR(j, n){
            lift[j][i] = lift[lift[j][i-1]][i-1];
        } 
    }
    //debug("pre done");
    int q;cin >> q;
    int i;
    FOR(xx, q){
        cin >> i >> j;
        if(j < i)swap(i, j);
        i--, j--;
        int ans = 0;
        int bit = 16;
        while(bit >= 0 && i < j){
           if(lift[i][bit] < j){
            i = lift[i][bit];
            ans += (1 << bit);
           } 
           bit--;
        }
        if(i < j)cout << ans +1;
        else cout << ans ;
        cout << "\n";
    }
}




Measured memory_bytes: 17280
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;

ll kaijou(ll n){
    if(n==0||n==1)return 1;
    return ((kaijou(n-1)%1000000007)*(n%1000000007))%1000000007;
}

int main(){
    ll a,b;cin>>a>>b;
    if(abs(a-b)>1){
        cout<<0<<endl;
        return 0;
    }
    else if(a==b){
        cout<<((kaijou(a)*kaijou(b))*2)%1000000007<<endl;
    }
    else{
        cout<<(kaijou(a)*kaijou(b))%1000000007<<endl;
    }
}






Measured memory_bytes: 1792
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n,k; cin >> n >> k;
    if(k==1){
        cout << 0 << endl;
        return 0;
    }
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    ll ans=0;
    vector<int> s(n+1);
    s[0]=0;
    map<int,int> mp;
    mp[0]=1;
    rep(i,n){
        s[i+1]=(s[i]+a[i])%k;
        if(i-k+1>=0) mp[s[i-k+1]]--;
        ans+=mp[s[i+1]];
        mp[s[i+1]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	string s;
	while (cin >> s) {
		for (char &c : s) if (c == ',')
			c = ' ';
		cout << s << endl;
	}
	return 0;
}


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

typedef long long ll;

#define MOD 998244353

vector<ll> fac(200001);
vector<ll> ifac(200001);

ll pow (ll a, ll n) {
	if (n==0)
		return 1;
	if (n==1)
		return a % MOD;
	ll tmp = pow (a, n/2);
	tmp %= MOD;
	ll tmp2 = tmp*tmp;
	tmp2 %= MOD;
	if (n%2==1)
		return (tmp2*a) % MOD;
	return tmp2;
}

ll comv (ll a, ll b) {
	if (a==0 || b==0)
		return 1;
	if (a<b || a < 0)
		return 0;
	ll tmp = ifac[a-b]*ifac[b] % MOD;
	return tmp * fac[a] % MOD;
}

int main () {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i=0; i<200000; i++) {
		fac[i+1] = fac[i]*(i+1)  %MOD;
		ifac[i+1] = ifac[i]*pow(i+1, MOD-2) % MOD;
	}


	int N, M, K;
	cin >> N >> M >> K;

	ll ans = 0;
	for (int k=0; k<=K; k++) {
		ll tmp = pow(M-1, N-k-1) % MOD;
		tmp *= M;
		tmp %= MOD;
		tmp *= comv(N-1,k);
		tmp %= MOD;
		ans += tmp;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6284
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var KS = Console.ReadLine().SplittedStringToInt32List();
        var K = KS[0];
        var S = KS[1];
        var count = 0;

        for (int i = 0; i <= K; i++)
        {
            for (int j = 0; j <= K; j++)
            {
                var num = S - i - j;
                if (num >= 0 && num <= K)
                {
                    count++;
                }
            }
        }
        Console.WriteLine(count);
        Console.ReadLine();
    }
    

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    
  
  

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
ll cnt = 0;
vi G;
inline void insertionSort(vi& a, int n, int g) {
	rep(i, g, n) {
		int v = a[i];
		int j = i - g;
		while(j >= 0 && a[j] > v) {
			a[j + g] = a[j];
			j -= g;
			++cnt;
		}
		a[j + g] = v;
	}
}
inline void shellSort(vi& a, int n) {
	for (int h = 1; h <= n; h = h * 3 + 1) {
		G.eb(h);
	}
	rrep(i, len(G) - 1, -1) {
		insertionSort(a, n, G[i]);
	}
}
int main() {
	int n; cin >> n;
	vi v(n); rep(i, 0, n) cin >> v[i];
	shellSort(v, n);
	P(len(G));
	rrep(i, len(G) - 1, -1) cout << G[i] << (i == 0 ? "\n" : " ");
	P(cnt);
	rep(i, 0, n) P(v[i]);
	return 0;
}

Measured memory_bytes: 6604
void main()
{
    long n = rdElem;

    long l, r = n - 1;
    string s;
    string t = "Vacant";

    l.writeln;
    stdout.flush;
    s = rdStr;
    if (s == t) return;
    string f = s;

    r.writeln;
    stdout.flush;
    s = rdStr;
    if (s == t) return;

    foreach (i; 0 .. 21)
    {
        long m = (l + r) >> 1;

        m.writeln;
        stdout.flush;
        s = rdStr;
        if (s == t) return;

        if ((m & 1) == (s == f)) r = m;
        else l = m;
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<vector<int>> A(2,vector<int>(N));
    rep(i,0,2)rep(n,0,N) cin>>A.at(i).at(n);

    int maxAns=0;
    rep(n,0,N){
        int ans=0;
        rep(i,0,N){
            if(i<n) ans+=A.at(0).at(i);
            else if(i>n) ans+=A.at(1).at(i);
            else ans+=A.at(0).at(i)+A.at(1).at(i);
        }
        maxAns=max(maxAns,ans);
    }

    cout<<maxAns<<endl;
}

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

typedef long long ll;

const int N = 200005;
int n;
int A[N];
vector<int> edges[N];
int V[N];
int res[N];

void dfs(int par, int u, int s) {
    for (auto v : edges[u]) {
        if (v == par) continue;
        int *p = lower_bound(V + 1, V + 1 + s, A[v]);
        int dist = p - V;
        int ns = s; // next size
        if (p == V + 1 + s)
            ++ns;

        int orig = *p;
        *p = A[v];
        res[v] = max(res[u], dist);
        dfs(u, v, ns);
        *p = orig;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
    }
    int u, v;
    for (int i = 0; i < n - 1; ++i) {
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    res[1] = 1;
    V[1] = A[1];
    dfs(0, 1, 1);

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

    return 0;
}



Measured memory_bytes: 36252
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}




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


Measured memory_bytes: 256
m[21][11][156],n,k,s;main(N){
for(;N<21;N++)for(m[N][0][0]=n=1;n<=N;n++)for(k=10;k;k--)for(s=155;s-n>=0;s--)m[N][k][s]+=m[N][k-1][s-n];
for(;scanf("%d%d%d",&n,&k,&s),n;)printf("%d\n",m[n][k][s]);
}

Measured memory_bytes: 736
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    rep(i, n) {
        if ( i == 0 ) ans *= k;
        else          ans *= (k - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	n,c,s:=0,0,""
	Fscan(in, &n, &s)
	for i, j := 0, n-1; i < j; {
		for ; i < j && s[i] == 'R'; i++ {}
		for ; i < j && s[j] == 'W'; j-- {}
		if i < j {
			c++;i++;j--
		}
	}
	Print(c)
}


Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;

	string s;
	if ((a < b && b < c) || (b < a && a < c) || (c < b && b < a) || (c < a && a < b)) {
		s = "No";
	}
	else {
		s = "Yes";
	}
	cout << s << endl;
	return 0;
}

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

#define maxn 1000005


int main(int argc, char const *argv[])
{
	int x,y,z;
	cin>>x>>y>>z;
	int nz,ny;
	int ans=0;
	for (int i = 1; i < maxn; ++i){
		ny=i;
		nz=ny+1;
		if(y*ny+z*nz<=x && y+2*z<=x){
			ans=ny;
			//cout<<"ny="<<ny<<"nz="<<nz<<endl;
		}
		if(y*ny+z*nz>x) break;
	}

	cout<<ans<<endl;

	return 0;
}

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

int main() {
	const int n = 6;
	int dice[n];
	int top, front;
	int p;
	int dice_result[6];
	/*     const int dice_tem[4][6] ={ {2,6,3,4,1,5},{5,1,3,4,6,2},
	{4,2,1,6,5,3},{3,2,6,1,5,4}};*/
	const int dice_tem[4][6] = { { 3,2,6,1,5,4 },{ 2,6,3,4,1,5 },
	{ 5,1,3,4,6,2 },{ 4,2,1,6,5,3 } };
	for (int i = 0; i < n; i++) {
		cin >> dice[i];
	}
	int num;
	cin >> num;
	for (int v = 0; v < num; v++) {
		cin >> top >> front;
		for (int d = 0; dice[0] != top ; d++) {
			if (d == 0)continue;

			for (int i = 0; i < n; i++) {
				dice_result[i] = dice[dice_tem[d % 2][i] - 1];
			}
			for (int i = 0; i < n; i++)dice[i] = dice_result[i];
		//	cout << "dice0 : " << dice[0] << endl;
		}
		//for (int i = 0; i < n; i++) { cout << dice[i] <<' '; }cout << endl;
		
		
		for (p = 0; p < 4; p++) {
			for (int i = 0; i < n; i++) {
			dice_result[i] = dice[dice_tem[p][i]-1];
		}
		//	cout << "p: " << p << " res" << dice_result[0] << endl;
			if (front == dice_result[0]) break;
		}
	//	cout << "result:" << dice[dice_tem[p][p +2 ]] << " p" << p << endl;
		int a = p == 0 ? 2 : p == 1 ? 0 : p == 2 ? 3 : p == 3 ? 1 : -1;
		int y[6];
		for (int i = 0; i < n; i++)y[i] = dice[dice_tem[a][i] - 1];
		cout << y[0]  << endl;
		

	}
	return 0;
}
		


Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main() {
    bool homexp = false;
    bool homexm = false;
    bool homeyp = false;
    bool homeym = false;
    bool homex = false;
    bool homey = false;
    string root;
    cin >> root;
    for (int i = 0; i < root.size(); ++i) {
        switch (root[i]){
            case 'N':
                homeyp = true;
                break;
            case 'S':
                homeym = true;
                break;
            case 'E':
                homexm = true;
                break;
            case 'W':
                homexp = true;
                break;
        }
    }
    if (homexm == true&& homexp == true){
        homex = true;
    }
    if (homexm == false&& homexp == false){
        homex = true;
    }
    if (homeym == true&& homeyp == true){
        homey = true;
    }
    if (homeym == false&& homeyp == false){
        homey = true;
    }
    if (homex == true && homey == true){
        cout << "Yes";
    } else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int t[10001];
int n,m,a,b,ans=0;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>a;
    t[n]=a;
    for(b=0;t[b]!=a;b++);
    if(b!=n)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, a, b) for (ll i = (a); i < (b); i++)
    #define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
    #define be(x) (x.begin(), x.end())
    #define pb(t) push_back(t)
    #define ll long long
    int main()
    {
        int n,k, count=0;
        cin>>n>>k;
        rep(i,0,n)
        {
            int a;
            cin>>a;
            if(a>=k)count++;
        }
        cout<<count<<endl;
    }

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int):
    if X >= 30:
        print(YES)
    else:
        print(NO)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
    int n; cin >> n;
    map<int, int> mp;
    rep(i, n)
    {
        int a; cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto e : mp)if(e.second % 2 == 1)ans++;
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define INF 1e+9

int main() {
	int n;
    while(cin>>n){
        if(!n)break;

        int a,b,c,v=0,d[11][11];

        for(int i=0;i<11;i++){
            for(int j=0;j<11;j++){
                if(i==j)d[i][j]=0;
                else d[i][j]=INF;
            }
        }

        for(int i=0;i<n;i++){
            cin>>a>>b>>c;
            d[a][b]=c;
            d[b][a]=c;
            v=max(max(v,a),b);
        }

        for(int k=0;k<=v;k++){
            for(int i=0;i<=v;i++){
                for(int j=0;j<=v;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
        int  ans1=INF,ans2;
        for(int i=0;i<=v;i++){
            int count=0;
            for(int j=0;j<=v;j++){
                count+=d[i][j];
            }
            if(ans1>count){
                ans1=count;
                ans2=i;
            }
        }

        cout<<ans2<<" "<<ans1<<endl;
    }
	return 0;
}

Measured memory_bytes: 3076
using System;

namespace AtCoder{
  class Program{
    static void Main(string[] args){
      string[] input1 = Console.ReadLine().Split(' ');
      int n = int.Parse(input1[0]);
      int k = int.Parse(input1[1]);
      string[] input = Console.ReadLine().Split(' ');
      int[] dp = new int[n];
      dp[0] = 0;
      dp[1] = Math.Abs(int.Parse(input[0]) - int.Parse(input[1]));
      for(int i = 2; i < n; i++){
        int min = 2147483647;
        for(int j = i - 1; j >= Math.Max(0, i - k); j--){
          min = Math.Min(min, Math.Abs(int.Parse(input[i]) - int.Parse(input[j])) + dp[j]);
        }
        dp[i] = min;
      }
      Console.WriteLine(dp[n-1]);
    }
  }
}


Measured memory_bytes: 35188
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdlib.h>
#include<vector>
#define P 1000000000+7
typedef long long int lli;
using namespace std;

int main(void){
    lli n,k;
    lli min,max;

    cin>>n>>k;
    lli sum=0;
    for(lli i=k;i<=n+1;i++){
        min=(2*0+(i-1)*1)*i/2;
        max=(2*n+(i-1)*-1)*i/2;
        //cout<<"min="<<min<<" max="<<max<<endl;

        sum+=max-min+1;
        sum%=P;
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int sum(int n) {
    int res = 0;
    while (n > 0) {
        res += n % 10;
        n /= 10;
    }

    return res;
}

int main() {

    int n; cin >> n;

    int ans = INF;
    for (int i = 1; i < n; ++i) {
        int a = i;
        int b = n - i;

        ans = min(ans, sum(a) + sum(b));
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define fori(a, n) for(ll (a) = 0; a < (n); ++a)
#define forI(a, n) for(ll (a) = 1; a <= (n); ++a)
#define pll pair<ll, ll>
#define pt pair<ll, ll>
#define x first
#define ff first
#define y second
#define ss second

const ll MAXN = 4e5 + 1;
const ll INF = 9e18;
const ll mod = 1e9 + 7;

ll n, m;

ll t[MAXN * 4];
ll a[MAXN * 4];
vector<pll> ln[MAXN];

void push(ll v){
    t[v] += a[v];
    a[v * 2] += a[v];
    a[v * 2 + 1] += a[v];
    a[v] = 0;
}

void add(ll v, ll l0, ll r0, ll l, ll r, ll val){
    if(l >= r) return;
    if(l0 == l && r0 == r){
        a[v] += val;
        return;
    }
    push(v);
    ll mid = (l0 + r0) >> 1;
    add(v * 2, l0, mid, l, min(r, mid), val);
    add(v * 2 + 1, mid, r0, max(l, mid), r, val);
    push(v * 2), push(v * 2 + 1);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
}

ll q(ll v, ll l0, ll r0, ll l, ll r){
    if(l >= r) return 0;
    push(v);
    if(l0 == l && r == r0){
        return t[v];
    }
    ll mid = (l0 + r0) >> 1;
    return max(q(v * 2, l0, mid, l, min(r, mid)),
               q(v * 2 + 1, mid, r0, max(l, mid), r));
}


void solve(){
    cin >> n >> m;
    fori(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        ln[b].emplace_back(a, c);
    }
    forI(i, n){
        add(1, 0, n + 1, i, i + 1, q(1, 0, n + 1, 0, i));
        for(auto e: ln[i]){
            add(1, 0, n + 1, e.ff, i + 1, e.ss);
        }
    }
    ll ans = 0;
    forI(i, n) ans = max(ans, q(1, 0, n + 1, i, i + 1));
    cout << ans;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
}


Measured memory_bytes: 31104
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	while (cin >> N >> W, N) {
		vector<int>num(11);
		for (int i = 0; i < N; i++) {
			cin >> M;
			num[M / W]++;
		}
		int length = 0;
		for (int i = 0; i <= 10; i++) {
			if (num[i])length = i;
		}
		long double ans = 0.01;
		M = *max_element(num.begin(), num.end());
		for (int i = 0; i <= length; i++) {
			long double add = num[i];
			add /= M;
			add *= (length - i);
			add /= length;
			ans += add;
		}
		cout << setprecision(20) << ans << endl;
	}
}


Measured memory_bytes: 3296