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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int s, w;
  cin >> s >> w;
  if (w >= s)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
}


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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  int n,cnt=0;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n,greater<int>());
  rep(i,0,n) if(i%2==0) cnt+=a[i]; else cnt-=a[i];
  cout<<cnt<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 7060
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char a = sc.next().charAt(0);
		if( (a == 'a')||(a=='i')||(a=='u')||(a=='e')||(a=='o')){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}
	return;
	}
}

Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
int H, W;
string S[500];
int m[500][500];
int main () {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }
    int k = 0;
    long long ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (m[i][j] == 0) {
                m[i][j] = ++k;
                queue<pair<int, int>> que;
                que.push(make_pair(i, j));
                long long X = 0, Y = 0;
                while (que.size()) {
                    int x = que.front().first, y = que.front().second;
                    que.pop();
                    int c;
                    if (S[x][y] == '.') {
                        c = '#';
                        X++;
                    }
                    else {
                        c = '.';
                        Y++;
                    }
                    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
                    for (int a = 0; a < 4; a++) {
                        int nx = x+dx[a], ny = y+dy[a];
                        if (0 <= nx && nx < H && 0 <= ny && ny < W && S[nx][ny] == c && m[nx][ny] == 0) {
                            m[nx][ny] = k;
                            que.push(make_pair(nx, ny));
                        }
                    }
                }
                ans += X*Y;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
restaurants = []
for i in range(n):
    s, p = input().split()
    restaurants.append((s, int(p), i + 1))

restaurants.sort(key=lambda x: x[1], reverse=True) # 点数でsort
restaurants.sort(key=lambda x: x[0]) # 名前でsort
for _, _, i in restaurants:
    print(i)

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

int prime[1000010];
bool is_prime[1000010];

int sieve(int n) {
	int ans = 0;
	int p = 0;
	for (int i = 0; i <= n; i++) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	for (int i = 0; i <= n; i++) {
		if (is_prime[i] == true) ans++;
	}
	return ans;
}

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;
		cout << sieve(2 * n) - sieve(n) << endl;
	}
	return 0;
}


Measured memory_bytes: 3420
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;
    sort(_all(a));

    int A = a.back();
    int mid = A / 2 + A % 2;
    int mi = inf;
    int B = -1;
    rep(i, n-1){
        int e = a[i];
        if(chmin(mi, abs(e - mid))){
            B = e;
        }
    }

    cout << A << " " << B << endl;

    return 0;
}


Measured memory_bytes: 768
// https://qiita.com/e869120/items/eb50fdaece12be418faa

#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    ll res = 0;
    rep(i, n) {
        ll x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll y = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
        res += x * y;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1408
count = {}
n = int(input())
for word in [input() for _ in range(n)]:
    if not word in count:
        count[word] = 1
    else:
        count[word] += 1

m = int(input())
for word in [input() for _ in range(m)]:
    if not word in count:
        count[word] = -1
    else:
        count[word] -= 1

high_score = max(sorted(count.items(), key=lambda x: x[1], reverse=True)[0][1], 0)
print(high_score)

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


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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin >>a >>b >>c;
	if(a>c)swap(a,c);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	cout <<a <<" "<<b <<" "<<c <<'\n';
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#define NMAX 100
#define MAX 100000000
using namespace std;

struct Matrix{
  long long r;
  long long c;
};

Matrix m[NMAX];
int n;

long long minmulti_[NMAX][NMAX];

long long minmulti(int begin,int end){
  if(begin==end){return 0;}
  if(begin+1==end){return m[begin].r*m[begin].c*m[end].c;}
  if(minmulti_[begin][end]!=0) return minmulti_[begin][end];
  long long min=MAX;
  long long num;
  for(int i=begin;i<end;i++){
     num = minmulti(begin,i) + minmulti(i+1,end);
     num += m[begin].r*m[i].c*m[end].c;
     if(num<min){min=num;}
  }
  minmulti_[begin][end]=min;
  return min;
}

int main(){
  for(int i=0;i<NMAX;i++){
    for(int j=0;j<NMAX;j++){
      minmulti_[i][j]=0;
    }
  }
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>m[i].r>>m[i].c;
  }
  cout<<minmulti(0,n-1)<<endl;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int a[10010][1310];

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

    int n, m;
    while (1)
    {
        cin >> n >> m;
        if (n == 0 && m == 0)
            break;
        rep(i, 10010) rep(j, 1310) a[i][j] = 0;
        int r;
        cin >> r;
        rep(i, r)
        {
            int T, N, M, S;
            cin >> T >> N >> M >> S;
            int x = (S == 1 ? 1 : -1);
            T++;
            a[M - 1][T] += x;
        }
        rep(i, m) rep(j, 1300) a[i][j + 1] += a[i][j];
        rep(i, m) rep(j, 1300) if (a[i][j] > 1) a[i][j] = 1;
        rep(i, m) rep(j, 1300) a[i][j + 1] += a[i][j];
        int q;
        cin >> q;
        while (q--)
        {
            int A, B, C;
            cin >> A >> B >> C;
            C--;
            cout << a[C][B] - a[C][A] << endl;
        }
    }
}


Measured memory_bytes: 105440
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int N;
char s[11234][16];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%s", &s[i]);

	int ans = 0;
	rep(i, N) {
		int l = strlen(s[i]);
		rep(j, l - 1) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B') ans++;
		}
	}

	int A = 0, BA = 0, B = 0;

	rep(i, N) {
		int l = strlen(s[i]);
		if (s[i][0] == 'B' && s[i][l - 1] == 'A') BA++;
		else if (s[i][0] == 'B') B++;
		else if (s[i][l - 1] == 'A') A++;
	}

	ans += min(A, B);
	A -= min(A, B);
	B -= min(A, B);
	if (BA) {
		ans += BA - 1;
		BA = 1;
	}
	if (BA && A || BA && B) ans++;

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
#define MOD 1000000007

ll m[200010],p[200010];
int mcnt,pcnt;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		if(t>=0)p[pcnt++]=t;
		else m[mcnt++]=-t;
	}
	//正の数・負の数をそれぞれソート
	sortup(m,mcnt);
	sortup(p,pcnt);
	
	//K==Nのとき
	if(k==n){
		ll ans=1;
		rep(i,0,mcnt)ans=ans*(MOD-m[i])%MOD;
		rep(i,0,pcnt)ans=ans*p[i]%MOD;
		printf("%lld",ans);
		return 0;
	}
	
	//Kが奇数かつ負のみのとき
	if(k%2==1&&mcnt==n){
		ll ans=1;
		rep(i,0,k)ans=ans*(MOD-m[i])%MOD;		
		printf("%lld",ans);
		return 0;
	}
	
	ll ans=1;
	while(k){
		// 負の数を2個とる or 正の数を1個とる
		if(k>=2 && mcnt>=2 &&(pcnt<=1 || (pcnt>=2 && m[mcnt-1]*m[mcnt-2]>=p[pcnt-1]*p[pcnt-2]))){
			ans=ans*m[--mcnt]%MOD;
			ans=ans*m[--mcnt]%MOD;
			k-=2;
		}else{
			ans=ans*p[--pcnt]%MOD;
			k--;
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 4104
import java.util.*;

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

        int ans = equal(mozi);

        if(ans == 1){
            System.out.println("yes");
        }else if(ans == 0){
            System.out.println("no");
        }
    }

    public static int equal(String[] lung){
        int answer = 1;
        for(int a=0; a<lung.length-1; a++){
            for(int b=a+1; b<lung.length; b++){
                if(lung[a].equals(lung[b])){
                    answer = 0;
                }
            }
        }
        return answer;
    }
}

Measured memory_bytes: 27032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] S = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.ReadLine();
            int[] T = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int cnt = 0;

            foreach (var t in T)
            {
                if (BinarySearch(S, t)) cnt++;
            }

            Console.WriteLine(cnt);
        }

        static bool BinarySearch(int[] S, int key)
        {
            int left = 0;
            int right = S.Length;

            while (left < right)
            {
                int mid = (left + right) / 2;

                if (S[mid] == key) return true;
                else if (key < S[mid]) right = mid;
                else left = mid + 1;
            }
            return false;
        }
    }
}

Measured memory_bytes: 19772
#include<iostream>
#include<cstdio>
using namespace std;
long long n,k;
int main()
{
	cin>>n>>k;
if (k==0)
    {
        cout<<(long long)n*n<<endl;
        return 0;
    }
    int i;
    long long ans=0;
    for (i=1;i<=n;i++)
    {
        //b = i
        if (i<=k) continue;
        int t=n/i;
        ans+=(long long)(i-k)*t;
        ans+=max(n%i-k+1,0ll);
    }
    cout<<ans<<endl;
    return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x; cin >> x;
    if(1800<= x){
        cout << 1 << endl;
    }
    else if(1600<=x){
        cout << 2 << endl;
    }
    else if(1400<=x){
        cout << 3 << endl;
    }    else if(1200<=x){
        cout << 4 << endl;
    }    else if(1000<=x){
        cout << 5 << endl;
    }    else if(800<=x){
        cout << 6 << endl;
    }    else if(600<=x){
        cout << 7 << endl;
    }
    else {
        cout << 8 << endl;
    }
}

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

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	int s, o;
	while(cin >> s, s) {
		s = 1000 - s;
		o = 0;
		while(s >= 500) {
			s -= 500;
			o++;
		}
		while(s >= 100){
			s -= 100;
			o++;
		}
		while(s >= 50){
			s -= 50;
			o++;
		}
		while(s >= 10){
			s -= 10;
			o++;
		}
		while(s >= 5){
			s -= 5;
			o++;
		}
		o += s;
		cout << o << endl;
	}

	return 0;

}

Measured memory_bytes: 1160
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    char a;
    cin >> a;
    if (a <= 'Z')cout << 'A' << endl;
    else cout << 'a' << endl;
    return 0;
}


Measured memory_bytes: 3592
def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N,K=map(int,input().split())
m=min(K,N-K+1)
for i in range(1,m+1):
    print((cmb(K-1,i-1,mod)*cmb(N-K+1,i,mod))%mod)
for i in range(0,K-m):
    print(0)


Measured memory_bytes: 41968
//It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include<bits/stdc++.h>
using namespace std;
     
     
#define Fast_as_duck ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define rev(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

    int d , t , s;
    cin >> d >> t >>s;

    if(d <= s*t){
        cout << "Yes";
    }else cout << "No";
    


    
    

    
    
        


}

int main(){
    Fast_as_duck;

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
*/
    int t = 1; 
    
    // cin >> t;
    

    while(t--){
        solve();
    }




    return 0;
}
      
       


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	return gcm(b, a % b);
}

int solve(const vector<int> as, int n) {
	if (n == 2) {
		return max(as[0], as[1]);
	}

	vector<int> from_left(n);
	int val = 0;
	FOR_LT(i, 0, n) {
		if (val == 0) {
			val = as[i];
		}
		else {
			val = gcm(val, as[i]);
		}
		from_left[i] = val;
	}

	vector<int> from_right(n);
	val = 0;
	FOR_DW(i, n - 1, 0) {
		if (val == 0) {
			val = as[i];
		}
		else {
			val = gcm(val, as[i]);
		}
		from_right[i] = val;
	}

	int ans = from_right[1];
	FOR_LT(i, 0, n - 2) {
		ans = max(ans, gcm(from_left[i], from_right[i + 2]));
	}
	ans = max(ans, from_left[n - 2]);


	return ans;
}

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

	vector<int> as(n);
	for (auto& a : as) {
		cin >> a;
	}

	cout << solve(as, n) << endl;

	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

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

	llong ans = 0;
	for (int i = 1; i <= N/2; ++i) {
		if (i != N-i)
			ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 4e5 + 33, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, a, b;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> a >> b;
	ll ans = (n/(a+b))*a + min(a, n%(a+b));
	cout << ans;
}



Measured memory_bytes: 256
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    string s;
    cin>>s;
    s[3]='8';
    cout<<s;
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	string s;
	cin >> s;

	if (s[0] == s[1] && s[0] == s[2] || s[1] == s[2] && s[2] == s[3])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	cout << endl;

}

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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))


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

template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }


int main()
{
	//cout.setf(ios::fixed); cout.precision(10);
	ios_base::sync_with_stdio(false);  cout.tie(nullptr); cin.tie(nullptr);

	char c;
	cin >> c;

	if (c == 'A')
	{
		cout << "T" << endl;
	}
	else if (c == 'T')
	{
		cout << "A" << endl;
	}
	else  if (c == 'C')
	{
		cout << "G" << endl;
	}
	else
	{
		cout << "C" << endl;

	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = (int)1e5 + 9;
bool is[N];

int main(){
    fastIO;
    string t;
    cin >> t;
    int n = t.size();
    for(int i = 0 ; i < n ; i ++ ){
        if(t[i] == '0')
            is[i+1]=false;
        else
            is[i+1]=true;
    }
    if(is[n]){
        cout << -1;
        return 0;
    }
    if(!is[1]){
        cout << -1;
        return 0;
    }
    for(int i = 1; i < n; i ++ ){
        if(is[i] != is[n - i]){
            cout << -1;
            return 0;
        }
    }
    int cnt = 1;
    for(int i = 1; i < n; i ++ ){
        cnt += is[i];
    }
    for(int i = 2; i <= cnt ;i ++ ){
        cout << i - 1 << " " << i << "\n";
    }
    int p = cnt + 1;
    int las = 1;
    int v = 2;
    for(int i = 2; i < n ; i ++ ){
        if(is[i]){
            for(int t = las + 1; t < i ; t ++ ){
                cout << p << " " << v << "\n";
                p ++ ;
            }
            las = i;
            v++;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
#pragma optimize("O3")
#define array vector<vector<int>>
#define thread sort
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (a - 1); i >= (b); i--)
#define all(a) (a).begin(), (a).end()
#define endl "\n"
#define ll long long
#define pb push_back
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vll vector<long long>
#define mii map<int, int>
#define mll map<long long, long long>
#define MOD 1000000007
#define MAX 1000000007
#define MOD2 1234567891
#define MOD3 998244353
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main() {
    int a, b;
    cin >> a >> b;
    int min1 = min(a, b), max1 = max(a, b);
    if ((max1 - min1) % 2 == 0) {
        cout << min1 + (max1 - min1) / 2;
    } else {
        cout << "IMPOSSIBLE";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>


using namespace std;



int main(){
    char x[8];
    int temp;
    cin>>temp;
    while(cin>>x[0]>>x[1]>>x[2]>>x[3]>>x[4]>>x[5]>>x[6]>>x[7]){
        int max=0;
        int min=0;
        int num[8];
        for(int i=0; i<8; i++)num[i]=x[i]-'0';
        sort(num, num+8);
        for(int i=7; i>=0; i--){
            max*=10;
            max+=num[i];
        }
        for(int i=0; i<8; i++){
            min*=10;
            min+=num[i];
        }
        cout<<max-min<<endl;
    }
}

Measured memory_bytes: 1176
#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>
#include<cstdio>

#include<string>
#include<cmath>
#include<map>
#include<cstdlib>
#include<deque>
#include<queue>
#include<climits>
#include<cstring>
using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j];
      if(j!=N-1) cout << " ";
      else cout << endl;
    }
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> T bsearch(T L, T R, const function<bool(T)>& can, bool left_feasible = true) {
    T& feasible = left_feasible ? L : R;
    T& infeasible = left_feasible ? R : L;
    while(R - L > 1) {
        T M = (L + R) / 2;
        (can(M) ? feasible : infeasible) = M;
    }
    return feasible;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> s(n), v(n);
    for(int i = 0; i < n; i++) {
        cin >> s[i] >> v[i];
    }
    vector<int> by_size(n), by_value(n);
    iota(by_size.begin(), by_size.end(), 0);
    sort(by_size.begin(), by_size.end(), [&](int i, int j) {
        return s[i] < s[j] or (s[i] == s[j] and v[i] < v[j]);
    });
    iota(by_value.begin(), by_value.end(), 0);
    sort(by_value.begin(), by_value.end(), [&](int i, int j) {
        return v[i] < v[j] or (v[i] == v[j] and s[i] < s[j]);
    });
    vector<int> c(m);
    for(int i = 0; i < m; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    cout << bsearch<int>(0, min(n, m) + 1, [&](int k) {
        vector<bool> dead(n);
        int sptr = n - 1, vptr = n - 1;
        for(int i = 0; i < k; i++) {
            while(sptr >= 0) {
                if(s[by_size[sptr]] > c[i]) {
                    dead[by_size[sptr]] = true;
                }
                if(dead[by_size[sptr]]) {
                    sptr--;
                } else {
                    break;
                }
            }
            if(sptr < 0) {
                return false;
            } else {
                while(dead[by_value[vptr]]) {
                    vptr--;
                }
                dead[by_value[vptr--]] = true;
            }
        }
        return true;
    }) << endl;
    return 0;
}



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

const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    ll n, k;
    cin >> n >> k;
    ll h[n];
    rep(i, n) cin >> h[i];
    sort(h, h + n);
    ll ans = 0;
    rep(i, n - k) ans += h[i];
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aman Kumar Singh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AOddsOfOddness solver = new AOddsOfOddness();
        solver.solve(1, in, out);
        out.close();
    }

    static class AOddsOfOddness {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int i = 0;
       int n = ni();
        double cnt = 0;
        for(i = 1; i <= (n); i++){
            if(i % 2 != 0)
                cnt++;
        }
        pn(cnt / n);
        }

        int ni() {
            return in.nextInt();
        }

        void pn(Object o) {
            out.println(o);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    vector<int> dp(k+1,false);
    for(int i=0;i<=k;i++){
        for(int x:arr){
            if(i>=x && !dp[i-x]){
                dp[i]=true;
            }
        }
    }
    if(dp[k])
    cout<<"First"<<endl;
    else 
    cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 3780
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	string s;
	cin >> s;

	if (s == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  map<ll, int> dmp;
  map<ll, int> tmp;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    dmp[x]++;
  }
  int m;
  cin >> m;
  for(int i = 0; i < m; i++){
    ll x;
    cin >> x;
    tmp[x]++;
  }
  for(auto itr = tmp.begin(); itr != tmp.end(); ++itr){
    ll val = itr->first;
    int count = itr->second;
    if(dmp[val] < count){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
	return 0;
}


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

int main(void){
  int H,W;
  string str;
  vector<string> C;
  cin >> H >> W;
  for(int i=0;i<H;i++){
    cin >> str;
    C.push_back(str);
  }

  for(int i=0;i<2*H;i++){
    cout << C[i/2] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	owo
	int n,q;
	cin>>n>>q;
	vector<ll>a(n+2),b(n+2);
	for(int i=0;i<=n;i++)a[i] = b[i] = n;
	ll ans = (n-2)*1LL*(n-2);
	int h,w;
	h = w = n;
	while(q--){
		int t,x;
		cin>>t>>x;
		if(t == 1){
			if(x<w){
			  for(int i=x;i<w;i++)a[i] = h;
			  w = x;
		    }
			ans-=a[x]-2;
		}else{
			if(x<h){
		       for(int i=x;i<h;i++)b[i] = w;
		       h = x;
		   }
		    ans-=b[x]-2;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 6232
#include <bits/stdc++.h>
#include <vector>
#include <queue>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

vector<int> children[100010];

int dfs(int par) {
    if (children[par].empty()) return 0;
    vector<int> v;
    for (auto ch : children[par]) {
        v.push_back(dfs(ch) + 1);
    }
    sort(all(v));

    REP(i, 1, v.size()) {
        if (v[i - 1] >= v[i]) v[i] = v[i - 1] + 1;
    }
    return *v.rbegin();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int par;
        cin >> par;
        children[par].push_back(i);
    }
    cout << dfs(1) << endl;
    return 0;
}



Measured memory_bytes: 13568
#pragma GCC optimize("Ofast")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define kd int
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
int main(){
    ios::sync_with_stdio(0);
    register int a,wh[9],b,e;
    cin>>a>>b>>e;
    fors(c,0,600){
        wh[1]=a+b+c;
        if(wh[1]<a+e) continue;
        fors(i,-100,200){
            wh[7]=a+e+i;
            if(wh[7]!=wh[1]) continue;
            fors(f,-100,200)
            {
                wh[6]=c+f+i;
                if(wh[6]!=wh[7]) continue;
                fors(d,-100,200){
                    wh[2]=d+e+f;
                    if(wh[2]!=wh[6]) continue;
                    fors(g,-100,200)
                    {
                        wh[4]=g+d+a;
                        wh[8]=c+e+g;
                        if((wh[8]!=wh[4])) continue;
                        fors(h,-100,200){
                            wh[3]=g+h+i;
                            wh[5]=b+e+h;
                            if((wh[3]!=wh[5]) || (wh[3]!=wh[4]) || (wh[3]!=wh[8])) continue;
                                cout<<a<<" "<<b<<" "<<c<<endl;
                                cout<<d<<" "<<e<<" "<<f<<endl;
                                cout<<g<<" "<<h<<" "<<i<<endl;
                                return 0;
                        }
                    }		
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

	int keta = 0;
	int n = 0;
	{
		long long t = N;
		while (t > 0)
		{
			n += t % 10;
			t /= 10;
			keta++;
		}
	}

	if (keta == 1)
	{
		cout << N << endl;
		return 0;
	}

	int ans = N / (pow(10, (keta - 1))) - 1;
	for (int i = 1; i < keta; i++)
	{
		ans += 9;
	}

	if (n > ans)
		ans = n;

	cout << ans << endl;

	return 0;
}

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

int main()
{
  string S ;
  cin>>S ;
  int SIZE=S.size() ;
  int count=0 ;
 
  for(int i=0;i<(SIZE/2);i++) if(S.at(i)!=S.at(SIZE-1-i)) count++ ;
  
  cout<<count<<endl ;
  return 0 ;
}

Measured memory_bytes: 256
# 約分して、互いに素な(1,3) (3,1)のようなペアを作りカウントする
# 正のグループと負のグループを別々に管理
# 正のグループの相手が負のグループに存在した場合、
# どちらかのグループから好きなだけ選ぶか、どちらも選ばないかしかない
# 誰ともペアにならなかったグループの個数を全て足してP個だとして、2^P通りを掛ける
# (0,0)については、その中から1つ選ぶか、選ばないかしかない

import sys
readline = sys.stdin.readline

N = int(readline())
import math

zeropair = 0
zeroa = 0
zerob = 0
from collections import defaultdict
pluspair = defaultdict(int)
minuspair = defaultdict(int)
for i in range(N):
  a,b = map(int,readline().split())
  if a == 0 and b == 0:
    zeropair += 1
    continue
  if a == 0:
    zeroa += 1
    continue
  if b == 0:
    zerob += 1
    continue
  absa = abs(a)
  absb = abs(b)
  g = math.gcd(absa,absb)
  absa,absb = absa//g,absb//g
  if a * b > 0:
    pluspair[(absa,absb)] += 1
  else:
    minuspair[(absa,absb)] += 1

DIV = 1000000007
ans = 1
# zeroa,zerobから選ぶパターンは、どちらから好きなだけ選ぶか、どちらも選ばないか
ans *= (pow(2,zeroa,DIV) + pow(2,zerob,DIV) - 1) % DIV
ans %= DIV

# 誰とでもペアになれるものをカウント
allcnt = 0

# plusから選ぶパターンで、minusにある対応ペアを探す
for item in pluspair.items():
  a,b = item[0]
  cnt = item[1]
  if (b,a) in minuspair:
    ans *= (pow(2,cnt,DIV) + pow(2,minuspair[(b,a)]) - 1) % DIV
    ans %= DIV
    del minuspair[(b,a)]
  else:
    allcnt += cnt

for val in minuspair.values():
  allcnt += val

ans = (ans * pow(2,allcnt,DIV)) % DIV
# zeropairから選んだ場合、今までのパターンとは独立
ans += zeropair
print((ans - 1) % DIV)


Measured memory_bytes: 44924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin >> n;
  bool exist=false;
  ll groups = 0, crr = 0;
  queue<ll> q, tpq;
  if(n>2){
    for(ll i=2;i<2*n;i++){
      if((2*n)%i!=0) continue;
      else{
        if(abs((2*n)/i - i) == 1) {
          groups = i;
          exist = true;
          break;
        }
      }
    }
  }

  if(exist){
    cout << "Yes" << endl;
    cout << 2*n/groups << endl;
    for(ll i=0;i<2*n/groups;i++){
      ll cnt = 0;
      cout << groups << " ";
      if(i == 0){
        for(crr=1;crr<=groups;crr++){
          cout << crr << " ";
        }
        cout << endl;
        q.push(1);
        continue;
      }
      while(!q.empty()){
        cnt += 1;
        cout << q.front() << " ";
        tpq.push(q.front() + 1);
        q.pop();
      }
      ll tar = crr + groups - cnt; 
      tpq.push(crr);
      for(;crr < tar; crr++){
          cout << crr << " ";
      }
      cout << endl;
      q = tpq;
      while(!tpq.empty()){
        tpq.pop();
      }
    }
  }else{
	if(n == 1){
      cout << "Yes" << endl;
      cout << 2 << endl;
      cout << 1 << " " << 1 << endl;
      cout << 1 << " " << 1 << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    if(N==1) cout << "Hello World" << endl;
    else{
        int A,B;
        cin >> A >> B;
        cout << A+B << endl;
    }



}


Measured memory_bytes: 256
def main():
    N, A, B = map(int, input().split())

    diff = B-A
    if diff % 2 == 0:
        print(diff//2)
    else:
        print(min(A-1,N-B) + 1 + (diff-1)//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940