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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-8;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 10001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll mul(ll a, ll b) {
    return a * b % MOD;
}

ll dp[5001][5001];

ll pw[5001];

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int n;
    cin >> n;
    string s;
    cin >> s;
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int bal = 0; bal < n; ++bal) {
            dp[i + 1][bal + 1] += dp[i][bal];
            if (dp[i + 1][bal + 1] >= MOD) {
                dp[i + 1][bal + 1] -= MOD;
            }
            if (bal) {
                dp[i + 1][bal - 1] += dp[i][bal];
                if (dp[i + 1][bal - 1] >= MOD) {
                    dp[i + 1][bal - 1] -= MOD;
                }
            }
        }
    }
    ll ans = 0;
    ll bal = s.size();
    pw[0] = 1;
    for (int i = 1; i <= n; ++i) {
        pw[i] = pw[i - 1] * 2 % MOD;
    }
    for (int del = 0; del < n; ++del) {
        if (n - del - bal >= 0) {
            for (int x = 0; x <= del; ++x) {
                ans += dp[n - del - 1][bal - 1] * pw[(n - del - bal) / 2] % MOD * dp[del][x] % MOD * pw[(del - x) / 2] %
                       MOD;
                if (ans >= MOD) {
                    ans -= MOD;
                }
            }

        }
    }
    cout << ans;

    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 195712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int t; cin >> t;
	while(t--)
	{
		int n, d; cin >> n >> d;
		int sum = d;
		priority_queue<int, vi, greater<int> > pq;
		pq.push(d);
		for(int i = 0; i < n - 1; i++)
		{
			int x = pq.top(); pq.pop();
			int best = 0; int cur = 0;
			for(int j = 0; j < 128; j++)
			{
				if(j+(j^x) >= best)
				{
					best = j+(j^x);
					cur = j;
				}
			}
			sum += best; sum -= x;
			pq.push(cur); pq.push((cur^x));
		}
		cout << sum << '\n';
	}
}


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

int main(){
    int h=1,w=1,flag;

    while(1){
    flag=1;
    cin>>h>>w;
    if(h==0&&w==0)break;
            for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(flag==1){cout<<"#";
                flag=0;
            }
            else {
            cout<<".";
            flag=1;
            }
        }
        if(w%2==0){
            if(flag==0)flag=1;
            else flag=0;
        }
        printf("\n");
    }
 printf("\n");
    }
}



Measured memory_bytes: 3092
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, S);
    IN(string, T);
    ll N = S.size();
    ll M = T.size();
    ll ans = INF;
    REP(i, N - M + 1)
    {
        ll c = 0;
        REP(j, M)
        {
            c += S[i + j] != T[j];
        }
        CH(min, ans, c);
    }
    OUT(ans);
}

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

ll c[1000000];
ll ncr[1000000];

ll C(ll n) {
  if (ncr[n] != 0) return ncr[n];
  ll r = 0;
  REP(i, n - 1) r += i + 1;
  ncr[n] = r;
  return ncr[n];
}

int main() {
  ll n, ma = -1, sum = 0;
  cin >> n;
  ll a[n];
  REP(i, n) {
    cin >> a[i];
    ma = max(a[i], ma);
    c[a[i]]++;
  }

  REP(i, ma + 1) {
    sum += C(c[i]);
  }

  REP(k, n) {
    cout << sum - C(c[a[k]]) + C(c[a[k]] - 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 8192
# 目指すグリッドは
# ABCABCABC..
# BCABCABCA..
# CABCABCAB..
# ABCABCABC..
# ...
# N = 500なので総マス数は250000
# 色の種類は30種類
# すべてのマスをあまりごとに3グループに分ける
# 各グループにおいて、各色が何マスずつあるかを計算する。250000回
# 長さ30の配列 * 3になるのであとは変更先の色をすべて試す。30 * 3回
# 隣あったマスを同じ色にすることができないため、
# グループごとに候補を3位まで用意し、3 * 3 * 3 = 27通りをすべて試す。
# 3位と4位がタイのときはどっちを取っても大丈夫

N,C = map(int,input().split())

D = [[0]*C for i in range(C)] # 違和感
for i in range(C):
  D[i] = list(map(int,input().split())) # 色は0-indexで指定
  # D[i][j]で、iをjに変えるときの違和感を算出

# print(D)

groups = [[0]*C for i in range(3)]

for i in range(N):
  line = list(map(int,input().split()))
  for j in range(len(line)):
    groups[(i+j)%3][line[j] - 1] += 1

# groups[i(グループ名)][j(色 0-index)] = 該当する個数 が出来た。
# 各グループに対して、各色に塗り替えたときの違和感を計算する
pattern = [[[0]*2 for j in range(C)] for i in range(3)]
# pattern[i(グループ名)][j(色 0-index))] = 対象の色に塗り替えたときの違和感
# 30 * 30 = 900, 900 * 3 = 2700

for i in range(len(groups)):
  # グループごとのループ
  for j in range(C):
    # 変更後の色j
    iwakan = 0 # 色jに変えるときの違和感を累積
    for k in range(len(groups[i])):
      # グループiには色kがいくつあるか
      iwakan += groups[i][k] * D[k][j]
    pattern[i][j][0] = iwakan
    pattern[i][j][1] = j # あとで並び替えるため、何色に変えるかをメモしておく

for i in range(len(pattern)):
  pattern[i] = sorted(pattern[i],key = lambda x:x[0])

ans = 10 ** 9 + 7
for a in range(3): # グループ1が何位の数字を使うか
  for b in range(3): # 同2
    if pattern[0][a][1] == pattern[1][b][1]:
      continue
    for c in range(3): # 同3
      if pattern[0][a][1] == pattern[2][c][1]:
        continue
      if pattern[1][b][1] == pattern[2][c][1]:
        continue
      val = pattern[0][a][0] + pattern[1][b][0] + pattern[2][c][0]
      if val < ans:
        ans = val
print(ans)
    


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double H = sc.nextDouble();
		double M = sc.nextDouble();
		
		//時針と分針の角度
		double minuteHand = M / 60;
		double hourHand = (H + minuteHand) / 12;
		double angle = Math.abs(minuteHand - hourHand);

		// 結果の出力
		System.out.println(Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5));
		
		sc.close();
	}
}


Measured memory_bytes: 28876
#include<iostream>
using namespace std;
typedef long long ll;
int t;
ll n,m,x,y;
string s;

int main()
{
    cin>>n>>x>>y;
    if((x%n)==0||(y%n)==0) cout<<"OK"<<endl;
    else{
        int d = (x/n+1)*n;
        int f = (y/n)*n;
        if(d>=x&&d<=y&&f>=x&&f<=y)
            cout<<"OK"<<endl;
        else
            cout<<"NG"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main(void) {

	int i, flag = 0;
	char s[11];
	
	cin >> s;

	for ( i = 0; s[i] != '\0'; i++) {
		if (i % 2 == 0 && s[i] != 'h') {
			flag = 1;
			break;
		}
		else if (i % 2 == 1 && s[i] != 'i') {
			flag = 1;
			break;
		}
	}
	if (flag == 0 && i % 2 == 1)
		flag = 1;
	if (flag == 1 || i <= 1 )
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}

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

void maxHeapify(vector<int> &heap, int i) {
  auto e = heap[i];
  int left = 2 * (i + 1) - 1, right = 2 * (i + 1), larger = i;
  if (right < heap.size()) {
    larger = heap[left] > heap[right] ? left : right;
  } else if (left < heap.size() ) {
    larger = left;
  }
  if (heap[larger] > e) {
    heap[i] = heap[larger];
    heap[larger] = e;
    maxHeapify(heap, larger);
  }
  return;
}
int main() {
  int H;
  cin >> H;
  vector<int> heap(H);
  for (size_t i = 0; i < H; i++) {
    cin >> heap[i];
  }

  for (int i = H / 2 - 1; i >= 0 ; i--) {
    maxHeapify(heap, i);
  }

  for (auto &&e : heap) {
    cout << ' ' << e;
  }

  cout << endl;
}



Measured memory_bytes: 4600
def base_10_to_n(x, n):
    if (int(x/n)):
        return base_10_to_n(int(x/n), n)+str(x%n)
    return str(x%n)

n, k = map(int, input().split())
x = base_10_to_n(n, k)
print(len(x))


Measured memory_bytes: 38384
#include <stdio.h>


int coler[3];
int answer = 3;
int main(){
	scanf("%d %d %d", &(coler[0]), &(coler[1]), &(coler[2]));
	if (coler[0] == coler[1]){
		answer -= 1;
	}
	if (coler[1] == coler[2]){
		answer -= 1;
	}
	if (coler[0] == coler[2]){
		answer -= 1;
	}
	if (coler[0] == coler[1] && coler[1] == coler[2]){
		answer = 1;
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {     
    int l,r,d;
    cin >> l >> r >> d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
def mlt(): return map(int, input().split())


x, a, b = mlt()

dp = [0 for n in range(x)]

for n in range(1, x+1):
    for k in range(n+1, x+1):
        d1 = k-n
        d2 = abs(a-n)+1+abs(b-k)
        ds = min(d1, d2)
        dp[ds] += 1

print(*dp[1:], sep='\n')


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

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
// #include <algorithm>
using namespace std;

#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back

#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))

#define ADD_OPERATORS_IN(T, COMP) \
    bool operator < (const T& ot) const { return COMP(ot) == -1; } \
    bool operator > (const T& ot) const { return COMP(ot) == 1; } \
    bool operator == (const T& ot) const { return COMP(ot) == 0; } \
    bool operator != (const T& ot) const { return COMP(ot) != 0; }

#define ADD_OPERATORS_OUT(T, COMP) \
    bool operator < (const T& a, const T& b) const { return COMP(a, b) == -1; } \
    bool operator > (const T& a, const T& b) const { return COMP(a, b) == 1; } \
    bool operator == (const T& a, const T&b) const { return COMP(a, b) == 0; } \
    bool operator != (const T& a, const T&b) const { return COMP(a, b) != 0; }


typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;

mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());

template<typename T1, typename T2> inline bool upmax(T1& a, T2 b) { return (a < b ? (a = b, true) : false); }
template<typename T1, typename T2> inline bool upmin(T1& a, T2 b) { return (b < a ? (a = b, true) : false); }

const int maxn = (int) 3e5 + 20;
const int maxlog = 21;
const int base = (int) 1e9 + 7;
const ld eps = (ld) 1e-7;
const ld PI = acos(-1.);
//const int pp = 41;
const int inf = 2e9;

int main() {
    int m, d;
    cin >> m >> d;

    int cnt = 0;
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= d; j++) {
            if (j % 10 >= 2 && j / 10 >= 2 && (j % 10) * (j / 10) == i)
                cnt++;
        }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll n,m;
    cin >> n >>m;
    vector<ll> A(m,0);
    REP(i,m) cin >>A[i];
    REP(i,m){
        n-=A[i];
        if(0 >n){
            n=-1;
            break;
        }
    }
    cout << n<<endl;

}

Measured memory_bytes: 3652
package main

import (
	"fmt"
)

func COM(n, k int64) int64 {
	r := int64(1)
	for i := int64(0); i < k; i++ {
		r = ModMul(r, n-i)
		r = ModDiv(r, i+1)
	}

	return r
}

const (
	MOD = 1000000000 + 7
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

type P struct {
	X, T, Cond int
}

type PS []*P

func (p PS) Len() int           { return len(p) }
func (p PS) Less(i, j int) bool { return p[i].T < p[j].T }
func (pq PS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func main() {
	var r, D, x int
	fmt.Scanf("%d %d %d\n", &r, &D, &x)
	sum := x
	for i := 0; i < 10; i++ {
		sum = sum*r - D
		fmt.Println(sum)
	}
}

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<vector<int>> c(N);
    REP(i, M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        c[a].pb(b);
        c[b].pb(a);
    }
    Rep(i, 1, N-1){
        SORT(c[i]);
        if(FIND(c[i],0) && FIND(c[i], N-1)){
            pr("POSSIBLE");
            return 0;
        }
    }
    pr("IMPOSSIBLE");
}

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

int main() {
	long long N, T, A;
	cin >> N >> T >> A;
	for (int i = 1; i < N; i++) {
		long double  t, a;
		cin >> t >> a;
		if (T * a > A * t) {
			T = t * ceil((long double)T / t);
			A = a * ceil((long double)T / t);
		}
		else {
			T = t * ceil((long double)A / a);
			A = a * ceil((long double)A / a);
		}
	}
	cout << T + A << endl;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

ll a,b,c,d;

ll lcm(ll x, ll y){
    ll g = __gcd(x,y);
    return x/g*y;
}

ll f(ll n){
    ll L = lcm(c,d);
    return n - n/c - n/d + n/L;
}

int main(){
    cin >>a >>b >>c >>d;
    cout << f(b) - f(a-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
 /*
 イベントソート
- イベントを入れる配列
- 現時点で通行止めにされている座標を持つセット
を 1 つずつ用意し、以下の 3 種類のイベントを定義しておきます:
1. 追加イベント (t, 0, x) - セットに x を追加する。
2. 削除イベント (t, 1, x) - セットから x を削除する。
3. 探索イベント (t, 2, i) セットの最小値を取り出す (時刻tに出発した人が止まる場所を見つける)

 i番目の工事は [S-X, T-X]に出発した人を足止めする
 
 */
using type = pair<int, long long>; // <イベント種類, 通行止め座標> 0: delete, 1: insert, 2: query 削除の後に追加
using event = pair<long long, type>; //[時刻t, イベント種類, 通行止め座標]

int main() {
	// 入力
	ll N,Q;cin>>N>>Q;
    vector<event> v; // イベントを入れる配列
    REP(i,N){
        ll s,t,x;cin>>s>>t>>x;
        v.pb(make_pair(t-x, type(0, x))); // 削除イベント (t, -1, x)
        v.pb(make_pair(s-x, type(1, x))); // 追加イベント (t, 1, x)
    }
    REP(i,Q){
        ll d;cin>>d;
        v.pb(make_pair(d, type(2, i))); // 探索イベント (t, 0, _)
    }

    // 解法
    sort(v.begin(), v.end()); // イベントソート
    ll ans[Q]; // 答えを入れる
    set<ll> se; // 現時点で通行止めにされている座標を持つセット
    REP(i, v.size()){
        ll type = v[i].second.first;
        ll val = v[i].second.second;
        if (type==0){// 削除イベント
            se.erase(val);
        }
        else if (type==1){//追加イベント
            se.insert(val);
            // printf("se %i. min: %lld\n", se.size(), *se.begin());
        }
        else{// 探索イベント
            if (se.size()==0) ans[val] = -1;
            else ans[val] = *se.begin();
            // printf("se %i. min: %lld\n", se.size(), *se.begin());
            
        }
    }

    // 出力
    REP(i,Q){
        printf("%lld\n", ans[i]);
    }
    
}


Measured memory_bytes: 26984
#include <stdio.h>
#include <stdlib.h>
#define N 100
int main(void){
    int i,n;
    int a[N];
    scanf("%d",&n);
    if(n>N) exit(1);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;i>=0;i--){
        printf("%d",a[i]);
        if(i>0) printf(" ");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2752
import sys
input = sys.stdin.readline
from collections import deque

nn = 202020
mod = 10 ** 9 + 7

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % mod

C = lambda a, b: fa[a] * fainv[b] * fainv[a-b] % mod if 0 <= b <= a else 0

N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

BU = [1] * N
TD = [1] * N
SI = [1] * N
for i in R[::-1]:
    a = 1
    s = 0
    for j in X[i]:
        a = a * BU[j] * fainv[SI[j]] % mod
        s += SI[j]
    SI[i] = s + 1
    BU[i] = fa[s] * a % mod

for i in R:
    a = TD[i] * fainv[N - SI[i]]
    for j in X[i]:
        a = a * BU[j] * fainv[SI[j]] % mod
    for j in X[i]:
        TD[j] = a * pow(BU[j], mod-2, mod) % mod * fa[SI[j]] % mod * fa[N - 1 - SI[j]] % mod

for i in range(N):
    print(BU[i] * TD[i] % mod * C(N-1, SI[i] - 1) % mod)

Measured memory_bytes: 126156
#include <stdio.h>

int main(void){
    int L,R,d,ans,r,l;
    
    scanf("%d",&L);
    scanf("%d",&R);
    scanf("%d",&d);
    
    r=R/d;
    l=L/d;
    
    ans=r-l;
    
    if(L%d==0){
        ans=ans+1;
    }
    
    
    
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 2148
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;

int main(){
    int a,b; cin>>a>>b;
    if(a==2 || b==2) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 998244353

ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(char *a,char *b) {
    char temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
vector<ll> isprime;
void seive(){
    isprime = vector<ll>(2000001,-1);
    for(int i=2;i*i<=2000000;i++){
        if(isprime[i]==-1){
            for(int j=i*i;j<=2000000;j+=i){
                if(isprime[j]==-1) isprime[j]=i;
            }
        }
    }
    for(int i=2;i<=2000000;i++){
        if(isprime[i]==-1) prime.push_back(i);
    }
}
void solve() {
    ll n;
    cin>>n;
    ll rem=n%10;
    if(rem==2 || rem==4 || rem==5 || rem==7 || rem==9) cout<<"hon";
    else if(rem==0 || rem==6 || rem==8 || rem==1) cout<<"pon";
    else cout<<"bon";

}




int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


Measured memory_bytes: 3612
import java.util.Scanner;

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


		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i=0;i<n;i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			int b = sc.nextInt();
			int p = sc.nextInt();

			int ans = x*b + y*p;

			if(b>=5 && p>=2){
				ans = (x*b + y*p)*4/5;
			}else{
				if(b<5){
					b=5;
				}
				if(p<2){
					p=2;
				}
				int wari = (x*b + y*p)*4/5;

				if(ans>wari){
					ans = wari;
				}
			}
			System.out.println(ans);
		}
	}
}

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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var A = new List<long>();

        var line = Console.ReadLine().Split(" ");
        for (int i = 0; i < N; i++)
        {
            A.Add(long.Parse(line[i]));
        }

        long result = 1;
        if (A.Contains(0))
        {
            result = 0;
        }
        else
        {
            try
            {
                foreach (var item in A)
                {
                    checked
                    {
                        result *= item;
                    }
                }
            }
            catch (OverflowException ex)
            {
                result = -1;
            }

            if (result > 1000000000000000000)
            {
                result = -1;
            }
        }

        Console.WriteLine(result);
    }
}


Measured memory_bytes: 43248
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(h.at(i)>=k){
      count++;
    }
  }
  cout << count << endl;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

int n, m;

bool all_on(long long switches, vector<vector<int>>& s, vector<int>& p) {
    for(int i = 0; i < m; ++i) {
        vector<int>& ss = s[i];
        int pp = p[i];
        int ct = 0;
        for(int sw : ss) {
            int mask = 1<<(sw-1);
            if(mask&switches) ++ct;
        }
        if(ct%2 != pp) return false;
    }
    return true;
}

int32_t main() {

    cin >> n >> m;

    vector<vector<int>> s(m, vector<int>());
    for(int i = 0; i < m; ++i) {
        int k; cin >> k;
        while(k--) {
            int x; cin >> x;
            s[i].push_back(x);
        }
    }
    vector<int> p(m);
    for(int i = 0; i < m; ++i) cin >> p[i];

    long long ans = 0;
    long long max_s = 1<<n;
    for(long long switches = 0; switches < max_s; ++switches) {
        if(all_on(switches, s, p)) ++ans;
    }

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


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

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    
    cout << (s<t ? "Yes":"No") << endl;

}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    string s;cin >>s;
    ll x,y;cin >>x>>y;
    ll n=s.size();
    vector<vector<bool>>dx(n+1,vector<bool>(2*n+2,false));
    vector<vector<bool>>dy(n+1,vector<bool>(2*n+2,false));
    vector<ll>ax;
    vector<ll>ay;
    ll t=0;
    ll now=0;
    for (int i = 0; i < n; ++i) {
        if(s[i]=='T'){
            if(t%2==0){
                ax.push_back(now);
            }
            else {
                ay.push_back(now);
            }
            now=0;
            t++;
        }
        else {
            now++;
        }
    }
    if(now!=0){
        if(t%2==0){
            ax.push_back(now);
        }
        else {
            ay.push_back(now);
        }
    }
    dx[0][n]=true;
    dy[0][n]=true;
    for (int i = 0; i <ax.size(); ++i) {
        for (int j = 0; j <2 * n+2; ++j) {
            if(dx[i][j]){
                if(j-ax[i]>=0&&i!=0){
                    dx[i+1][j-ax[i]]=true;
                }
                if(j+ax[i]<2*n+2){
                    dx[i+1][j+ax[i]]=true;
                }
            }
        }
    }
    for (int i = 0; i <ay.size(); ++i) {
        for (int j = 0; j <2 * n+2; ++j) {
            if(dy[i][j]){
                if(j-ay[i]>=0){
                    dy[i+1][j-ay[i]]=true;
                }
                if(j+ay[i]<2*n+2){
                    dy[i+1][j+ay[i]]=true;
                }
            }
        }
    }
//    for (int i = 0; i <2*n+2; ++i) {
//        if(dx[ax.size()][i]){
//            cout <<i<<" ";
//        }
//    }
//    cout <<endl;
    if(dx[ax.size()][n+x]&&dy[ay.size()][n+y]){
        puts("Yes");
    }
    else puts("No");
    return 0;
}



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

using namespace std;

bool check(string& S){
    string c = "NWSE";
    for(int i=0;i<4;i++){
        if(S.find(c[i]) != string::npos && S.find(c[(i+2)%4]) == string::npos) return false;
    }
    return true;
}

int main(){
    string S;
    while(cin >> S){
        cout << (check(S) ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main () {
  int i, a, v, j, k;
  int A[100];

  scanf("%d\n", &a);

  for (i = 0; i < a; i++) {
    scanf("%d", &A[i]);
    if (i > 0) {
      printf(" ");
    }
      printf("%d", A[i]);
  }
  printf("\n");

  for (i = 1; i < a; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for (k = 0; k < a; k++) {
      if (k > 0) {
        printf(" ");
      }
      printf("%d", A[k]);
    }
    printf("\n");
  }

  return 0;
}

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

ll K, A, B;

int main(void) {
  cin >> K >> A >> B;

  if(K <= A) cout << 1 << endl;
  else if(A - B <= 0) cout << -1 << endl;
  else {
    ll ans = (K - A) / (A - B) * 2 + 1;
    if((ans / 2 + 1) * A - ans / 2 * B >= K) cout << ans << endl;
    else cout << ans + 2 << endl;
  }
}


Measured memory_bytes: 256
import math

sd = list(input())
t = list(input())

dic = []

slen = len(sd)
tlen = len(t)
for i in range(slen - tlen + 1):
    for j in range(tlen):
        if not (t[j] == sd[i + j] or sd[i + j] == "?"):
            break
    else:
        s = sd[:i] + t + sd[i + tlen:]
        for k in range(len(s)):
            if s[k] == "?":
                s[k] = "a"
        dic.append("".join(s))

if len(dic) == 0:
    print("UNRESTORABLE")
    exit()
print(sorted(dic)[0])

Measured memory_bytes: 9092
#include <iostream>


using namespace std;

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		int x = i;
		if(x % 3 == 0)
		{
			cout << " " << i;
			continue;
		}
		do
		{
			if(x % 10 == 3)
			{
				cout << " " << i;
				break;
			}
			x /= 10;
		} while(x);
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3088
# alone
N = int(input())
divisors = []
for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        divisors.append(i)
        if i != N // i:
            divisors.append(N//i)

result = sorted(divisors)
#print(result)

if len(result) == 2:
    final_i = result[0]
    final_j = result[1]
else:
    #print(len(result))
    if len(result)%2 == 0:
        final_i = result[len(result)//2 - 1]
        final_j = result[len(result)//2 ]
            
    else:
        final_i = result[(len(result))//2]
        final_j = result[(len(result))//2]
            
#print(final_i,final_j)        
print(final_i+final_j - 2)

Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define INF 1e9;
#define mod 1e9+7

//#define max(x,y) (x>y)?x:y
//#define min(x,y) (x<y)?x:y
#define rep(i,j,k) for(int i=j;i<k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define mi(n) (int*)malloc(sizeof(int)*n);
#define mc(n) (char*)malloc(sizeof(char)*n);

using namespace std;
void p(int x){
    printf("%d\n",x);
}

void pp(char c){
    printf("%c\n",c);
}

void ppp(char *s){
    printf("%s\n",s);
}

int main(){
   string s;
   cin>>s;
   int count=0,ans=0;
   bool judge=false;
   rep(i,0,s.length()){
       if(s[i]=='A') judge=true;
       if(judge)count++;
       if(s[i]=='Z' && judge){
        ans=max(count,ans);
       }
   }
   
   cout<<ans<<endl;
   
   

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(x, a, b) = sc.nextLine.split(" ").map(_.toInt)
    if (math.abs(x - a) < math.abs(x - b)) println("A")
    else println("B")
  }
}


Measured memory_bytes: 25632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 200005;
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    set<string>st;
    f(n) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << '\n';
}

Measured memory_bytes: 19236
#include <stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r<0||x+r>W||y-r<0||y+r>H)printf("No\n");
  else printf("Yes\n");
  return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    Vi a(n),b(n);
    rp(i,n) cin >> a[i];
    rp(i,n) cin >> b[i];
    Vi af(n+1,0),bf(n+1,0);
    rp(i,n){
        af[a[i]]++;
        bf[b[i]]++;
        //print("a");
    }
    rp(i,n+1){
        if(af[i]+bf[i]>n){
            print("No");
            return;
        }
    }
    ll j=0;
    rp(i,n){
        if(i>0&&a[i-1]!=a[i]) j=0;
        if(a[i]==b[i]){
            for(;j<n;j++){
                if(a[i]!=b[j]&&a[j]!=b[i]) {
                    swap(b[i],b[j]);
                    break;
                }
            }
        }
    }
    print("Yes");
    for(auto bb:b){
        princ(bb);
    }
    cout << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}


Measured memory_bytes: 9516
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;
 
#[fastout()]
fn main(){
    input!{
        n:usize,k:usize,
    }
    let Mod=1000000007;
    let mut c=vec![vec![0;2500];2500];
    for i in 0..2500{
        c[i][0]=1;
    }
    for i in 0..2020{
        for j in 0..2020{
            c[i+1][j+1]=(c[i][j+1]+c[i][j])%Mod;
        }
    }
    for i in 1..k+1{
        let c1:i64=c[n-k+1][i] as i64;
        let c2:i64=c[k-1][i-1] as i64;
        println!("{}",(c1*c2)%Mod);
    }
}

Measured memory_bytes: 50848
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<(n);++i)
#define itn int
#define ocut cout
#define ouct cout
#define outc cout

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        re(i,b){
            cout << a;
        }
    }
    else{
        re(i,a){
            cout << b;
        }
    }
}



Measured memory_bytes: 256
s = input() #sys.stdin.readlineは最後が改行
n =len(s)

from collections import defaultdict
amari = defaultdict(lambda:0)
amari[0]=1
num=0
tmp=0
ans =0

for i in range(n):
    num = tmp + int(s[-1-i])*pow(10,i,2019)
    tmp = num%2019
    amari[tmp]+=1

    if amari[tmp]>1:
        val = amari[tmp]
        ans -= (val-1)*(val-2)//2
        ans += (val)*(val-1)//2

print(ans)




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

int main(void){
    string s;
    set<char> ss;
    cin >> s;
    for(auto c : s)
        ss.insert(c);
    if(ss.size() == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
function main(input) {
  var N=input.split("\n")[0];
  var arrL = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
  var sum =  function(arr) {
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += arr[i];
    };
    return sum;
};

const wa = sum(arrL);
 const saidai=Math.max.apply(null, arrL);
  if(saidai<wa-saidai){
    console.log("Yes");
  }else{
    console.log("No");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

const int Maxn = 2005;

int n, z, w;
int a[Maxn];
int dp[Maxn][2];

int main()
{
	scanf("%d %d %d", &n, &z, &w);
	a[0] = z; a[1] = w;
	for (int i = 2; i <= n + 1; i++)
		scanf("%d", &a[i]);
	dp[n + 1][0] = dp[n + 1][1] = abs(a[n] - a[n + 1]);
	for (int i = n; i >= 2; i--) {
		int mx = abs(a[i - 1] - a[n + 1]);
		for (int j = i; j <= n; j++)
			mx = max(mx, dp[j + 1][1]);
		dp[i][0] = mx;
		int mn = abs(a[i - 1] - a[n + 1]);
		for (int j = i; j <= n; j++)
			mn = min(mn, dp[j + 1][0]);
		dp[i][1] = mn;
	}
	printf("%d\n", dp[2][0]);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    ll n;
    cin >> n;
    
    bool s[100000] = {};
    for(int i = 2; i < 60000; i++){
        if(!s[i]){
            for(int j = 2 * i; j < 60000; j += i){
                s[j] = true;
            }
        }
    }
    
    int p = 2;
    REP(i, n - 1){
        while(!(!s[p] && p % 5 == 4))p++;
        cout << p << ' ';
        p++;
    }
    while(!(!s[p] && p % 5 == 4))p++;
    cout << p << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e18 + 9;

int n, a[N];

int f(int x){
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans += abs(x + i - a[i]);
	return ans;
}
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int l = -inf, h = inf;
	while(l + 1 < h){
		int md = (l + h) >> 1;
		if(f(md) < f(md + 1))
			h = md;
		else
			l = md;
	}
	cout << min(f(l), f(h));
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	int sum=n-k;
	if(n<k)k=n;
	if(sum<0)sum=0;
	cout<<k*x+sum*y<<endl;
}

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

// #define multitest 1
#ifdef WIN32
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	while (*name == ',' || *name == ' ')
		name++;
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1, typename... Args>
void PC(const char *names, Arg1 &&arg1, Args &&... args)
{
	while (*names == ',' || *names == ' ')
		names++;
	const char *comma = strchr(names, ',');
	std::cerr.write(names, comma - names) << " { ";
	for (const auto &v : arg1)
		cerr << v << ' ';
	cerr << " }\n";
	PC(comma, args...);
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10, mod = 1000000007;
vector<int> G[nax];
int res, k, vis[nax];
vector<int> a(nax);

int dfs(int node)
{
	int steps = 0;
	for (auto child : G[node])
		steps = max(steps, dfs(child) + 1);
	if (steps == k - 1 && a[node] != 0)
	{
		a[node] = 0;
		steps = -1;
		res++;
	}
	return steps;
}

void solve(int caseNo)
{
	int n, x;
	cin >> n >> k;
	res = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		--a[i];
	}
	if (a[0] != 0)
	{
		res++;
		a[0] = 0;
	}
	for (int i = 1; i < n; ++i)
		G[a[i]].pb(i);
	dfs(0);
	cout << res << '\n';
}

int main()
{
#ifndef WIN32
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	for (int i = 0; i < t; ++i)
		solve(i);
#ifdef TIME
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

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

  public static void main(String [] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String ln;
    StringTokenizer st;
    while((ln = br.readLine()) != null){
      st = new StringTokenizer(ln);
      int a = Integer.parseInt(st.nextToken());
      int b = Integer.parseInt(st.nextToken());
      System.out.println(((a+b)+"").length());
    }  
  }
}

Measured memory_bytes: 10000
def change(s, n):
  c = ['r', 'g', 'b']
  a, b = s[n], s[n + 1]
  if a == b:
    return s
  s = list(s)
  c.remove(a)
  c.remove(b)
  s[n], s[n + 1] = c[0], c[0]
  return ''.join(s)

while True:
  s = raw_input()
  if s == '0':
    break
  
  q = [(s, 0)]
  mem = []
  while len(q) > 0:
    v, n = q.pop(0)
    if v in mem:
      continue
    if v.count(v[0]) == len(v):
      print(n)
      break
    mem.append(v)
    for i in range(len(v) - 1):
      vv = change(v, i)
      if vv != v:
        q.append((vv, n + 1))
  else:
    print('NA')

Measured memory_bytes: 6600