akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from itertools import combinations
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
count=0
for x,y in combinations(X,2):
    r = np.sqrt(sum(abs(np.array(x)-np.array(y))**2))
    if r.is_integer() == True:
        count += 1
print(count)

Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll min3(ll a, ll b, ll c){
    if(a < b){
        if(b < c) return a;
        else{
            if(a < c) return a;
            else return c;
        }
    }else{
        if(b < c) return b;
        else return c;
    }
}

int main(){
    ll h,w; cin >> h >> w;
    ll c[h][w];
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    ll dp[h+1][w+1] = {};
    rep(i,h){
        rep(j,w){
            if(c[i][j] == 1) dp[i+1][j+1] == 0;
            else{
                dp[i+1][j+1] = min3(dp[i][j],dp[i][j+1],dp[i+1][j]) + 1;
            }
        }
    }
    ll mx = 0;
    rep(i,h+1){
        rep(j,w+1){
            if(mx < dp[i][j]) mx = dp[i][j];
        }
    }
    cout << mx*mx << endl;
}


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

#define ll long long
#define ar array

int main() {

    ios::sync_with_stdio(false);
	
	int n, t, menor, resposta;
	vector<pair <int, int>>caminho;
	
	pair<int, int> par;
	
	cin >> n >> t;
	
	while(n > 0){
		cin >> par.first >> par.second;
		caminho.push_back(par);
		--n;
	}
	sort(caminho.begin(), caminho.end());
	
	for(int i = 0; i < caminho.size(); i++){
	    if(caminho[i].second <= t){
	        cout << caminho[i].first << endl;
	    return 0;
	    }
	}
	cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 5e6 + 17;

struct pt
{
	int x, y;
	pt() { }
};

int H[maxn], F[maxn], used[maxn];

struct hash_table
{
	hash_table() { }

	int getpos(int h) const
	{
		int i = h % maxn;
		for (; used[i] && H[i] != h; ++i) if (i == maxn) i = 0;
		return i;
	}

	int& operator[](int h)
	{
		int i = getpos(h);
		H[i] = h;
		used[i] = 1;
		return F[i];
	}
};

struct fenwick
{
	int n;
	hash_table F;

	fenwick() { n = inf; }

	void upd(int i, int x)
	{
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	}

	int get(int i)
	{
		int res = 0;

		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);

		return res;
	}
};

int n;
pt s, f;
pt p[maxn];

bool read()
{
	if (scanf("%d %d %d %d %d", &s.x, &s.y, &f.x, &f.y, &n) != 5)
		return false;

	forn (i, n)
		scanf("%d %d", &p[i].x, &p[i].y);

	return true;
}

bool cmp(pt a, pt b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); }

void solve()
{
	if (s.x > f.x)
		swap(s, f);

	if (s.y > f.y)
	{
		f.y = 2 * s.y - f.y;

		forn (i, n)
			p[i].y = 2 * s.y - p[i].y;
	}

	vector<pt> pp;

	forn (i, n)
		if (s.x <= p[i].x && p[i].x <= f.x && s.y <= p[i].y && p[i].y <= f.y)
			pp.push_back(p[i]);

	sort(pp.begin(), pp.end(), cmp);
	fenwick dp;

	forn (i, size(pp))
		dp.upd(pp[i].y, dp.get(pp[i].y) + 1);

	int lis = dp.get(inf);
	long double ans = 0;

	if (lis != min(f.y - s.y, f.x - s.x) + 1)
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * lis;
	else
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * (lis - 1) + 10 * M_PI;

	printf("%.15f\n", (double) ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 62320
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
x, y = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

#a+b=x
#2*a+4*b=y
#2*a+2*b=2*x

b = y/2-x
a = 2*x-y/2

if b >= 0 and b == int(b) and a >= 0 and a == int(a):
    print('Yes')
else:
    print('No')

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

int main() {
  int a,b,c,d,i;
  cin >> a >> b >> c >> d;
  
  do{
    c = c-b;
    if(c<=0){
      cout << "Yes" << endl;
      break;
    }
    a=a-d;
    if(a<=0){
      cout << "No" << endl;
      break;
    }
  }while(a>0 || d>0);
  
} 

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int n;
	cin >> n;
	int a[25], b[25], c[25];
	REP(i, n) cin >> a[i];
	REP(i, n) cin >> b[i];
	REP(i, n - 1) cin >> c[i];
	int ans = 0;
	REP(i, n){
		if (i != 0) {
			if (a[i - 1] == a[i] - 1) ans += c[a[i - 1] - 1];
		}
		ans += b[a[i] - 1];
	}
	cout << ans << endl;
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
map<char,vector<char>> valid_next;
map<char,vector<char>> valid_ender;
bool next_string(string& s, int& i, string x)
{
    if(!(i+x.length()-1 < s.length()))
        return false;
    else
        return s.substr(i,x.length())==x;
}
bool verify(string& s)
{
    reverse(s.begin(),s.end());
    for(int i = 0; i < s.length(); i++)
        if(s[i]=='m')
        {
            if(next_string(s,i,"maerd"))
                i += 4;
            else
                return false;
        }
        else if(s[i]=='e')
        {
            if(next_string(s,i,"esare"))
                i += 4;
            else
                return false;
        }
        else if(s[i]=='r')
        {
            if(next_string(s,i,"remaerd"))
                i += 6;
            else if(next_string(s,i,"resare"))
                i += 5;
            else
                return false;
        }
        else
            return false;
    return true;
}
int main()
{
    string s; cin >> s;
    cout<<(verify(s) ? "YES" : "NO")<<endl;
    return 0;
}

Measured memory_bytes: 512
# ABC 085 C Otoshidama
N, Y = map(int,input().split())

def solve(N, Y):
    for x in range(N+1):
        for y in range(N-x+1):
            z = N-(x+y)
            if (x * 10000 + y * 5000 + z * 1000 == Y):
                return x, y, z
            
    return -1, -1, -1

x, y, z = solve(N,Y)

print("%d %d %d" % (x,y,z))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define INF 10000000000000
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define BS binary_search
#define N 100005

void solve()
{
	int n;cin>>n;
	int h[n+1];
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	int dp[n+1]={0};
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n]<<endl;
}
 
int32_t main()
{
   	int tc=1;
   	//cin>>tc;
   	while(tc--){
   		solve();
   	}
}


Measured memory_bytes: 1792
/*
	0216:Cutting Down Water Bills
*/
#include	<iostream>

using namespace std;

int main(void) {
	int w;
	while(1){
		cin >> w;
		if(w == -1) { break; }
		
		int m = 1150;
		w -= 10;
		for(int i = 0; i < 10 && w > 0; i++, w--){
			m += 125;
		}
		for(int i = 0; i < 10 && w > 0; i++, w--){
			m += 140;
		}
		for(w; w > 0; w--){
			m += 160;
		}
		cout << 4280 - m << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
x=list(input())
cnt=Counter(x)
x2=int("".join(x),2)
one=cnt["1"]
# print(x)
# print(math.log2(2*10**5))
# print(cnt)
# print(x2,one)
lst=[0]*(2*10**5+10)
# lst[0]=-1
flaglst=[0,0]
if one-1!=0:
    flaglst[0]=x2%(one-1)
flaglst[1]=x2%(one+1)
# print(flaglst)

for i in range(2*10**5):
    now=i+1
    ans=0
    while now:
        cnt2=0
        m=0
        while now>=pow(2,m):
            if now&1<<m:
                cnt2+=1
            m+=1
        now%=cnt2
        ans+=1
    lst[i+1]=ans
# # print(lst[:100])

for i in range(n):
    tmp=0
    if x[i]=="1":
        tmp=flaglst[0]
        if one-1!=0:
            tmp-=pow(2,n-1-i,one-1)
            tmp%=one-1
        else:
            print(0)
            continue
    else:
        tmp=flaglst[1]
        tmp+=pow(2,n-1-i,one+1)
        tmp%=one+1
    # print(tmp,pow(2,n-1-i),one)

    print(lst[tmp]+1)

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int num_divisors = 0;
	for (int i = a; i <= b; ++i) {
		if (c % i == 0) {
			++num_divisors;
		}
	}
	cout << num_divisors << endl;
}


Measured memory_bytes: 3088
A=int(input())
B=int(input())
C=int(input())
X=int(input())
a=0
b=0
Counter=0
while a<=A:
  while b<=B:
    if 0<=X-500*a-100*b<=50*C:
      Counter+=1
    b+=1
  b=0  
  a+=1
print(Counter)  

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

using namespace std;

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

int main(){
    while(1){
        int a,b;
        cin >> a >> b;
        if(a == 0 && b == 0)break;
        else cout << min(a,b) << " " << max(a,b) << endl;
    }

    return 0;
}



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


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    def f(n):
        n = str(n)
        for ss, cc in zip(s, map(str, c)):
            if n[ss-1] != cc:
                return False
        return True
    if any(map(lambda ss: ss > N, s)):
        return -1
    if N == 1:
        return min(filter(f, range(10)), default=-1)
    return min(filter(f, range(10**(N-1), 10**N)), default=-1)


# Generated by 1.1.6 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()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    print(solve(N, M, s, c))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] Healths = new int[n];
        for(int i = 0; i < n; i++) {
            Healths[i] = in.nextInt();
        }
        Arrays.sort(Healths);
        long ans = 0;
        for(int i = 0; i < n - k; i++) {
            ans += Healths[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 66140
#include<stdio.h>
#include<string.h>
int main()
{
    char s[20];
    int i;
    scanf("%s",s);
    for(i=0; i<strlen(s); i++)
    {
        if(s[i]==',')
        {
            s[i]=' ';
        }
    }
    printf("%s",s);
    return 0;
}


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

using namespace std;

int n,ans = 0,d = 0;
string str;

int main(){
    cin >> n;
    cin >> str;
    for(int i = 0;i < n; i++){
        if(str[i] == 'I'){
            d++;
        }else if(str[i] == 'D'){
            d--;
        }
        if(ans < d) ans = d;
    }
    cout << ans << endl;

    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }



void func(long long S, long long W){

    if(S>W)cout<<"safe"<<endl;
    else cout<<"unsafe"<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);
    func(S, W);
    return 0;
}


Measured memory_bytes: 3708
using System;
using System.Text;

public class Test
{
	static public void Main( )
	{
		StringBuilder output = new StringBuilder();
		while( true ) {
			int[] nm = Array.ConvertAll( Console.ReadLine().Split( ' ' ), int.Parse );
			int n = nm[0];
			int x = nm[1];
			
			if( 0 == n && 0 == x ) { break; }
			
			int cnt = 0;
			for( var i=1; i<n; i++ ) {
				for( var j=i+1; j<=n; j++ ) {
					var k = x-i-j;
					if( i < k && k < j && 0 < k && k < n ) { cnt++; }					
				}
			}
			output.AppendLine( cnt.ToString() );
		}
		Console.Write( output );
	}
}

Measured memory_bytes: 19968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  string s;
  cin >> s;
  cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14) << endl;

}

Measured memory_bytes: 256
import java.util.*

val sc = Scanner(System.`in`)
val A = sc.nextInt()
val B = sc.nextInt()
val C = sc.nextInt()

fun main(args: Array<String>) {
    println(if (judge()) "YES" else "NO")
}

fun judge(): Boolean {
    for (i in 0 until B) {
        if (A * i % B == C) {
            return true
        }
    }
    return false
}


Measured memory_bytes: 31264
def main():
    import sys
    X,K,D=list(map(int,sys.stdin.readline().split()))
    X=abs(X)
    if X-K*D>=0:
        print(X-K*D)
    else:
        count=X//D
        now=X%D
        if (K-count)%2==0:
            print(now)
        else:
            print(abs(now-D))

main()

Measured memory_bytes: 61860
#include<iostream>
#include<vector>
#include<queue>
#define inf 1e18
#define end(a) {cout<<a;return 0;}
using namespace std;
vector<pair<int,int> > v[100005];
long long dp[100005];
int n,m;
void dpinf(void)
{
	for(int i=0;i<n;i++)
		dp[i]=inf;
}
void ready(void)
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,d;
		cin>>l>>r>>d;
		l--;
		r--;
		v[l].push_back({r,d});
		v[r].push_back({l,-d});  
	}
	dpinf();
}
int main(){
	ready();
	for(int i=0;i<n;i++)
	{
		if(dp[i]==inf)
		{
			queue<int> q;
			q.push(i);
			dp[i]=0;
			while(!q.empty())
			{
				int k=q.front();
				q.pop();
				for(int j=0;j<v[k].size();j++)
				{
					pair<int,int> p=v[k][j];
					int to=p.first,dis=p.second;
					if(dp[to]==inf)
					{
						dp[to]=dp[k]+dis;
						q.push(to); 
					}
					else if(dp[to]!=dp[k]+dis)
						end("No");
				}
			}
		}
	}
	end("Yes");
}

Measured memory_bytes: 9728
#ARC080-C
n = int(input())
a = list(map(int,input().split()))

four = 0
even = 0
odd = 0
for i in a:
    if i%4 == 0:
        four += 1
    elif i % 2 == 0:
        even += 1
    else:
        odd += 1

if even > 0 and even % 2 == 1:
    odd += 1
    
if four + 1 >= odd:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
n = int(input())
v = list(map(int, input().split()))

even = {}
odd = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] not in even:
            even[v[i]] = 0
        even[v[i]] += 1
    else:
        if v[i] not in odd:
            odd[v[i]] = 0
        odd[v[i]] += 1

even_sorted = sorted(even.items(), key=lambda x:x[1])[::-1]
odd_sorted = sorted(odd.items(), key=lambda x:x[1])[::-1]

ans = 0
if even_sorted[0][0] != odd_sorted[0][0]:
    ans += n - even_sorted[0][1] - odd_sorted[0][1]
else:
    if len(even_sorted) == 1 or len(odd_sorted) == 1:
        even_sorted.append((-1, 0))
        odd_sorted.append((-1, 0))
    x = n - even_sorted[0][1] - odd_sorted[1][1]
    y = n - even_sorted[1][1] - odd_sorted[0][1]
    ans += min(x, y)

print(ans)

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

int main(void) {
    int n, k;
    string s;
    cin >> n >> s >> k;

    char c = s[k - 1];

    for (int i = 0; i < n; i++) {
        if (s[i] != c) {
            s[i] = '*';
        }
    }
    cout << s << endl;
    return 0;
}

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

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

using namespace std;





int main()
{
	string s;
	while(cin >>s){
	
		bool ok=0;
		rep(i,10){
			auto w=s;
			replace(w.begin(),w.end(),'X',char(i+'0'));
			rep(j,10){
				string no = string(1, char(j+'0'));
				if( w.find("+0"+no)!=-1 || w.find("=0"+no)!=-1) w="00";
				if(w[0]=='0' && w[1]==char(j+'0')) w="00";
			}
			if(w=="00") continue;
			
			//cout << w << " :: ";
			int64_t sm=0, sm2=0;
			for(auto x: w){
				if(isdigit(x)) sm2=sm2*10+x-'0';
				else{
					sm += sm2;
					sm2 = 0;
				}
			}
			//cout <<sm <<"  "<<sm2 <<"\n";
			if(sm == sm2){
				cout << i << "\n";
				ok=1; break;
			}
		}
		if(!ok) cout <<"NA\n";
	
	}
	
	return 0;

}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	double ans=0,k=380000;
	rep(i,n){
		double a;string s;cin >> a >> s;
		if(s=="JPY") ans+=a;
		else ans+=a*k;
	}
	cout << fixed << setprecision(20) << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main(){
	int l;
	cin >> l;
	int n = log2(l) + 1;
	cout << n << " ";
	vector<P> ans;
	int memo = 0, cnt = 0;
	REP(i, n - 1) {
		ans.push_back(make_pair(i, 0));
		ans.push_back(make_pair(i, ((ll)1 << (i - 1))));
		memo += 2;
	}
	for (int i = n - 1; i >= 1; i--) {
		if (l - ((ll)1 << (i - 1)) >= ((ll)1 << (n - 1))) {
			ans.push_back(make_pair(i, l - ((ll)1 << (i - 1))));
			l -= (ll)1 << (i - 1);
			cnt++;
		}
	}
	cout << memo + cnt << endl;
	rep(i, memo)cout << ans[i].first << " " << ans[i].first + 1 << " " << ans[i].second << endl;
	for (int i = memo; i < memo + cnt; i++)cout << ans[i].first << " " << n << " " << ans[i].second << endl;
	return 0;
}

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

int main(){
    int n,meiyong;
    cin>>n>>meiyong;
    string s[101];
    for(int i=0;i<n;++i){
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;++i){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

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

#define N (1<<17)
#define ll long long
#define ld long double
#define M 1000000007
#define INF 1000000007
#define LINF 1000000000000000007LL
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second
#define L length() - 1

using namespace std;

int main () {
    ll n;
    cin>>n;
    ll s = 0;
    ll v[n];
    ll mi = LINF;
    ll ma = 0;
    for (int i = 0; i < n; i++) {
        cin>>v[i];
        s += v[i];
        ma = max(ma, v[i]);
        mi = min(mi, v[i]);
    }

    ll t = s / (n * (n + 1) / 2);
    if (s % (n * (n + 1) / 2) || mi < t || ma > n * t) {
        cout<<"NO"<<endl;
        return 0;
    }
    for (ll i = 0; i < n; i++) {
        v[i] -= t * (i + 1);
        v[i] %= n;
        v[i] += n;
        v[i] %= n;
    }
    bool b = true;
    for (ll i = 1; i < n; i++) {
        b = b & (v[i] == v[i - 1]);
    }
    if (b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 1024
num_args = int(input())
input_list = input().split(" ")
input_list = [ int(i) for i in input_list]

min_input = input_list[0]
max_input = input_list[0]

for i in input_list[1:num_args]:
  if i < min_input:
    min_input = i
  elif i > max_input:
  	max_input = i
    
print(abs(max_input-min_input))

Measured memory_bytes: 3060
#include <iostream>
long long int j[100001];
long long int k[100001];
int main() {
	int n, w;
	std::cin >> n >> w;
	int x, y;
	for (int q = 0; q < n; q++) {
		std::cin >> x >> y;
		for (int e = x; e <= w; e++) {
			if (k[e - x] + y > k[e])
				j[e] = k[e - x] + y;
			else
				j[e] = k[e];
		}
		for (int e = 0; e <= w; e++) {
			k[e] = j[e];
		}
	}
	std::cout << j[w];
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define WHOLE(v) v.begin(), v.end()
using namespace std;

const int64_t MOD = 1e9 + 7;

// O(log a)
int64_t powmod(int64_t a, int64_t p) {
    int64_t value = 1;
    for (int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
        if (p & 1) value = (value * mul) % MOD;
    }
    return value;
}

int64_t invmod(int64_t x) {
    return powmod(x, MOD - 2);
}

struct Factorial {
    vector<int64_t> val;
    vector<int64_t> inv;
};

// O(N)
Factorial GetFact(int N) {
    N++;
    Factorial fact;
    fact.val = vector<int64_t>(N);
    fact.inv = vector<int64_t>(N);
    fact.val[0] = 1;
    for (int i = 1; i < N; i++) {
        fact.val[i] = int64_t(fact.val[i - 1] * i) % MOD;
    }
    fact.inv[0] = 1;
    fact.inv[N - 1] = powmod(fact.val[N - 1], MOD - 2);
    for (int i = N - 1; i > 0; i--) {
        fact.inv[i - 1] = int64_t(fact.inv[i] * i) % MOD;
    }
    return fact;
}

int64_t Combination(int n, int m, const Factorial &f) {
    if (n < m || m < 0 || n < 0) return 0;
    return ((f.val[n] * f.inv[m] % MOD) * f.inv[n - m]) % MOD;
}

int main() {
    int64_t N, K;
    cin >> N >> K;
    Factorial f = GetFact(4000);
    int64_t ans;
    for (int64_t i = 1; i <= K; i++) {
        ans = 0;
        ans += (Combination(N - K - 1, i - 2, f) * Combination(K - 1, i - 1, f)) % MOD;
        ans %= MOD;
        ans += (2 * ((Combination(N - K - 1, i - 1, f) * Combination(K - 1, i - 1, f)) % MOD)) % MOD;
        ans %= MOD;
        ans += (Combination(N - K - 1, i, f) * Combination(K - 1, i - 1, f)) % MOD;
        ans %= MOD;
        if( N == K && i == 1) ans = 1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct{
    int midterm_exam;
    int final_exam;
    int re_exam;
}Test;

int main(void)
{
    Test math_test[50];
    int i, student_num;

    student_num = 0;

    do{
        scanf("%d %d %d", &(math_test[student_num].midterm_exam), &(math_test[student_num].final_exam), &(math_test[student_num].re_exam));
        student_num++;
    }while((math_test[(student_num - 1)].midterm_exam != -1) || (math_test[(student_num - 1)].final_exam != -1) || (math_test[(student_num - 1)].re_exam != -1));

    student_num -= 1;
    
    for(i = 0; i < student_num; i++){
        if((math_test[i].midterm_exam == -1) || (math_test[i].final_exam == -1)){
            printf("F\n");
        }
        else if((math_test[i].midterm_exam + math_test[i].final_exam) >= 80){
            printf("A\n");
        }
        else if((math_test[i].midterm_exam + math_test[i].final_exam) >= 65){
            printf("B\n");
        }
        else if((math_test[i].midterm_exam + math_test[i].final_exam) >= 50){
            printf("C\n");
        }
        else if((math_test[i].midterm_exam + math_test[i].final_exam) >= 30){
            if(math_test[i].re_exam >= 50){
                printf("C\n");
            }
            else{
                printf("D\n");
            }
        }
        else{
            printf("F\n");
        }
    }

    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    long long  ans = 0;
    
    //count case1
    for(int i=k; i<=n; i+=k) ans++;
    ans = pow(ans, 3);

    //count case2
    if(k%2 == 0){
        long long temp = 0;
        for(int i=k/2; i<=n; i+=k) temp++;
        ans += pow(temp, 3);
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  int S1 = A * B; int S2 = C * D;
  if( S1 >= S2 ) cout << S1 << endl;
  else cout << S2 << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())		# 5 7


if k==0:
	print(n*n)
	exit(0)

ans = 0
for i in range(k+1, n+1):
	q = n // i
	m = n % i
	
	a = q*(i-k)
	b = max(m-k+1, 0)
	
	#print(i, q,m,a,b)
	
	ans += a+b

print(ans)


Measured memory_bytes: 3060
import math
a,b,k = list(map(int, input().split()))
res = []
for i in range(1, max([a,b])+1):
  if(a % i == 0 and b % i == 0):
    res.append(i)
if(len(res) == 0):
  print(res[0])
else:
  print(res[-k])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  string s;
  cin >> s;
  ll ans = 0;
  ll cnt = 0;
  rep(i,s.size()) {
    if (s[i] == 'B') ++cnt;
    else {
      ans += cnt;
    }
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

int main () {
  int n, x, d=0, count=1;
  cin >> n >> x;
  vector<int> l(n);
  rep(i,n) cin >> l.at(i);
  rep(i,n) {
    d += l.at(i);
    if(d > x) {
      break;
    }
    count++;
  }
  cout << count;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size() / 2; i++) {
		int j = S.size() - 1 - i;
		if (S[i] != S[j]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3608
def main():
    md = [int(x) for x in input().split()]
    ret = 0
    for i in range(md[0]):
        for j in range(md[1]):
            d = [(1+j) % 10, (1+j)//10]
            if d[0] >= 2 and d[1] >= 2 and d[0] * d[1] == i+1:
                # print(i+1, j+1)
                ret += 1
    print(ret)
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ans=0,b=0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            if(b==0){
                ans--;
                b++;
            }
            else{
                ans++;
                b--;
            }
        }
        else{
            b=0;
            ans++;
        }
    }
    cout << ans+1<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


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


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

	int odd, even;

	if (n % 2 == 0) {
		odd = n / 2;
		even = n / 2;
	}
	else {
		odd = n / 2 + 1;
		even = n / 2;
	}

	ANS(odd*even);



	return 0;
}

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

int main(){
	vector<double> height;
	double d;
	
	while((scanf("%lf", &d)) != EOF){
		height.push_back(d);
	}
	
	sort(height.begin(), height.end());
	
	printf("%lf\n", height.back() - height.front());
	
	return 0;
}

Measured memory_bytes: 1092
#include <iostream> 
#include <sstream> 
#include <fstream> 
#include <string> 
#include <vector> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <algorithm> 
#include <functional> 
#include <utility> 
#include <bitset> 
#include <cmath> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
using namespace std;

int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(b>a+x) cout<<"dangerous"<<endl;
	else if(b>a) cout<<"safe"<<endl;
	else cout<<"delicious"<<endl;
return 0;
} 

Measured memory_bytes: 256
n, m = list(map(int, input().split()))

like = [True] * (m+1)

for i in range(n):
    ka = list(map(int, input().split()))
    for j in range(1, m+1):
        if j not in ka[1:]:
            like[j] = False

print(like[1:].count(True))
        


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


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


    vector<vector<int>> board(2, vector<int>(n));
    rep(y, 2) rep(x, n) {
            cin >> board[y][x];
        }

    vector<int> sum_1(n + 1, 0);
    for (int i = 0; i < n; i++) {
        sum_1[i + 1] = sum_1[i] + board[0][i];
    }

    vector<int> sum_2(n + 1, 0);
    for (int i = n; i > 0; i--) {
        sum_2[i - 1] = sum_2[i] + board[1][i - 1];
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int now = sum_1[i + 1] + sum_2[i];
        cmax(ans, now);

    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = sum(p[0:k])
t = ans
for i in range(1,n-k+1):
    t += - p[i-1] + p[i+k-1]
    ans = max(ans,t)
print((ans + k) / 2)

Measured memory_bytes: 98888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef double ld;

const int N = 1e5 + 5;
vi dp(N, 0);

int func(int k, vi vec)
{
	if (dp[k]) return dp[k];

	for (int i = 0; i < vec.size(); i++)
	{
		if (vec[i] <= k)
		{
			if (func(k - vec[i], vec) == 2) return dp[k] = 1;
		}
	}

	return dp[k] = 2;
}

int main()
{
	fastio
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, val;
	cin >> n >> val;

	vi arr(n);

	for (int i = 0; i < n; i++) cin >> arr[i];

	if (func(val, arr) == 1) cout << "First";
	else cout << "Second";

	return 0;

}

Measured memory_bytes: 54860
n=int(input())
K=int(input())
m=len(str(n))
N=list(map(int,str(n)))
dp=[[[0,0]for j in range(K+1)]for i in range(m+1)]
dp[0][0][0]=1
for i in range(1,1+m):
    for j in range(K+1):
        for k in range(10):
            if k==0:
                if N[i-1]==k:
                    dp[i][j][0]+=dp[i-1][j][0]
                elif N[i-1]>k:
                    dp[i][j][1]+=dp[i-1][j][0]
                dp[i][j][1]+=dp[i-1][j][1]
            else:
                if j<K:
                    if N[i-1]==k:
                        dp[i][j+1][0]+=dp[i-1][j][0]
                    elif N[i-1]>k:
                        dp[i][j+1][1]+=dp[i-1][j][0]
                    dp[i][j+1][1]+=dp[i-1][j][1]

print(sum(dp[-1][K]))

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

namespace test
{
    public class MaximumProfit
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine()); //標準入力
            var list = new List<int>();
            for (int i = 0; i < N; ++i)
            {
                list.Add(int.Parse(Console.ReadLine()));
            }
            var minNum = int.MaxValue;
            var maxDiff = int.MinValue;
            for (int i = 0; i < list.Count; ++i)
            {
                maxDiff = Math.Max(maxDiff, list[i] - minNum);
                minNum = Math.Min(minNum, list[i]);
            }
            Console.WriteLine(maxDiff);
        }

    }
}



Measured memory_bytes: 12200
#include<cstdio>
#include<algorithm>
using namespace std;
int w[101000], n, S[101000], BIT[201000];
void Add(int a, int b) {
	while (a <= n + n) {
		BIT[a] += b;
		a += (a&-a);
	}
}
int Sum(int a) {
	int r = 0;
	while (a) {
		r += BIT[a];
		a -= (a&-a);
	}
	return r;
}
bool Pos(int K) {
	int i;
	for (i = 1; i <= n; i++) {
		S[i] = S[i - 1];
		if (w[i] >= K)S[i]++;
		else S[i]--;
	}
	for (i = 0; i <= n + n; i++)BIT[i] = 0;
	long long res = 0;
	for (i = 0; i <= n; i++) {
		res += Sum(S[i] + n);
		if (i == n)break;
		Add(S[i] + n, 1);
	}
	if (res * 2 >= 1ll * n*(n + 1) / 2)return true;
	return false;
}
int main() {
	int i, b = 1, e = 1e9, r = 0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)scanf("%d", &w[i]);
	while (b <= e) {
		int mid = (b + e) >> 1;
		if (Pos(mid)) {
			r = mid;
			b = mid + 1;
		}
		else e = mid - 1;
	}
	printf("%d\n", r);
}

Measured memory_bytes: 1792
from collections import Counter
s = list(input())

count = Counter(s)
if len(s) <= 3:
  if len(s) == 1: print("YES")
  elif len(count.keys()) == len(s): print("YES")
  else: print("NO")
else:
  if len(count.keys()) <= 2: print("NO")
  elif max(count.values()) - min(count.values()) <= 1: print("YES")
  else: print("NO")


Measured memory_bytes: 10080
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int64_t res = 0;
    int64_t n, p;
    cin >> n >> p;
    int64_t odd = 0, even = 0;
    for (int i = 0; i < n; i++) {
        int m1;
        cin >> m1;
        if (m1 % 2 == 0)
            even++;
        else
            odd++;
    }
    switch (p) {
    case 0:
        if (odd == 0) {
            cout << (int64_t)(std::pow(2, even));
        } else {
            cout << (int64_t)(std::pow(2, even) * std::pow(2, odd) / 2);
        }
        break;
    case 1:
        if (odd == 0) {
            cout << 0;
            exit(0);
        } else {
            cout << (int64_t)(std::pow(2, even) * std::pow(2, odd) / 2);
        }
        break;
    default:
        break;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int x,y,i;
    for(i=1; i<3001; i++){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0)break;
		if(x>=y){
			printf("%d %d\n", y, x);

		}
		else{
			printf("%d %d\n", x, y);
		}


	}
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using namespace std;

typedef long long ll;

int main() {
	/*string s;
	cin >> s;
	rep(i, 4) {
		int a = 0;
		rep(j, 4) { 
			if (s[i] == s[j])a++;
		}
		if (a != 2) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";*/

	/*int n;
	cin >> n;
	vector<int>p(n + 1);
	int i;
	for (i = 1; i < n + 1; i++)cin >> p[i];
	int ans = 0;
	for (i = 2; i < n; i++) {
		if (p[i] != min({ p[i - 1],p[i],p[i + 1] }) && p[i] != max({ p[i - 1],p[i],p[i + 1] }))ans++;
	}
	cout << ans;*/


	/*int N;
	cin >> N;
	vector<int>d(N);
	int i;
	rep(i, N)cin >> d[i];
	sort(all(d));
	cout << d[N / 2] - d[N / 2 - 1];*/

	int N, K;
	cin >> N >> K;
	vector<vector<int>>c(2005, vector<int>(2005));
	c[0][0] = 1;
	int i, j;
	for (i = 1; i <= N; i++)for (j = 0; j <= i; j++) {
		if (j == 0 || j == i)c[i][j] = 1;
		else {
			c[i][j] += c[i - 1][j - 1] + c[i - 1][j];
			c[i][j] %= mod;
		}
	}
	ll a, b;
	for (i = 1; i <= K; i++) {
		ll ans = 0;
		if (i <= N - K + 1) {
			a = c[N - K + 1][i];
			b = c[K - 1][i - 1];
			ans = a * b % mod;
		}
		cout << ans << "\n";
	}
	
	
	return 0;
}

Measured memory_bytes: 16000
import itertools
N = int(input())
mati = list()
for _ in range(N):
    mati.append(list(map(int, input().split())))

mati_list = list(range(N))
comb = list(itertools.combinations(mati_list, 2))
length = list()
for i, k in comb:
    x_i, y_i = mati[i]
    x_k, y_k = mati[k]
    l = ((x_i - x_k) ** 2 + (y_i - y_k) ** 2) ** 0.5
    length.append(l)
ave = sum(length) / len(length)
print(ave*(N-1))

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

int main() {
  int N,M,i,H;
  H=0;
  i=0;
  cin >> N ;
	while(cin >>M){
    if(H <=M){
    	H=M;
      i+=1;
    }
    }
 cout << i << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	int n, m;
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1)  / 2;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var A = parseInt(input[0].split(" ")[1]);
  var B = parseInt(input[0].split(" ")[2]);
  var ans = Math.min(B,A*N);
  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<iostream>
#include<vector>
using namespace std;
int main(){
	vector<long long> v;
	{
		long long n,a=0,b=0,c=0,d=0,e=0;
		cin>>n;
		for(long long i=0; i<n; i++)
		{	string s;
			cin>>s;
			switch(s[0])
			{
				case 'M':
					a++;
					break;
				case 'A':
					b++;
					break;
				case 'R':
					c++;
					break;
				case 'C':
					d++;
					break;
				case 'H':
					e++;
					break;
			}
		}
		if(a)
			v.push_back(a);
		if(b)
			v.push_back(b);
		if(c)
			v.push_back(c);
		if(d)
			v.push_back(d);
		if(e)
			v.push_back(e);
	}
	if(v.size()<3){
		cout<<0;
	}
	else{
		long long s=0;
		for(long long i=0;i<v.size()-2;i++)
			for(long long j=i+1;j<v.size()-1;j++)
				for(long long k=j+1;k<v.size();k++)
					s+=v[i]*v[j]*v[k];
		cout<<s;
	}
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n); vector<PII> v;
  rep(i,n) cin >> a[i], v.push_back({a[i],i+1});
  sort(all(v));
  rep(i,n) cout << v[i].second << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define INF (int)1e9

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int N, A[100000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i];
	int dp[100001];
	for(int i = N; i >= 0; i--)
		if(i >= N - 1) dp[i] = 0;
		else if(i < N - 2) dp[i] = min(abs(A[i + 2] - A[i]) + dp[i + 2], abs(A[i + 1] - A[i]) + dp[i + 1]);
		else dp[i] = abs(A[i + 1] - A[i]) + dp[i + 1];
	cout << dp[0] << "\n";
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,z;
    int a[10]={0};
    cin>>x>>y>>z;
    a[x]++;
    a[y]++;
    a[z]++;
    if(a[5]==2&&a[7]==1)
        cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3580
/* 161-C.cpp
 *     Created on : Apr 4, 2020
 *     Time		  : 6:16:58 PM
 *     Author     : null_ptr
 */

#include<bits/stdc++.h>

using namespace std;

#define F_Input freopen("input.in","r",stdin)
#define push emplace_back
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)

template<typename T>
void Swap(T &a,T &b){
a^=b;b^=a;a^=b;}

template<class type>
void show(type name)
{for(auto& nm:name)cerr<<nm<<' ';cerr<<'\n';}

using lint=long long;
using ivec=vector<int>;
using ipair=pair<int,int>;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	lint a,b;
	cin>>a>>b;
	lint ans=min((a%b),b-(a%b));
	cout<<ans;
}





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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256