akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int solve(vector<int> &D){
    ll ans=0;
    int N=D.size();
    for(int i=0;i<D.size();i++){
        if(D[i]==0) continue;
        int R=i;
        int check=(N-1)^R^(N-1-R);
        if(check==0) ans^=1;
    }
    return ans;
}

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

  int N;
  cin>>N;
  string S;
  cin>>S;

  vector<int> D;
  rep(i,N-1) D.push_back(abs(S[i]-S[i+1]));

  int two=0,one=0;
  rep(i,D.size()){
      if(D[i]==2) two++;
      else if(D[i]==1) one++;
  }

  if(two>0&&one>0){
      rep(i,D.size()) D[i]%=2;
  }else{
      rep(i,D.size()) if(D[i]!=0) D[i]=1;
  }

  int res=solve(D);
  int ans=res;
  if(one==0&&ans==1) ans=2;
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 8344
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    if (A > 9 || B > 9) {
        cout << -1 << endl;
    }
    else {
        cout << A * B << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10); x/=10;} reverse(all(res)); return res;}

void solve() {
  ll n; cin>>n; map<string,ll> paper;
  rep(i,n){
    string s; cin>>s;
    if(paper.count(s)) paper[s]++;
    else paper[s]=1;
  }
  ll x=0;
  for(auto p:paper){
    auto key=p.fi;
    auto value=p.se;
    chmax(x,value);
  }
  vector<string> v;
  for(auto p:paper){
    auto key=p.fi;
    auto value=p.se;
    if(value==x) v.eb(key);
  }
  sort(all(v));
  rep(i,(ll)v.size()) out(v[i]);
}

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


Measured memory_bytes: 25584
from collections import Counter

N = int(input())
S = [Counter(input()) for _ in range(N)]

INF = 55
memo = [INF] * 26
for s in S:
    for i in range(26):
        memo[i] = min(memo[i], s[chr(ord('a') + i)])

result = ""
for i in range(26):
    if memo[i] != 0:
        result += chr(ord('a') + i) * memo[i]

print(result)

Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int main(){
  int n,m,fl[32][32],i,j,x,y,r,p,q;
  int dx,dy;
  char d[4];
  while(scanf("%d",&n),n!=0){
    for(i=0;i<32;i++){
      for(j=0;j<32;j++){fl[i][j]=0;}
    }
    for(i=0;i<n;i++){
      scanf("%d%d",&x,&y);
      fl[x][y]++;
    }
    p=10;q=10;r=0;
    r+=fl[p][q];fl[p][q]=0;
    scanf("%d",&m);
    for(i=0;i<m;i++){
      scanf("%s%d",d,&j);
      if(d[0]=='N'){dx=0;dy=1;}
      if(d[0]=='E'){dx=1;dy=0;}
      if(d[0]=='W'){dx=-1;dy=0;}
      if(d[0]=='S'){dx=0;dy=-1;}
      while(j>0){
        j--;
        p+=dx;q+=dy;
        r+=fl[p][q];fl[p][q]=0;
      }
    }
    if(r==n){printf("Yes\n");}
    else{printf("No\n");}
  }
  return 0;
}



Measured memory_bytes: 2028
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[100+5];
 
 int main()
 {
   int n;
   cin>>n;
   for(int i=0;i<n;i++) cin>>arr[i];
   for(int i=0;i<n-1;i++) cout<<arr[i]<<" ";
   cout<<arr[n-1]<<endl;
   for(int i=1;i<n;i++)
   {
     int key=arr[i];
     int j=i-1;
     while(j>=0&&arr[j]>key)
     {
       arr[j+1]=arr[j];
       j--;                     
     }     
     j++;
     arr[j]=key;   
     for(int k=0;k<n-1;k++) cout<<arr[k]<<" ";
     cout<<arr[n-1]<<endl;
   }
   //while(1);
   return 0;
 }
 

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

using namespace std;

int dp[100000];

int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = 1; i < n; i++)
		if (i == 1)
			dp[i] = abs(h[i] - h[i - 1]);
		else
			dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	cout << dp[n - 1] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

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

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	ll x, k, d; cin>>x>>k>>d;
	x = abs(x);
	if(k > x/d){
		k -= x/d;
		if(k%2) cout<<(d - x%d);
		else cout<<x%d;
	}
	else cout<<x - k*d;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cout.setf(std::ios_base::fixed);
    cout.precision(6);
    cout.setf(std::ios_base::showpoint);
    vector< vector<ll> > C(51, vector<ll>(51));
    for (int i = 1; i < 51; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    double sr = 0.0;
    for (int i = 0; i < a; ++i)
        sr += v[i];
    sr /= (double) a;
    cout << sr << endl;
    ll sp = 0;
    if (v[0] == v[a - 1])
    {
        int nrP = 0;
        while (nrP < n && v[nrP] == v[0])
        ++nrP;
        --nrP;
        ll wlk = min(nrP, b - 1) + 1;
        for (int i = a; i <= wlk; ++i)
            sp += C[nrP + 1][i];
        cout << sp;
        return 0;
    }
    int nrL = a - 1;
    while (nrL >= 0 && v[nrL] == v[a - 1])
        --nrL;
        ++nrL;
    int nrP = a - 1;
    while (nrP < n && v[nrP] == v[a - 1])
        ++nrP;
        --nrP;
    ll wlk = a - 1 - nrL + 1;
    sp = C[nrP - nrL + 1][wlk];
    cout << sp;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		//sc??¨dice??????????????????????????????
		Scanner sc = new Scanner(System.in);
		Dice8 dice = new Dice8(sc);

		//????????°????????????????????°?????????
		int q = sc.nextInt();
		for(int i = 0; i < q; i++){

			//?????¢??¨?????¢???????????????
			int topNum = sc.nextInt();
			int frontNum = sc.nextInt();

			//Dice8?????????????????????searchRight???????????????????????????
			int ans = dice.searchRight(topNum, frontNum);
			System.out.println(ans);
		}
		sc.close();
	}
}

//?????????????????§????????????????????£???????????????????????§???????????????????????????
//???????????§??????????????????????????????????????????????????¨??§??????????????§?????????????????§????????????
//???????????????????????????????????????????????????????????????]

//??¢????????????????????????
//??¢?????°?????????????????????
//??¢???????????????????????????
class Dice8 {
	//?????£?????????
	private int[] dice = new int[6];

	//?????????????????????
	Dice8(Scanner scan){
		for(int i = 0; i < 6; i++){
			this.dice[i] = scan.nextInt();
			//????????????
			//System.out.println("this.dice[" + i + "]" + this.dice[i]);
		}
	}

	//???????????????????????\????????????
	void roll(char action){
		//??????????????´?????????????????????????????¢?????????
		int temp = dice[0];

		//????§??????¨??¢?????????????????????????????????????????????
		switch(action){
		case 'N':
			dice[0] = dice[1];
			dice[1] = dice[5];
			dice[5] = dice[4];
			dice[4] = temp;
			break;

		case 'S':
			dice[0] = dice[4];
			dice[4] = dice[5];
			dice[5] = dice[1];
			dice[1] = temp;
			break;

		case 'E':
			dice[0] = dice[3];
			dice[3] = dice[5];
			dice[5] = dice[2];
			dice[2] = temp;
			break;

		case 'W':
			dice[0] = dice[2];
			dice[2] = dice[5];
			dice[5] = dice[3];
			dice[3] = temp;
			break;

		default :
			break;
		}
	}


	//?????¢??¨?????¢?????°??????????????£????????´??¢?????°?????????????????????
	int searchRight(int topNum , int frontNum){

		//????????????????????????????????°
		char action = 'a';
		//?????¢?????°????????????????????????
		for(int i = 0; i < 8; i++){
			//????????????
			//System.out.println("?????????????????¢this.dice[1] = " + this.dice[1]);

			//??\?????????????????¢?????°??¨?????¨???????????????????????¢??????????????????????????????????????????
			if(frontNum == dice[1]){
				break;
				//????????\?????????????????¬'N'????????????
				//????????????3?????¢?????????????????´???????????¨???????¨???????????????¢?????????
			} else {
				if(i == 3){
					action = 'E';
					roll(action);
				} else {
					action = 'N';
					roll(action);
				}
			}
		}
		//?????¢????????????????????????
		for(int i = 0; i < 3; i++){
			//????????????
			//System.out.println("?????????????????¢this.dice[1]???= " + this.dice[0]);

			//??\?????????????????¢?????°??¨?????¨???????????????????????¢??????????????????????????????????????????
			if(topNum == dice[0]){
				break;
				//????????§?????????????¨?????????¢?????????
			} else {
				action = 'W';
				roll(action);
			}
		}

		return dice[2];
	}
}

Measured memory_bytes: 26108
import java.util.Scanner;

/**
 * TITLE : AC or WA
 * URL : https://atcoder.jp/contests/abc152/tasks/abc152_a
 */
public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        if (N == M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 105;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int a,b,c;
    int k;
    cin>>a>>b>>c>>k;
    int ba=0; 
    if(a>=b){
        ba = log2((a/b))+1;
    }
    int bn=b;
    for(int i=0;i<ba;i++){
        bn*=2;
    }

    int cb = 0;
    if(bn>=c){
        cb = log2((bn/c))+1;
    }    
    //cout<<a<<" "<<b<<" "<<c<<" "<<ba<<" "<<bn<<" "<<cb<<"\n";

    if(ba+cb<=k){
        cout<<"Yes\n";
    }
    else cout<<"No\n";

    return;
}
// how r u bro

Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
	int a,b,c,tem;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a > b){
		tem=a;
		a=b;
		b=tem;
			if(b > c){
				tem=b;
				b=c;
				c=tem;
					if(a > b){
						tem=a;
						a=b;
						b=tem;
					}
			}
	}
	
	else if(a < b){
		a=a;
		b=b;
			if(b > c){
				tem=b;
				b=c;
				c=tem;
					if(a > b){
						tem=a;
						a=b;
						b=tem;
					}
			}
	}
	
	printf("%d %d %d\n",a,b,c);
	
	
	return 0;
}


Measured memory_bytes: 2044
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  ll n, k;
  cin>>n>>k;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll m = 0;
  for(ll i=0; 1ll<<i <= k; i++) {
    if(1ll<<i & k)
      m = i;
  }
  vector<ll> v(m+1,0);
  for(ll i=0; i<=m; i++) {
    rep(j,n) {
      if(a[j] & 1ll<<i)
	v[i]++;
    }
  }
  rep(i,m+1) v[i]=n-v[i];
  ll x = 0;
  for(ll i=m; i>=0; i--) {
    if(v[i] > n/2 and x+(1ll<<i) <= k) {
      x += 1ll<<i;
    }
  }
  ll ans = 0;
  rep(i,n) ans += x^a[i];
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3672
using System;

namespace ForAtCoder
{
    class Program
    {
        static void Main()
        {
            string[] a = Console.ReadLine().Split(' ');

            int s = int.Parse(a[0]);
            int w = int.Parse(a[1]);

            if (s <= w)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }

}


Measured memory_bytes: 17840
n = int(input())
h = list(map(int,input().split()))
pre = h[-1]
ans = "Yes"
flag = False
count = 0
# 右のマスから調べていく
for i in range(-2,-n,-1):
  # if flag and pre - h[i] > 0:
  #   count += 1
  # if pre - h[i] > 0 and flag and count > 1:
  #   ans = "No"
  # elif pre - h[i] > 1:
  #   ans = "No"
  # if pre - h[i] < -1:
  #   flag = True
  if h[i] - pre == 1:
    h[i] = h[i] - 1
  elif h[i] - pre > 1:
    ans = "No"
  pre = h[i]
print(ans)

Measured memory_bytes: 14396
#include <iostream>
 
using namespace std;
 
int main(){
  int A, B;
  cin >> A >> B;
  A = (A==1) ? 14 : A;
  B = (B==1) ? 14 : B;
  if(A == B){
    cout << "Draw" << endl;
  }else if(A > B){
    cout  << "Alice" << endl;
  }else{
    cout  << "Bob" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int a,b;
	cin>>a>>b;
	if((a+b)%2==0){
		cout<<(a+b)/2<<endl;
	}
	else cout<<(a+b)/2+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <climits>
#include <random>
#include <algorithm>

#define int_max 2147483647;

void Problem_A(void)
{
    std::string str;
    std::cin>>str;

    int a = int(str[5])-48;
    int b = int(str[6])-48;

    int month =10*a+b;
    // std::cout<<month;
    if(month >= 5)
    {
        std::cout<<"TBD";
    }
    else
    {
        std::cout<<"Heisei";
    }
    return;
}

void Problem_B(void)
{

}
int main(int argc, char const *argv[])
{
    Problem_A();
    return 0;
}

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

typedef pair<long long, long long> data_t;

int main(){
  int n,m;
  cin>>n>>m;
  vector<string> a(n),b(m);
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<m;i++)
    cin>>b[i];
  int flag=0;
  string tmp;
  for(int i=0;i+m<=n;i++){
    for(int j=0;j+m<=n;j++){
      flag=0;
      for(int l=0;l<m;l++){
        tmp=a[i+l].substr(j,m);
        if(b[l]!=tmp){
          flag=1;
          break;
        }
      }
      if(flag==0){
      cout<<"Yes"<<endl;
      return 0;
    }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b=1;
    for(;;){
        cin>>a;
        if(a==0){
            break;
        }
        cout<<"Case "<<b<<": "<<a<<endl; //タイムアウトが多く答えが正しくならない
        b++;
    }
}



Measured memory_bytes: 3052
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N,K = LI()
    p = LI()

    p.sort()
    print(sum(p[:K]))
if __name__ == '__main__':
    main()

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

int main() {

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

    long long Ans = 0;


    vector<int> H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }

    sort(H.begin(),H.end());

    if(N <= K){
        Ans = 0;
    }else{
        for(int i = 0; i<K; i++){
            H.pop_back();
        }
        for(int i = 0; i<H.size(); i++){

            Ans += H[i];
        }
        
    }
    
    cout << Ans << endl;

}


Measured memory_bytes: 1024
s = input()
t = [0]*len(s)

for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        t[i] = 1

ans = []
tmp = 0
for j in t:
    if j == 1:
        tmp += 1
    else:
       ans.append(tmp)
       tmp = 0
ans.append(tmp)

print(max(ans))

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

 if((a+b)%2==0)

      {
           k=(a+b)/2;
          printf("%d",k);
      }
 else
       {
           printf("IMPOSSIBLE");
       }


return 0;
}


Measured memory_bytes: 128
n = int(input())
lis = list(map(int,input().split()))
lis[0]-=1
for i in range(n-1):
  if lis[i] < lis[i+1]:
    lis[i+1] -= 1
  elif lis[i] > lis[i+1]:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 20612
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, A, B = map(int, readline().split())
    print(min(A,B), max((A+B)-N, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
from scipy.sparse.csgraph import floyd_warshall

N,M,L = map(int,input().split())
abc = [[int(i) for i in input().split()] for j in range(M)]
Q = int(input())
st = [[int(i) for i in input().split()] for j in range(Q)]
INF = 1<<30
Path = [[INF for i in range(N)] for j in range(N)]
AnsPath = [[INF for i in range(N)] for j in range(N)]

def PathInit():
    for i in range(N):
        Path[i][i] = 0

PathInit()
for i,j,k in abc:
    Path[i-1][j-1] = k
    #双方向
    Path[j-1][i-1] = k

Path = floyd_warshall(Path)

for i in range(N):
    for j in range(N):
        if Path[i][j] <= L:
            AnsPath[i][j] = 1
AnsPath = floyd_warshall(AnsPath)
for s,t in st:
    if AnsPath[s-1][t-1] == INF:
        print(-1)
    else:
        print(int(AnsPath[s-1][t-1]-1))

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


int main(void){
   int N;
   cin>>N;
   long long mod=1000000007;
   vector<long long> A(N);
   for(int i=0;i<N;i++){
      cin>>A[i];
   }
   vector<long long> sum(N+1);
   sum[0]=0;
   for(int i=0;i<N;i++){
      sum[i+1]=(sum[i]+A[i])%mod;
   }
   
   long long ans=0;
   for(int i=0;i<N-1;i++){
      ans+=A[i]*sum[N]%mod;
      ans-=A[i]*sum[i+1]%mod;
   }
   if(ans<0){
      cout<<ans%mod+mod<<endl;
   }else{
      cout<<ans%mod<<endl;
   }
   return 0;
}


Measured memory_bytes: 6324
#include <stdio.h>
#include <math.h>

int main(){
  int n, x[1024], y[1024];
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d", &x[i]);
  for(int i = 0; i < n; i++) scanf("%d", &y[i]);
  double p1 = 0, p2 = 0, p3 = 0, pm = 0, z;
  for(int i = 0; i < n; i++){
    if(x[i] > y[i]) z = x[i] - y[i];
    else z = y[i] - x[i];
    p1 += z;
    p2 += pow(z, 2);
    p3 += pow(z, 3);
    if(pm < z) pm = z;
  }
  p2 = pow(p2, (double)1/2);
  p3 = pow(p3, (double)1/3);
  printf("%lf\n%lf\n%lf\n%lf\n", p1, p2, p3, pm);
}



Measured memory_bytes: 2868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll power( ll a , ll n)
{
    if( a==0 )return 0;
    if( n== 0)
    {
        return 1;
    }
    ll small = power( a , n/2);
    if( n%2 )
    {
        return small * small * a;
    }
    return small * small;
}

map<ll,ll> prime_factors( ll n)
{
    map <ll, ll> m;
    while( n%2 ==0 )
    {
        n = n/2;
        m[2] ++;
    }
    for(int i=3;i<= sqrt( n);i = i+ 2)
    {
        while( n%i == 0)
        {
            n = n/i;
            m[i] ++;
        }
    }
    if( n != 1)
    {
        m[n] ++;
    }
    return m;
}
int main()
{
    ll n,p;
    cin>>n>>p;
    map<ll,ll> m = prime_factors( p );
    map<ll,ll> ::iterator it = m.begin() ;
    ll ans =1;

    while( it != m.end() )
    {
        ans = ans * power (it->first , it->second / n );
        it++;
    }
    cout<<ans;
}


Measured memory_bytes: 3660
#include <iostream>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//#include <string>
typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    LL n;
    LL k;
    LL ans=0;
    vector<LL> h;
    LL tmp_h;
    cin >> n >> k;
    for(LL i=0; i<n; i++){
        cin >> tmp_h;
        h.push_back(tmp_h);
    }
    if(n>k){
        sort(h.begin(),h.end());
        for(LL i=0; i<n-k; i++){
            ans+=h[i];
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string N; cin >> N;
  int l = N.size();
  int K; cin >> K;
  string zero; rep(i,l) zero += '0';
  vector<int> nz; rep(i,l) if (N[i]!='0') nz.push_back(i);

  ll result = 0;
  if (K==1) result = (N[0]-'0') + (l-1)*9;
  else if (K==2) {
    repr(i,1,l) {
      repr(in,1,10) {
        string tmp = zero;
        string ln = ""; ln += ('0'+in);
        tmp.replace(0,1,N.substr(0,1)); tmp.replace(i,1,ln);
        if (tmp<=N) result++;
      }
    }
    result += (N[0]-'1') * ((l-1)*9);
    result += (l-1)*(l-2)/2*9*9;
  }
  else if (K==3) {
    repr(i,1,l) repr(j,i+1,l) {
      repr(in,1,10) repr(jn,1,10) {
        string tmp = zero;
        string ln = "", rn = ""; ln += ('0'+in); rn += ('0'+jn);
        tmp.replace(0,1,N.substr(0,1)); tmp.replace(i,1,ln); tmp.replace(j,1,rn);
        if (tmp<=N) result++;
      }
    }
    result += (N[0]-'1') * (l-1)*(l-2)/2*9*9;
    result += (l-1)*(l-2)*(l-3)/6*9*9*9;
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
//https://stackoverflow.com/questions/31065929/number-of-common-sub-sequences-of-two-strings
//https://www.geeksforgeeks.org/count-common-subsequence-in-two-strings/

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next(
    		) throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}

public class Main {
	
	static int mod=1000000007;
	
	public static void main(String[] args) throws IOException{
		Reader.init(System.in);
		int N=Reader.nextInt();
		int M=Reader.nextInt();
		int S[]=new int[N];
		int T[]=new int[M];
		for(int i=0;i<N;i++) {
			S[i]=Reader.nextInt();
		}
		for(int i=0;i<M;i++) {
			T[i]=Reader.nextInt();
		}
		long result=commonSubsequence(S,T, N, M);
		System.out.println(result);
	}

	private static long commonSubsequence(int[] s, int[] t, int n, int m) {
		long dp[][]=new long[n+1][m+1];
		
		for(int i=0;i<=n;i++) {
			dp[i][0]=1;
		}
		for(int j=0;j<=m;j++) {
			dp[0][j]=1;
		}
		
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=m;j++) {
				if(s[i-1]==t[j-1]) {
					dp[i][j]=dp[i][j-1]+dp[i-1][j];
				}
	            else {
	            	dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1]+mod;
	            }
				dp[i][j]%=mod;
			}
		}
		return dp[n][m];
	}
	
}

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

int main()
{
	std::string s; std::cin >> s;
	int ans = 0;
	char s0 = s[0];
	for(int i=1; i<s.size(); i++)
	{
		if(s0!=s[i])
		{
			ans++;
			s0 = s[i];
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 512
while True:
	x, y = map(int,raw_input().split())
	lst = range(x,0,-1)
	if x == 0 and y == 0:
		break
	lst = range(x,0,-1)	
	for i in range(y):
	    c = []
	    a,b = map(int,raw_input().split())
	    for f in range(b):
	    	c.append(lst.pop(a-1))
	    lst = c + lst
	print lst[0]

Measured memory_bytes: 6244
#include <stdio.h>

int main(int argc, const char * argv[])
{

    int sum;
    int cnt = 0;
    int i, j, k, l;
    
    while (scanf("%d", &sum) != EOF) {
        for (i = 0; i < 10; i++) {
            for (j = 0; j < 10; j++) {
                for (k = 0; k < 10; k++) {
                    for (l = 0; l < 10; l++) {
                        if (i + j + k + l == sum) {
                            cnt++;
                            break;
                        }
                    }
                }
            }
        }
        printf("%d\n", cnt);
        cnt = 0;
    }
    return 0;
}

Measured memory_bytes: 592
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		String X =nextString();
		int s = 0;
		int t = 0;
		int remCnt=0;
		for(int i=0;i<X.length();i++) {
			if(X.charAt(i)=='S') {
				s++;
			}else {
				if(s!=0) {
					s--;
					remCnt+=2;
				}else {
					t++;
				}
			}
		}
		pw.println(X.length()-remCnt);
	}



	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

  vector<int> a(n);
  set<int> st;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    st.insert(a[i]);
  }

  string ans;
  if (st.size() == a.size()) {
    ans = "YES";
  } else {
    ans = "NO";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int N; cin >> N;
  vector <int> A(N);
  int odd = 0, even = 0;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    if (A[i] % 2 != 0){
      odd++;
    }else{
      even++;
    }
  }

  if (odd == 0){
    cout << "second" << endl;
  }else{
    cout << "first" << endl;
  }
  



  return 0;
}


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

//O(VE)

class BellmanFord {
private:
  struct edge {
    int from, to, cost;
  };

  const int INF = 1e18;
  int V, E;
  vector<edge> es;
  vector<int> d;

  void add_edge(int from, int to, int cost) {
    es.push_back({from, to, cost});
  }
  bool shortest_path(int s) {
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    for (int i = 0; i < V; i++) {
      bool update = false;
      for (auto e : es) {
        if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
          d[e.to] = d[e.from] + e.cost;
          update = true;
          if (i == V - 1) return false;
        }
      }
      if (!update) break;
    }
    return true;
  }
  int get_shortest_dist(int v) {
    return d[v];
  }

public:
  BellmanFord(int V, int E) : V(V), E(E), es(E), d(V) {}

  void addEdge(int from, int to, int cost) { return add_edge(from, to, cost); }
  bool init(int s) { return shortest_path(s); }
  int dist(int v) { return get_shortest_dist(v); }
};

signed main() {
  int V, E, r;
  cin >> V >> E >> r;

  BellmanFord bf(V, E);

  for (int i = 0; i < E; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    bf.addEdge(s, t, d);
  }

  if (!bf.init(r)) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }

  for (int i = 0; i < V; i++) {
    int dist = bf.dist(i);

    if (dist == 1e18) {
      cout << "INF" << endl;
    } else {
      cout << dist << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

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

	int n;
	cin >> n;
	if (n > 999)
		cout << "ABD\n";
	else
		cout << "ABC\n";
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

bool is_cyclic_impl(ll node, const vector<vector<ll>>& edges, vector<int>& status, vector<ll>& result) {
	if (status[node] == 1) return true;
	if (status[node] == 0) {
		status[node] = 1;
		for (ll i = 0; i < edges[node].size(); ++i) {
			if (is_cyclic_impl(edges[node][i], edges, status, result)) return true;
		}
		status[node] = 2;
		result.emplace_back(node);
	}

	return false;
}

bool is_cyclic(const vector<vector<ll>>& edges, vector<int>& status, vector<ll>& result) {
	for (ll i = 0; i < edges.size(); ++i) {
		if (status[i] == 0 && is_cyclic_impl(i, edges, status, result)) return true;
	}
	reverse(result.begin(), result.end());
	return false;
}

int solve() {
	ll K;
	string S;
	cin >> K >> S;

	cout << S.substr(0, K);
	if (S.size() > K) {
		cout << "...";
	}
	cout << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3652
X, N = map(int,input().split())

p = list(map(int,input().split()))
dev = []
mini = 0

for i in range(N):
    dev.append(abs(X-p[i]))

#print(dev)
for i in range(N):
    if mini == dev[i]:
        break
else:
    print(X)
    exit()

mini +=1
while True:
    check = 0
    temp = 0
    for i in range(N):
        if mini==dev[i]:
            if check == 1:
                mini +=1
                break
            else:
                check +=1
                temp = p[i]
    else:
        if X-temp < 0 or temp ==0:
            print(X-mini)
            exit()
        else:
            print(X+mini)
            exit()

Measured memory_bytes: 9224
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  ll ans = 0;
  int num = INF;
  rep(i,n){
    if(a[i] == 0) continue;
    if(num+1 == i){
      a[i]--;
      ans++;
    }
    if(a[i] % 2){
      a[i]--;
      num = i;
    }
    ans += a[i]/2;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


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

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

class Mint{
    public:
    int v;
    const long long MOD = 1000000007;
    Mint():v(0){}
    Mint(signed v):v(v){}
    Mint(long long t){v=t%MOD; if(v<0)v+=MOD;}

    Mint pow(long long k){
        Mint res(1), tmp(v);
        while(k){
            if(k&1)res*=tmp;
            tmp*=tmp;
            k>>=1;
        }
        return res;
    }
    Mint inv(){return pow(MOD-2);}

    Mint& operator+=(Mint a){v+=a.v; if(v>=MOD)v-=MOD; return *this;}
    Mint& operator-=(Mint a){v+=MOD-a.v; if(v>=MOD)v-=MOD; return *this;}
    Mint& operator*=(Mint a){v=1LL*v*a.v%MOD; return *this;}
    Mint& operator/=(Mint a){return (*this)*=a.inv();}

    Mint operator+(Mint a) const{return Mint(v)+=a;};
    Mint operator-(Mint a) const{return Mint(v)-=a;};
    Mint operator*(Mint a) const{return Mint(v)*=a;};
    Mint operator/(Mint a) const{return Mint(v)/=a;};

    Mint operator-(){return v ? MOD-v : v;}
    bool operator==(Mint a)const{return v==a.v;}
    bool operator!=(Mint a)const{return v!=a.v;}

    Mint operator=(Mint a) {v=a.v;return a;}

    friend ostream& operator<<(ostream& os, const Mint& mint){
        os << mint.v;
        return os;
    }
};

class cmbs{
    public:
    vector<Mint> fact, finv, inv;
    cmbs(){
        fact.clear(); finv.clear(); inv.clear();
    }
    void init(int n){
        if(n+1 <= (signed)fact.size())return;
        fact.assign(n+1,1);
        finv.assign(n+1,1);
        inv.assign(n+1,1);

        for(int i=1; i<=n; i++) fact[i] = fact[i-1]*Mint(i);
        finv[n] = Mint(1)/fact[n];
        for(int i=n; i>=1;i--) finv[i-1] = finv[i]*Mint(i);
        for(int i=1; i<=n; i++) inv[i] = finv[i]*fact[i-1];
    }
    Mint comb(long long n, int k){
        if(n<k||k<0)return Mint(0);
        Mint res(1);
        for(int i=0; i<k; i++){
            res *= Mint(n-i);
            res /= Mint(i+1);
        }
        return res;
    }
    Mint C(int n,int k){
        if(n<k||k<0)return Mint(0);
        init(n);
        return fact[n]*finv[n-k]*finv[k];
    }
    Mint P(int n, int k){
        if(n<k || k<0)return Mint(0);
        init(n);
        return fact[n]*finv[n-k];
    }
    Mint H(int n, int k){
        if(n<0||k<0)return Mint(0);
        if(!n&&!k)return Mint(1);
        init(n+k-1);
        return C(n+k-1,k);
    }
};

int main(){
    ll n,k;
    cin>>n>>k;
    cmbs cmb;
    cout<<cmb.H(k,n)<<endl;
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

void divisor(ll n, vector<ll>& div) {
    for(ll i = 1; i * i <= n; i++) {
        if(n%i == 0) {
            div.push_back(i);
            if(n != i * i) div.push_back(n/i);
        }
    }
    sort(div.begin(), div.end());
}

signed main() {

    ll n;
    vector<ll> div_n, div_n_1;
    cin >> n;

    divisor(n, div_n);
    divisor(n-1, div_n_1);
    
    int cnt = 0;

    for(auto&&x:div_n) {
        if(x == 1) continue;
        ll t = n;
        while(t%x == 0) t /= x;
        if(t%x == 1) cnt++;
    }

    cout << cnt + (int)div_n_1.size() -1 << endl;
  
    return 0;
}



Measured memory_bytes: 384
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))
#define all(x) (x).begin(), (x).end()

#define fr first
#define se second

const ll mod = 1000000007;

inline ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

inline ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

inline ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

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

	int n;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	double res = 0;
	for(int i=0; i<n; i++) {
		res += 1.0 / a[i];
	}
	cout << fixed << setprecision(12) << 1/res << endl;

	return 0;
}

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

int main()
{
  int color[8] = {};
  int free = 0;
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    int a;
    cin >> a;
    if (a < 3200)
      ++color[a/400];
    else
      ++free;
  }
  int sum = 0;
  for (int i = 0; i < 8; ++i)
    if (0 < color[i])
      ++sum;
  cout << ((0 == sum) ? 1 : sum) << " " << (sum + free);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	string S1;
	string S2;
	string S3;
    
	cin >> S1 >> S2 >> S3;

	if (S1.at(S1.size() - 1) == S2.at(0) && S2.at(S2.size() - 1) == S3.at(0)) {
		cout<<"YES"<<endl;

	}

	else {
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 20;

int main(){
  int r, D, x;
  cin >> r >> D >> x;
  rep(i, 10){
    x = r*x - D;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
object Main extends App {
	val Array(h, w) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val dp = Array.ofDim[Char](h, w)

	for(i<-0 until h){
		dp(i) = scala.io.StdIn.readLine.toList.toArray
	}

	println(Array.fill(w+2)("#").mkString)
	for(i<-0 until h){
		println("#" + dp(i).mkString + "#")
	}
	println(Array.fill(w+2)("#").mkString)
}


Measured memory_bytes: 31916
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
    
        
        sc.close();

        boolean bool = false;
        int n = N % 10;
        if(n==7){
            bool = true;
        }
        n = N / 10;
        n = n % 10;
        if(n == 7){
            bool = true;
        }
        n = N / 100;
        if( n == 7){
            bool = true;
        }

        if(bool){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}      


Measured memory_bytes: 35832
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

int main() {
    int N, L;
    cin >> N >> L;
    string S[101];
    rep(i, N)cin >> S[i];
    sort(S, S + N);
    string sumS;
    rep(i, N)sumS += S[i];
    cout << sumS << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node{int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if (T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
    if (T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
    return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibiling(int u){
    if (T[u].parent == NIL) return NIL;
    if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
    if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibiling(u));
    int deg = 0;
    if (T[u].left != NIL) deg++;
    if (T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);
    
    if (T[u].parent == NIL) printf("root\n");
    else if (T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
    else printf("internal node\n");
}

int main(){
    int v, l, r, root = 0;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) T[i].parent = NIL;
    for (int i = 0; i < n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if (l != NIL) T[l].parent = v;
        if (r != NIL) T[r].parent = v;
    }
    
    for (int i = 0; i < n; i++) if (T[i].parent == NIL) root = i;
    
    setDepth(root, 0);
    setHeight(root);
    
    for (int i = 0; i < n; i++) print(i);
    
    return 0;
}



Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  vector<int> count(n+1,0);
  for(int i=0;i<n-1;i++)
  {
    int x;cin>>x;
    count[x]++;
  }
  for(int i=1;i<=n;i++)
    cout<<count[i]<<endl;
  return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
ll mod=1000000007;

int main() {
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    if(n&1){
        double ans=(n/2)+1;
        ans=ans/(double)n;
        cout<<ans;
    }
    else{
        double ans=n/2;
        ans=ans/(double)n;
        cout<<ans;
    }

	return 0;
}


Measured memory_bytes: 256