akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int n;
int nEdge;
int nQuery;

int ps[505][505];
int cs[505][505];

int main(void) {
  scanf("%d%d%d", &n, &nEdge, &nQuery);
  REP(i, nEdge) {
    int l, r;
    scanf("%d%d", &l, &r);
    ps[l][r]++;
  }
  REP(i, n+1) REP(j, n+1) {
    cs[i][j] = ps[i][j];
    if(i-1 >= 0) {
      cs[i][j] += cs[i-1][j];
    }
    if(j-1 >= 0) {
      cs[i][j] += cs[i][j-1];
    }
    if(i-1 >= 0 && j-1 >= 0) {
      cs[i][j] -= cs[i-1][j-1];
    }
  }
  // REP(i, n+1) {
  //   REP(j, n+1) {
  //     cerr << " " << cs[i][j];
  //   }
  //   cerr << endl;
  // }
  
  REP(iQuery, nQuery) {
    int p, q;
    scanf("%d%d", &p, &q);
    int res = cs[q][q] - cs[p-1][q];
    printf("%d\n", res);
  }
  
  return 0;
}


Measured memory_bytes: 2944
n = int(input())
s = input()

alphabets = [chr(i + 97) for i in range(26)]

# forward
l1 = [0] * (n-1)
now = [False] * 26
for i in range(n-1):
    now[ord(s[i]) - 97] = True
    l1[i] = now.copy()

# backward
l2 = [0] * (n-1)
now = [False] * 26
for i in range(n-1, 0, -1):
    now[ord(s[i]) - 97] = True
    l2[i-1] = now.copy()

ans = 0
for i in range(n-1):
    cnt = 0
    for j in range(26):
        if l1[i][j] and l2[i][j]:
            cnt += 1

    if ans < cnt:
        ans = cnt

print(ans)

Measured memory_bytes: 9172
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

void main() {
    int H, N;
    scan(H, N);
    auto a = new int[](N);
    auto b = new int[](N);
    iota(N).each!(i => scan(a[i], b[i]));

    const lim = H + a.reduce!max + 1;

    auto dp = new long[][](N + 1, lim);
    fillAll(dp, infl);
    dp[0][0] = 0;

    foreach (i; 1 .. N + 1) {
        foreach (x; 0 .. lim) {
            chmin(dp[i][x], dp[i-1][x]);
            if (x - a[i-1] >= 0) {
                chmin(dp[i][x], dp[i][x - a[i-1]] + b[i-1]);
            }
        }
    }

    long ans = infl;
    foreach (x; H .. lim) {
        chmin(ans, dp[N][x]);
    }
    writeln(ans);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 93052
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n;
string s[155];
bool up=false;

void init(){
  rep(i,105)s[i]="aaa";
}

int main(){
  int n;
  int data[105];
  while(cin>>n){
    if(n==0)break;
    rep(i,n)cin>>data[i];
    sort(data,data+n);
    ll sum=0;
    for(int i=1;i<n-1;i++)sum+=data[i];
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3052
#include <stdio.h>
int main (){
  int N,M,A[1000],B[1000],i,cost=0,min;
  scanf("%d %d",&N,&M);
  scanf("%d %d",&A[0],&B[0]);
  min= A[0];
  for (i=1 ; i<M ;i++){
    scanf("%d %d",&A[i],&B[i]);
    if (min>A[i]){
      min=A[i];
    }
  }
  for(i=0 ; i<M ; i++){
    scanf("%d %d",&A[i],&B[i]);
    if( A[i]<N ){
      cost=cost+B[i]-N;
    }
  }
  cost=cost-N+min;
  printf("%d\n",cost);
  return 0;
}

Measured memory_bytes: 2720
def find(abcd):
    a, b, c, d = abcd
    ops = ['{}{}{}'.format(i, j, k)
           for i in [1, 2] for j in [1, 2] for k in [1, 2]]
    opr = {'1': '+', '2': '-'}

    for op in ops:
        expression = a + opr[op[0]] + b + opr[op[1]] + c + opr[op[2]] + d
        try:
            if eval(expression) == 7:
                return(expression)
        except SyntaxError:
            pass


def main():
    abcd = input()
    print('{}=7'.format(find(abcd)))


main()

Measured memory_bytes: 3064
//-- Araz Jabrayilov --
//-- araz17---zuna#1041 --

#include <bits/stdc++.h>

#define ll long long
#define endl '\n'
#define F first
#define S second

using namespace std;



int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    ll x = 0;
    ll a = 100;
    int t = 0;

    cin >> x;

    while(a < x){
         a *= 1.01;
         t++;
    }

    cout << t << endl;

    return 0;
}



Measured memory_bytes: 3604
a[210][9],i,j,n,k,s;main(x){for(;~scanf("%d",&x);j>2?j=1,++i:++j)!n?n=x:--a[a[i][j]=x][j+3];for(;j>3?s=!printf("%d\n",s),j=++k<n:1;)s+=!~a[x=a[k][j]][3+j++]*x;}

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

int a[1010], vis[1000010];
long long sum[1010];
long long all[1000010];

int main(){
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		sum[i] = sum[i - 1] + a[i];
	}
	int tot = 0;
	for (int i = 1; i <= n; i++){
		for (int j = i; j <= n; j++){
			all[tot++] = sum[j] - sum[i - 1];
		}
	}
	long long ans = 0;
	for (int p = 40; p >= 0; p--){
		int cnt = 0;
		for (int i = 0; i < tot; i++){
			if (vis[i]) continue;
			cnt += all[i] >> p & 1;
		}
		if (cnt < k) continue;
		ans |= 1ll << p;
		for (int i = 0; i < tot; i++){
			if (!(all[i] >> p & 1)) vis[i] = 1;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

struct Dish {
    long a, b, sum;
    Dish(long a, long b) : a(a), b(b), sum(a + b) {}
    bool operator<(const Dish& x) {
        return sum < x.sum;
    }
};

int main() {
    int n;
    cin >> n;
    vector<Dish> dishes;
    for (int i = 0; i < n; i++) {
        long a, b;
        cin >> a >> b;
        dishes.push_back(Dish(a, b));
    }
    long ans = 0;
    sort(dishes.begin(), dishes.end());
    for (int i = 0; i < n; i++) {
        ans += ((i & 1) == 0) ? dishes[n - i - 1].a : -dishes[n - i - 1].b;
    }
    cout << ans << endl;
    return 0;
}


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

void add(string s[], int h, int w, int i, int j) {
	if(i>=0 && i <= h - 1 && j >= 0 && j <= w - 1 && s[i][j] != '#')
		s[i][j]++;

}

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



Measured memory_bytes: 256
#include<stdio.h>
int main(){
    while(1){
    int H,W,i,j;
    scanf("%d%d",&H,&W);
        if(H==0&&W==0)
        break;
        for(i=0;i<H;i++)
        {
            for(j=0;j<W;j++)
            {
                printf("#");
             }
            printf("\n");
        }
        printf("\n");
        
        
    }
return 0;
}


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

int main(void){
    int N;
    cin >> N;
    
    vector<int> size(110,0);
    for(int i = 0 ; i < N ; i++){
        int tmp;
        cin >> tmp;
        size.at(tmp)++;
    }
    
    int cnt = 0;
    for(int i = 0 ; i < 110 ; i++){
        if(size.at(i) != 0){
            cnt++;
        }
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <unordered_map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
ll a[200020];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n; cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  ll cnt = 0;
  REP(i,n) {
    if(a[i] == cnt + 1) {
      ++cnt;
    }
  }
  if(cnt == 0) cout << -1;
  else cout << n - cnt;
  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repb(i,r,l) for(int i=r;i>l;i--)
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

void solve() {
    int mn=1000,mx=0,n;cin>>n;
    for(int i=0;i<n;i++) {
        int x;cin>>x;
        mn = min(mn,x);
        mx = max(mx,x);
    }
    cout<<mx-mn<<endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int i,n,sum=0;
  cin>>n;
  for(i=1; i<=n; i++)
  {
    if(i%3!=0 && i%5!=0)
    {
      sum+=i;
    }
}
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int N,K;
    int M = 0;
    cin >> N >> K;
    vector<int> p(N),s(N+1);
    s[0] = 0;
    REP(i,N){
        cin >> p[i];
        s[i+1] = s[i] + p[i];
    }
    REP(i,N-K+1){
        //cout << s[i+K]-s[i] << endl;
        if(s[i+K]-s[i]>M){
            M = s[i+K]-s[i];
        }
    }
    cout << std::fixed << std::setprecision(15);
    cout << (float)((M+K)/2.0) << endl;
    return 0;
}

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

int main(){
  string s;cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  } else if(s == "Cloudy") {
    cout << "Rainy" << endl;
  } else if(s == "Rainy"){
    cout << "Sunny" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
res = 0
f = 1
t = 10 ** 10
for _ in range(N):
  x, y = map(int, input().split())
  if x != y: f = 0
  if x > y:
    t = min(t, y)
  res += y
if f:
  print(0)
  exit(0)

print(res - t)

Measured memory_bytes: 41580
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	sc := bufio.NewScanner(os.Stdin)
	for {
		sc.Scan()
		in := sc.Text()
		a := strings.Split(in, " ")

		val1, _ := strconv.Atoi(a[0])
		val2, _ := strconv.Atoi(a[1])
		if val1 == 0 && val2 == 0 {
			return
		}

		if val1 < val2 {
			fmt.Printf("%v %v\n", val1, val2)
		} else{
			fmt.Printf("%v %v\n", val2, val1)
		}
	}

}



Measured memory_bytes: 1176
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){

	int N;
	vector<int>player;
	string card;
	while(cin>>N,N){
	cin>>card;
	int ba=0;
	for(int i=0;i<N;i++)player.push_back(0);
	int p=0;
	for(int i=0;i<100;i++){
	if(p==N)p=0;
	
	if(card[i]=='M')player[p]++;
	else if(card[i]=='S'){
	player[p]++;
	ba+=player[p];
	player[p]=0;
	}
	else if(card[i]=='L'){
	player[p]++;
	player[p]+=ba;
	ba=0;
	//continue;
	}	
			/*sort(player.begin(),player.end());
	for(int i=0;i<player.size();i++)cout<<player[i]<<" ";
	cout<<ba<<endl;*/
		p++;
	}
	sort(player.begin(),player.end());
	for(int i=0;i<player.size();i++)cout<<player[i]<<" ";
	cout<<ba<<endl;
	
	card.clear();
	player.clear();
	}
	return 0;
}

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

stack<int> S;
int n, x[10000][10000], a, b, c, d, _time=1;
int y[10000][3];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> b >> c;
		for (int j = 1; j <= c; j++) {
			cin >> d;
			x[i][d] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		x[0][i] = 1;
	}
	S.push(0);
	while (!S.empty()) {
		a = S.top();
		for (int i = 1; i <= n; i++) {
			if (x[a][i] == 1 && y[i][0] == 0) {
				y[i][0] = 1;
				y[i][1] = _time;
				S.push(i);
				goto Exit;
			}
		}
		S.pop();
		y[a][2] = _time;
	Exit:;
		_time++;
	}
	for (int i = 1; i <= n; i++) {
		cout << i << ' ' << y[i][1] << ' ' << y[i][2] << endl;
	}
	return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=1e5+10;
int n;
char s[N];
ll dp[N][4],a[N];
int main()
{
    scanf("%d%s",&n,s+1);
    rep(i,1,n)
    {if(s[i]=='R')a[i]=1;if(s[i]=='G')a[i]=2;if(s[i]=='B')a[i]=3;}


    for(int i=1;i<=n;++i){
        for(int j=1;j<=3;++j) dp[i][j]=dp[i-1][j];

        if(s[i]=='R') dp[i][1]++;
        else if(s[i]=='G') dp[i][2]++;
        else if(s[i]=='B') dp[i][3]++;
    }

    ll ans=0;

    for(int i=n;i;--i){
        for(int j=i-1;j;--j){
            if(a[i]!=a[j])
            ans+=dp[j-1][6-a[i]-a[j]];
        }
    }

    for(int len=1;len<=n;++len){
        for(int i=1;i+2*len<=n;++i){
            int j=i+len,k=j+len;
            if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]) ans--;
        }
    }
    cout<<ans<<endl;
}
/*
5
5 4 3 2 1
*/


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

int main(){
    
    string N;
    cin >> N;
    int A = N[0] - '0';
    int B = N[1] - '0';
    int C = N[2] - '0';
    int D = N[3] - '0';

    if(A+B+C+D==7) cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
    else if(A+B+C-D==7) cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
    else if(A+B-C+D==7) cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
    else if(A+B-C-D==7) cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
    else if(A-B+C+D==7) cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
    else if(A-B+C-D==7) cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
    else if(A-B-C+D==7) cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
    else if(A-B-C-D==7) cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <functional>

int main(void) {
  int n, m, c, i, j, k, ans = 0, now = 0;
  scanf("%d%d%d", &n, &m, &c);
  int l[c], cnt[c];
  std::pair<int, int> b[n];
  for(i = 0; i < c; ++i) {
    scanf("%d", &l[i]);
    cnt[i] = 0;
  }
  for(i = 0; i < n; ++i) {
    scanf("%d%d", &b[i].second, &b[i].first);
    b[i].second--;
  }
  std::sort(b, b + n, std::greater< std::pair<int, int> >());
  for(i = 0; i < n; ++i) {
    if(now == m) break;
    if(cnt[b[i].second] < l[b[i].second]) {
       cnt[b[i].second]++;
       now++;
       ans += b[i].first;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 4216
from collections import Counter
input()
a = list(map(int, input().split()))
ca = Counter(a)
sca = sorted(ca.items(), key=lambda x:-x[0])
# print(sca)
h, w = 0, 0
for k, v in sca:
  if v >= 4:
    h = max(h, k)
    w = max(w, k)
  elif v >= 2:
    if h == 0:
      h = max(h, k)
    else:
      w = max(w, k)
  if h != 0 and w != 0:
    print(h*w)
    exit()
print(0)

Measured memory_bytes: 72344
#include <bits/stdc++.h>
#define fore(i,a,b) for(int i = a; i < b; i++)
#define fst first
#define snd second
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int>
#define piii pair<int, pii>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;

const int N_MAX = 1e6+15;
ll A[N_MAX],B[N_MAX];

int main(){
    int N;
    cin>>N;
    fore(i,0,N){
        cin>>A[i]>>B[i];
    }
    sort(A,A+N);
    sort(B,B+N);
    ll ans = 0LL;
    if(N%2){
        int mid = N/2;
        ans=B[mid]-A[mid]+1;
    }
    else{
        ll x = A[N/2]+A[(N/2)-1];
        ll y = B[N/2]+B[(N/2)-1];
        ans=y-x+1LL;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6780
n, q = list(map(int, input().split()))

ab_list = []
is_ab = True
done_list = []

# while is_ab:
#     a, b = list(map(int, input().split()))
#     ab_list.append((a, b))
#     done_list.append(a)
#     done_list.append(b)
#     if set(done_list) == set(range(1, n+1)):
#         break

for _ in range(n-1):
    a, b = list(map(int, input().split()))
    ab_list.append((a, b))

px_total_dict = {node_id: 0 for node_id in range(1, n+1)}
for _ in range(q):
    p, x = list(map(int, input().split()))
    px_total_dict[p] += x

ab_list = sorted(ab_list, key=lambda x: x[0])

count_list = [0] * n
next_child_list = []

# 子供ではなく親を覚える方式は？
# parent2children_dict = {i: [] for i in range(1, n+1)}

# for i, ab in enumerate(ab_list):
#     a, b = ab
#     next_child_list.append(b)

#     if i != len(ab_list) - 1 and ab_list[i+1][0] == a:
#         # 次の辺も同じノードが始点だったら
#         continue
#     else:
#         parent2children_dict[a] = next_child_list
#         next_child_list = []

ch2pa_dict = {}

for i, ab in enumerate(ab_list):
    a, b = ab
    ch2pa_dict[b] = a

root_id = list(set(list(range(1, n+1))) - set(list(ch2pa_dict.keys())))[0]
# print('root_id: {}'.format(root_id))

# for i, ab in enumerate(ab_list):
#     a, b = ab
#     next_child_list.append(b)

#     if i != len(ab_list) - 1 and ab_list[i+1][0] == a:
#         # 次の辺も同じノードが始点だったら
#         continue
#     else:
#         parent2children_dict[a] = next_child_list
#         next_child_list = []

# print(parent2children_dict)

for node_id in range(1, n+1):
    # print('node_id: {}'.format(node_id))
    count = px_total_dict[node_id]
    count_list[node_id-1] += count
    if node_id != root_id:
        parent_id = ch2pa_dict[node_id]
        count_list[node_id-1] += count_list[parent_id-1]
    # print(child_list)
    # print(count_list)

ans = ' '.join([str(x) for x in count_list])
print(ans)


Measured memory_bytes: 99800
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int n, t;
  float a;
  cin >>n;
  cin >> t >> a;
  int h[n];
  float ht[n];
  for(int i=0;i<n;i++){
    cin>> h[i];
    
    ht[i] = t -h[i]*0.006;
  }
  
  int ans=0;
  for(int i=0;i<n;i++){
    if( pow(a - ht[i], 2) < pow(a - ht[ans], 2)){
      ans = i;
    }
  }
  cout <<ans+1;
  return 0;
}

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

using namespace std;

char ch[100005];

int main()
{
    scanf("%s",ch);
    int r=0,p=0;
    int sum =0;
    int l =strlen(ch);
    for(int i=0;i<l;i++)
    {
        if(ch[i] == 'g')
        {
            if(r == p) r++;
            else
            {
                p++;
                sum ++;

            }
        }
        if(ch[i]=='p')
        {
            if(r == p)
            {
                r++;
                sum--;
            }
            else p++;
        }
    }
    printf("%d\n",sum);
    return 0;
}

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

//solution:
#define int int64_t

void hike() {
    int n; cin >> n;
    cout << (1000 - (n % 1000)) % 1000 << "\n";
}

signed main() {
    int t = 1; //cin >> t;
    while(t--) hike();
    return 0;
} //farewell, until we meet again..

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
const int MOD=1e9+7;
char s[1000001];
int nxt[1000001];
int dp[1000001];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);s[n+1]=s[n];
	for(int i=1,j=2;j<=n+1;j++){
		if(s[j-1]==s[j]){
			while(i<j)nxt[i++]=j;
		}
	}
	if(nxt[1]>n)printf("1");
	else{
		dp[0]=1;
		for(int i=0;i<n;i++){
			(dp[i+1]+=dp[i])%=MOD;
			(dp[nxt[i+1]]+=dp[i])%=MOD;
		}
		int ans=0;
		for(int i=n,j=0;i>0;i--){
			if(j%3==0)ans=(ans+dp[i])%MOD;
			j+=s[i]=='a'?1:2;
		}
		printf("%d",ans);
	}
}


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

using namespace std;

constexpr int MOD = 1000000007;

using Long = long long;
template<typename T>
using V = vector<T>;
template<typename T>
using Vv = V<V<T>>;
using Vb = V<bool>;
using Vvb = V<Vb>;
using Vi = V<int>;
using Vvi = V<Vi>;
using Vl = V<Long>;
using Vvl = V<Vl>;
using Vd = V<double>;
using Vvd = V<Vd>;
using Vs = V<string>;

template <typename First, typename Second>
istream& operator>>(istream& is, pair<First, Second>& v);

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template <typename First, typename Second>
istream& operator>>(istream& is, pair<First, Second>& v) {
    is >> v.first >> v.second;
    return is;
}

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

// *** SOLUTION BEGIN ***

void solve() {
    int n;
    cin >> n;
    Vi a(n);
    cin >> a;
    sort(begin(a), end(a));
    int m = a.back();
    a.pop_back();
    int best = a.front();
    for (int x : a) {
        if (abs(2LL * x - m) < abs(2LL * best - m)) {
            best = x;
        }
    }
    cout << m << ' ' << best;
}

// *** SOLUTION END ***

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


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <bitset>
using namespace std;
#define ll long long
const ll N = 4e3+507;
ll n,i,j,dif,excl,r[N],g[N],b[N],k,k1,k2,perechi;
string s;
bitset <N> f;
int main()
{
    cin>>n>>s;
    for (i=0;i<s.size();++i)
    {
        if (s[i]=='R') r[++k]=i+1;
        else if (s[i]=='G') g[++k1]=i+1;
        else if (s[i]=='B') b[++k2]=i+1,f[i+1]=1;
    }
    for (i=1;i<=k;++i)
    {
        for (j=1;j<=k1;++j)
        {
            excl=0;
            if (g[j]<r[i])
            {
                dif=r[i]-g[j];
                if (g[j]-dif>0 && f[g[j]-dif]) excl++;
                if (r[i]+dif<=n && f[r[i]+dif]) excl++;
                if ((r[i]+g[j])%2==0 && f[(r[i]+g[j])/2]) excl++;
            }
            else if (g[j]>r[i])
            {
                dif=g[j]-r[i];
                if (r[i]-dif>0 && f[r[i]-dif]) excl++;
                if (g[j]+dif<=n && f[g[j]+dif]) excl++;
                if ((r[i]+g[j])%2==0 && f[(r[i]+g[j])/2]) excl++;
            }
            perechi=perechi+(k2-excl);
        }
    }
    cout<<perechi<<"\n";
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

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

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >>  m2 >> k;

    int diff = (60*h2+m2)-(60*h1+m1);
    out(diff-k);
}


Measured memory_bytes: 3584
def check():
    N = int(input())
    A = [int(input()) for i in range(N)]
    flag = [0]* N
    count = 0
    
    posi = A[0]
    flag[0] = 1

    while 1:
        flag[posi-1] = 1
        count += 1
        if posi == 2:
            return count
        posi = A[posi-1]
        if flag[posi-1] == 1:
            return -1
print(check())

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

int main(){
    int A,B;
    cin >> A >> B;
    if ( (A<1)|| (A>9)) cout << "-1" << endl;
    else if ((B<1)|| (B>9)) cout << "-1" << endl;
    else cout << A * B << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int N,x,y;
	cin>>N;


	if(N>=15){
	x=N*800;
	y=(N/15)*200;
	
		cout<<x-y;
}
	else{
		x=N*800;
	y=0;
	cout<<x-y;
}
}

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

int main() {

int A,B,C,D;
int X,Y;
cin >> A >> B >> C >> D;

X = (A + D -1)/ D;
Y = (C + B -1)/ B;

if (X >= Y){
    cout << "Yes" << endl;
}
else
{
     cout << "No" << endl;
}




}


Measured memory_bytes: 3632
S = input()
N = len(S)

R = [0]*N  # 最初に R にいた子供の最終位置を格納する
L = [0]*N  # 最初に L にいた子供の最終位置を格納する（解法をわかりやすくするために用意したけど、Rだけでも答えは保持できる
A = [0]*N  # 回答 A[x] = R[x] + L[x]

# 連続する R の位置を左から右に数える
count = 0
for i in range(N):
    if S[i] == 'R':
        count += 1
    else: # S[i] == 'L'
        if count > 0: # L が連続するケースでは count==0 となる
            q, r = divmod(count, 2)
            R[i-1] = q + r
            R[i] =  q

            # L で途切れたのでクリア
            count = 0

# 連続する L の位置を右から左に数える(逆順)
count = 0
for i in range(N)[::-1]:   # range(N) の逆順を取り出す書き方 [N-1, N-2, ... 0] になる
    if S[i] == 'L':
        count += 1
    else: # 'R'
        if count > 0:
            q, r = divmod(count, 2) # 現在位置は R で RLの R の位置なので
            L[i] = q            #
            L[i+1] =  q + r     # i-1じゃなくて、i+1になる
                                # R[i] と R[i+1]に足しこんでも構わない

            # R で途切れたのでクリア
            count = 0

# L と R を足してあげる(Rに回答を保持するなら、AとLは不要）
for i in range(N):
    A[i] = L[i]+R[i]

print(*A) # print(A[0], A[1]...) と同じ



Measured memory_bytes: 8056
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}
string S;
int L,i;
map<char,int> cnt;
inline void solve(){
  IN(S);
  L=S.size();
  REP(i,L)cnt[S[i]]++;
  REP(i,L)if(cnt[S[i]]>1){
    OUT("no");
    return;
  }
  OUT("yes");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int A[100002];
int gcdL[100002];
int gcdR[100002];

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

int main(void) {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];

  gcdL[0] = gcdR[N+1] = 0;

  for (int i = 1; i <= N; i++) {
    gcdL[i] = gcd(gcdL[i-1], A[i]);
  }
  for (int i = N; i >= 1; i--) {
    gcdR[i] = gcd(gcdR[i+1], A[i]);
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = max(ans, (gcd(gcdL[i-1], gcdR[i+1])));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 100100;

int a[MAX];

int main(void) {
  int N;
  scanf("%d", &N);
  REP(i, N) scanf("%d", &a[i]);

  sort(a, a + N);
  vector<pair<int, int>> v;
  int i = 0;
  while (i < N) {
    int j = i;
    while (j < N && a[j] == a[i]) j++;
    v.push_back({a[i], j-i});
    i = j;
  }

  int n = v.size();
  int pos = N;
  int last_double = N+1;
  FOR(i, 1, n) {
    pos -= v[i-1].second;
    int last_left = (v[i-1].second % 2) ^ 1;
    int last_up = ((v[i].first - v[i-1].first + 1) % 2);
    if (last_left == 0 && last_up == 1) {
      int doubl = pos - 1 - (v[i-1].first - 1);
      if (doubl > 0) last_double = min(last_double, doubl);
    }
    if (last_left == 1 && last_up == 0) {
      int doubl = pos - (v[i-1].first - 1);
      if (doubl > 0) last_double = min(last_double, doubl);
    }
  }

  if (last_double == N+1) {
    if (v[0].first % 2) {
      last_double = N+1;
    } else {
      last_double = N;
    }
  }

  if (last_double % 2) {
    puts("First");
  } else {
    puts("Second");
  }
  return 0;
}


Measured memory_bytes: 1784
//
//  main.cpp
//  ALDS1_1-B
//
//  Created by Saicj on 2015/08/31.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
//#include <vector>
#include <algorithm>

namespace Function {
    
    int gcd( int m, int n )
    {
        // ?????°?????????????????´??????????????????
        if ( ( 0 == m ) || ( 0 == n ) )
            return 0;
        
        // ???????????????????????????
        while( m != n )
        {
            if ( m > n ) m = m - n;
            else         n = n - m;
        }
        return m;
    }//gcd
}

int main() {
    
    int x, y;
    std::cin >> x >> y;
    
    printf("%d\n", Function::gcd(x, y));
    
    return 0;
}

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

using namespace std;

int main() {
    vector<int> stones;
    vector<int> energyReq;
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        int h;
        cin >> h;
        stones.push_back(h);
    }
    energyReq.push_back(0);
    for (int i = 1; i < n; i++){
        int minE = INT32_MAX;
        for (int j = 1; j <= min(i, k); j++){
            minE = min(minE, energyReq[i - j] + abs(stones[i] - stones[i - j]));
        }
        energyReq.push_back(minE);
    }
    cout << energyReq.at(n - 1) << endl;
    return 0;
}


Measured memory_bytes: 1400
from sys import exit
S = input()
#0回判定
x = len(S)
if S.count("B") == x or S.count("W") == x:
    print(0)
    exit()



cntw=0
for s in S.split("W"):
    if s:
        cntw += 1
cntb=0
for s in S.split("B"):
    if s:
        cntb += 1
print(abs(cntb - cntw) + min(cntb, cntw) * 2 - 1)

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  map <int, int> frec;
  for (int i = 0; i < n; i++) {
    int elem;
    cin >> elem;
    frec[elem]++;
  }
  vector <pii> arr;
  for (auto pp: frec) arr.pb(pp);
  int cnt = 0;
  int ans = 0;
  for (int i = 0; i < sz(arr); i++) {
    cnt += arr[i].second;
    if (n / 2 == cnt) {
      ans = arr[i + 1].first - arr[i].first;
    }
  }
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);    

    int n; cin>>n;
    vector<P> xy(n);
    rep(i,n)cin>>xy[i].first>>xy[i].second;
    sort(all(xy));

    map<P,int> mp; 
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            mp[P(xy[i].first-xy[j].first,xy[i].second-xy[j].second)]++;
        }
    }

    int ans=0;
    for(auto i:mp){
        // cout<<i.first.first<<' '<<i.first.second<<endl;
        chmax(ans,i.second);
    }
    cout<<n-ans<<endl;

}

Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        long[] a = new long[n];
        for(int i = 0; i < n; i++){
            a[i] = scan.nextLong();
            if(a[i] == 0){
                System.out.println(0);
                return;
            }
        }
        long out = 1;
        for(int i = 0; i < n; i++){
            if(a[i] <= 1000000000000000000L / out) out *= a[i];
            else{
                System.out.println(-1);
                return;
            }
        }
        if(out > 1000000000000000000L) System.out.println(-1);
        else System.out.println(out);
        scan.close();
    }
}

Measured memory_bytes: 50748
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
//priority_queue
#include<list>
#include<forward_list>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<iterator>
#include<complex>//.real.imag
#define rep(i,a,n) for(int i=a;i<n;++i)
#define repd(i,a,n) for(int i=a;i<=n;++i)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define rbf(elem,a) for(auto elem:a)
#define MAXI INT_MAX
#define MINI INT_MIN
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1000005;
bool isprime(ll num){if(num == 1)return 0;if(num == 2 || num == 3)return 1;if(num % 6 != 1 && num % 6 != 5)return 0;ll t = sqrt(num);for(ll i = 5; i <= t; i += 6){if(num % i == 0 || num % (i + 2) == 0)return 0;}return 1;}
ll powmode(ll base, ll index, ll mode){ll result = 1;while(index){if(index & 1){result = (result * base) % mode;index--;}index >>= 1;base = (base * base) % mode;}return result;}
int gcd(int x,int y){if(x<y) return gcd(y,x);if(y==0) return x;else{if(!(x%2)){if(!(y%2))return 2*gcd(x>>1,y>>1);else return gcd(x>>1,y);}else{if(!(y%2))return gcd(x,y>>1);else return gcd(y,x-y);}}}
int lcm( int a, int b){return a/gcd(a,b)*b;}
using namespace std;
int a[MAXN];
int presum[MAXN];
int dum[MAXN];
int main()
{
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    ios::sync_with_stdio(false);
    int n,sum=0;
    cin>>n;
    repd(i,1,n)
    {
    	char xx;
    	cin>>xx;
    	a[i]=(xx=='.'?0:1);

    }
    for(int i=1;i<=n;++i)
    {
        presum[i]=presum[i-1];
        if(!a[i])presum[i]++;
    }
    for(int i=n;i>=0;--i)
    {
        dum[i]=dum[i+1];
        if(a[i])dum[i]++;
    }
    repd(i,1,n)
    {
        sum=max(sum,dum[i]+presum[i]);
    }
    cout<<n-sum<<endl;
    return 0;
}

Measured memory_bytes: 9216
def func():
    S = input()
    K = int(input())

    Slen = len(S)

    ans = 1
    for i in range(K):
        if i == Slen:
            break

        if S[i] != "1":
            ans = S[i]
            break

    print(ans)


if __name__ == '__main__':
    func()


Measured memory_bytes: 2940
from collections import Counter
N, X, Y = map(int, input().split())
cnt = []

for i in range(1, N):
    for j in range(i+1, N+1):
        cnt.append(min(j-i, abs(X-i)+abs(Y-j)+1))

cnt = Counter(cnt)
for i in range(1, N):
    print(cnt[i])



Measured memory_bytes: 73212
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] p = Enumerable.Repeat(0, n).Select(_ => int.Parse(Console.ReadLine())).ToArray();

        int[] index = new int[p.Length];
        for (int i = 0; i < p.Length; i++)
        {
            index[p[i] - 1] = i;
        }
        //ある中心から順々に下ってる場合は嬉しい
        //中心の数字を決めます
        //中心の数字から上が全て順、または下が全て順であれば、逆側をもう一度やり直すだけ
        //それより上が順だったら?一番上を中心にすればいいだけ
        //昇順の最大まで求める

        //前より後ろよりを組み合わせると効率的にできる?
        //真ん中の方の連続列でもOK 連続列ならね
        //LIS(only +1)
        int count = 1;
        int max = 0;
        for (int i = 1; i < index.Length; i++)
        {
            if (index[i - 1] > index[i])
            {
                max = Max(max, count);
                count = 0;
            }
            count++;
        }
        max = Max(max, count);
        Console.WriteLine(n - max);
    }
}

Measured memory_bytes: 18524
import java.util.*;
import java.util.stream.IntStream;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[][] A = new int[N][3];
    int[][] dp = new int[N][3];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 3; j++) {
        A[i][j] = sc.nextInt(); 
      }
    }
    for (int i = 0; i < 3; i++) {
      dp[0][i] = A[0][i]; 
    }
    for (int i = 1; i < N; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          if (j == k) continue;
          dp[i][j] = Math.max(dp[i][j], A[i][j] + dp[i-1][k]);
        }
      }
      //System.out.println(Arrays.toString(dp[i]));
    }
    System.out.println(IntStream.of(dp[N-1]).max().getAsInt());
  }
}

Measured memory_bytes: 104652
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  bool check=false;
  int length= 0;
  int now=0;
  for(int i=0;i<str.size();i++){
    if(str.at(i)=='A' || str.at(i)=='C' || str.at(i)=='G' || str.at(i)=='T'){
      check = true;
    }else{
      check = false;
    }
      
    if(check){
      now++;
      if(length < now){
        length = now;
      }
    }else{
      now=0;
    }
  }
   
  cout << length << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int MAX = 3000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
void COMint(){ //前処理
    fac[0]=fac[1]=1; //階乗
    finv[0]=finv[1]=1; //階乗の逆元
    inv[1]=1; //逆元

    for(int i=2;i<MAX;i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD % i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}
ll COM(int n, int k){ //二項係数の計算
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD; // n! * (k!)^-1 * ((n-k)!)^-1
}
int main(){
    COMint();
    int n,k; cin >> n >> k;
    for(int i=1;i<=k;i++){
        cout << COM(k-1,i-1)*COM(n-k+1,i) % 1000000007 << endl;
    }
    return 0;
}

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

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

  int answer = 0;
  while(s > 0){
      answer += s % 10; //sの下1桁が1なら加える
      s /= 10; //sの数字の桁を下に一つずらす
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;


int main(){
    ll N, A, B; cin >> N >> A >> B;
    vector<ll> h(N);
    ll max_value = 0;
    rep(i,N) {
        cin >> h[i];
        max_value = max(max_value, h[i]);
    }
    ll ok = (max_value + B)/B;
    ll ng = 0;
    
    while(abs(ok-ng)>1){
        ll mid = (ok+ng) / 2;
        ll cnt = 0;
        rep(i,N){
            ll diff = (A-B);
            cnt += max(0LL, (h[i]-B*mid+(diff-1))/diff);
        }
        if (cnt <= mid) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 (b<a) { a=b; return 1; } return 0; }



i64 n, a[101010];
void solve(){
	cin >> n;
	bool ok = 0;
	i64 ans = 1;
	double d = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] == 0){
			ok = 1;
		}
		else{
			ans *= a[i];
			d += log10(a[i]);
		}
	}
	if(ok){
		cout << 0 << endl;
		return;
	}
	if(d > 18){
		cout << -1 << endl;
		return;
	}
	if(ans > 1000000000000000000){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 4756
# coding:utf-8
danmen = input()
S1 = []
S2 = []
area = 0 # ?????????????°´???????????¢???

for i, line in enumerate(danmen):
    if line == '\\':
        S1.append(i)
    elif S1 and line == '/':
        loc = S1.pop()
        area += i-loc

        pond_sum = i-loc
        while S2 and S2[-1][0] > loc:
            pond_sum += S2[-1][1]
            S2.pop()

        S2.append([loc,pond_sum])


print(area)
print(len(S2),*(a for j,a in S2))

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

#define ll long long
#define str string

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

vector <ll> v;
ll Y[10000000] = {}, X[10000000] = {},m = 0,a = 0,b = 0,n = 0, x = 0,y = 0,sum = 0;
str H[100][100] = {};
str S,Sa;
bool ans = false;

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
		//Code Line
cin >> x;
if(x % 4 == 0 || x % 7 == 0 || x % 11 == 0)cout << "Yes" << endl;
else{
	for(int i = x;i >= 0;i -= 4){
	if(i % 7 == 0)ans = true;
	if(i % 11 == 0)ans = true;
	}
	for(int i = x;i >= 0;i -= 7){
	if(i % 4 == 0)ans = true;
	if(i % 11 == 0)ans = true;
	}
	for(int i = x;i >= 0;i -= 11){
	if(i % 4 == 0)ans = true;
	if(i % 7 == 0)ans = true;
	}
	if(ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}

		//Code Line
return 0; 
}


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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

int n, k;

inline void input()
{
	n = read<int>(), k = read<int>();
}

inline void solve()
{
	printf("%d\n", (n - 1 + k - 2) / (k - 1));
}

int main()
{
//	freopen("C.in", "r", stdin);
//	freopen("C.out", "w", stdout);

	input();
	solve();

	return 0;
}



Measured memory_bytes: 256
using System;

class p
{
    static void Main(string[] args)
    {
        long ans = -10000000000;
        long min = 10000000000;
        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            long R = long.Parse(Console.ReadLine());
            if (min > R)
            {
                ans = Math.Max(ans, R - min);
                min = R;
            }
            else
            {
                ans = Math.Max(ans, R - min);
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 9216
n = int(input())
a = list(map(int,input().split()))
ans = 1
d = 0
for i in range(1,n):
    diff = a[i]-a[i-1]
    if d == 0:
        d = diff
    elif d*diff < 0:
        d = 0
        ans += 1
print(ans)

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

long long minm(long long a,long long b)
  {
  if(a<b)
    return a;
  else return b;
  }
int main()
  {
  int n;cin>>n;
  long long sum=0,a[n];
  for(int i=0;i<n;i++)
    {
    cin>>a[i];
    }
  sort(a,a+n);
  sum+=a[n-1];
  int i=n-2,j=0,k=1;
  while(i>0)
  {
    sum+=(a[i]);
    j++;
    if(j==2) i--,j=0;
    k++;
    if(k==n-1) break;
  }
  cout<<sum;
  }


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

int main() {
 // bool ans = true;
  string s; cin >> s;
  if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
    
}

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

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

	int q;cin>>q;
	while(q--){
		int b,e;cin>>b>>e;
		reverse(next(a.begin(),b), next(a.begin(),e));
	}

	bool isFirst=true;
	for(auto &&ai: a){
		if(!isFirst) cout<<" ";
		cout<<ai;
		isFirst &= false;
	}
	cout<<endl;
  return 0;
}



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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  A = (A == 1) ? 14 : A;
  B = (B == 1) ? 14 : B;
  if (A > B) {
    cout << "Alice";
  } else if (B > A) {
    cout << "Bob";
  } else {
    cout << "Draw";
  }
  return 0;
}


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

int d[6][10] = {
	{0,1,2,3,4,5,6,7,8,9},
	{0,10,7,4,1,11,8,5,2,12},
	{0,9,5,1,10,6,2,11,7,3},
	{0,12,11,10,9,8,7,6,5,4},
	{0,3,6,9,12,2,5,8,11,1},
	{0,4,8,12,3,7,11,2,6,10}
};

vector<int> dp = { 1,0,0,0,0,0,0,0,0,0,0,0,0 };
vector<int> buf;

void ad(int p, int n) {
	int t = d[p][n];
	for (int i = 0; i < 13; i++) {
		buf[(i + t) % 13] = (buf[(i + t) % 13] + dp[i]) % 1000000007;
	}
}

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

	for (int i = 0; i < s.size(); i++) {
		buf = vector<int>(13);
		int p = (s.size() - i - 1) % 6;
		char c = s[i];
		if (c == '?') {
			for (int n = 0; n < 10; n++)
				ad(p, n);
		}
		else {
			ad(p, c - '0');
		}
		dp = move(buf);
	}

	cout << dp[5] << endl;

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    char ch[213];
    scanf("%s",ch);
    int cnt=0;
    for(register int i=0;i<strlen(ch);i++){
        if(ch[i]=='1'){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256