akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
    bool cards[4][14];
    int n, rank;
    char suit;
    cin >> n;
    for (int s = 0;s < 4;s++){
        for (int r = 1;r <= 13;r++){
            cards[s][r] = 0;
        }
    }
    
    for(int i = 0;i < n;i++){
        cin >> suit >> rank;
        if (suit == 'S') cards[0][rank] = 1;
        if (suit == 'H') cards[1][rank] = 1;
        if (suit == 'C') cards[2][rank] = 1;
        if (suit == 'D') cards[3][rank] = 1;
    }
    
    for ( int s = 0;s < 4;s++){
        for (int r = 1;r <= 13;r++){
            if(cards[s][r])continue;
            if(s == 0) suit = 'S';
            if(s == 1) suit = 'H';
            if(s == 2) suit = 'C';
            if(s == 3) suit = 'D';
            cout << suit << " " << r << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int gcd(int a, int b)
{
    int x = max(a, b),
        y = min(a, b);
    if (x % y == 0)
        return y;
    else
        return gcd(y, x % y);
}

int main()
{
    int n;
    cin >> n;
    int cd = 0;
    repi(i, n, 0)
    {
        int a;
        cin >> a;
        if (i > 0)
        {
            cd = gcd(cd, a);
        }
        else
        {
            cd = a;
        }
    }
    cout << cd << endl;
    return 0;
}

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

def main():
    d = deque(list(input().strip('\n')))
    c = 0
    while len(d) > 1:
        if d.popleft() != d.pop():
            c += 1
    print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> vec;
  queue<int> qe;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    for (int j = 0; j < a; ++j)
      qe.push(i);
  }

  vector<vector<int>> ans(h, vector<int>(w, 0));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (i % 2 == 0)
        ans[i][j] = qe.front();
      else
        ans[i][w - j - 1] = qe.front();
      qe.pop();
    }
  }

  for (auto &row : ans) {
    cout << row[0];
    for (int i = 1; i < int(row.size()); ++i)
      cout << " " << row[i];
    cout << endl;
  }
}


Measured memory_bytes: 3620
n = gets.chomp.to_i

map = []
n.times do |i|
  map << gets.chomp.chars.map(&:ord)
end
rmap = map.transpose

cnt = 0

n.times do
  cnt += 1 if map == rmap
  map.rotate!
  rmap.map!(&:rotate!)
end

puts cnt * n

Measured memory_bytes: 5628
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll ans = 0;
ll n;

void dfs(string num, bool a, bool b, bool c) {
    if (stol(num) > n) return;
    if (a && b && c) ans++;
    dfs(num + '3', true, b, c);
    dfs(num + '5', a, true, c);
    dfs(num + '7', a, b, true);
}

void solve() {
    dfs("3", true, false, false);
    dfs("5", false, true, false);
    dfs("7", false, false, true);
    cout << ans << endl;
}

int main() {
    cin >> n;
    solve();
    return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	template<typename T> inline int ts(T *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 250007;
const lint bas = 250007 , mo = 2059392230891;

inline lint sfx(lint a,lint b)
{
	a%=mo,b%=mo;
	return (a*b-(lint)((louble)a/mo*b+0.5)*mo+mo)%mo;
}

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=sfx(a,b);a=sfx(a,a),t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

const lint ibas = inva(bas);

int n;char s[_];
lint loc[_];
unordered_map<lint,int> cnt;

inline lint trans(lint h,char op)
{
	if(op=='<')return sfx(h,ibas);
	if(op=='>')return sfx(h,bas);
	if(op=='+')return (h+1)%mo;
	if(op=='-')return (h-1+mo)%mo;
	throw "fuck me";
}

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);
	
	n=ty(),ts(s+1);

	loc[0]=1;
	for(int i=1;i<=n;i++)
	{
		loc[i]=loc[i-1];
		if(s[i]=='<')loc[i]=sfx(loc[i],ibas);
		if(s[i]=='>')loc[i]=sfx(loc[i],bas);
	}

	lint tar=0;
	for(int i=n;i>=1;i--)tar=trans(tar,s[i]);
	cnt[0]=1;
	lint ans=0,now=0;
	for(int i=n;i>=1;i--)
		now=trans(now,s[i]),ans+=cnt[sfx(now-tar+mo,loc[i-1])],cnt[sfx(now,loc[i-1])]++;
	cout<<ans<<lf;
	
	return 0;
}


Measured memory_bytes: 22132
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll x, a, b;
  cin >> x >> a >> b;

  string ans = "dangerous";
  if (b <= a)
    ans = "delicious";
  else if (b - a <= x) ans = "safe";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
ll binpow(ll x,ll y){
    ll res=1;
    x%=mod;
    while(y>0){
        if(y&1)
            res=(res*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return res;
}
ll modinv(ll a,ll m){
    assert(m>0);
    if(m==1)
        return 0;
    a%=m;
    if(a<0)
        a+=m;
    assert(a!=0);
    if(a==1)
        return 1;
    return m-modinv(m,a)*m/a;
}
ll mulmod(ll a,ll b){
    ll res=0;
    a%=mod;
    while(b){
        if(b&1)
            res=(res+a)%mod;
        a=(2*a)%mod;
        b>>=1;
    }
    return res;
}
ll binomialCoeff(ll n, ll r){  
    if(r>n-r)r=n-r;
    ll ans=1;
    for(ll i=0;i<r;i++){
        ans = mulmod(ans,n-i);
        ans = mulmod(ans,modinv(i+1,mod));
    }
    return ans%mod;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,a,b,ans;
    cin>>n>>a>>b;
    ans = (binpow(2,n)%mod-binomialCoeff(n,a)%mod-binomialCoeff(n,b)%mod-1)%mod;
    if(ans<0)
        ans+=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//AtCoder ABC084 Contest
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;

int main(){
    lld t;
    t=1;
    while(t--){
        lld n;
        cin>>n;
        vector<pair<lld,pair<lld,lld > >  > v;
        v.resize(n+2); 
        for(lld i=1;i<=n-1;i++){
            cin>>v[i].first>>v[i].second.first>>v[i].second.second;
        }
        vector<lld > ans(n);
        for(lld i=1;i<=n-1;i++){
            lld tm=v[i].first+v[i].second.first;
            lld j=i+1;
            while(j<=n-1){
                if(tm<v[j].second.first){
                    tm+=(v[j].second.first-tm);
                }
                else{
                    lld rem=tm%(v[j].second.second);
                    if(rem!=0){
                        tm+=(v[j].second.second-rem);
                    }
                }
                
                tm+=v[j].first;
                j++;
            }
            cout<<tm<<"\n";
        }
        cout<<0<<"\n";
    }
}

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

int main(){
	int cntA[2]={0},cntB[2]={0},cntC[2]={0},cntD[2]={0};
	double right,left;
	while(cin>>left){
		cin>>right;
		if(right>=1.1)cntA[0]++;
		else if(right>=0.6)cntB[0]++;
		else if(right>=0.2)cntC[0]++;
		else cntD[0]++;
		if(left>=1.1)cntA[1]++;
		else if(left>=0.6)cntB[1]++;
		else if(left>=0.2)cntC[1]++;
		else cntD[1]++;
	}
	cout<<cntA[1]<<" "<<cntA[0]<<endl;
	cout<<cntB[1]<<" "<<cntB[0]<<endl;
	cout<<cntC[1]<<" "<<cntC[0]<<endl;
	cout<<cntD[1]<<" "<<cntD[0]<<endl;
	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
int x, y, a, b, c;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  cin >> a >> b >> c >> x >> y;
  int ans = INT_MAX;
  rep(xy, 0, max(x, y) + 1) {
  	int rx = max(0, x - xy);
  	int ry = max(0, y - xy);
		ans = min(ans, rx * a + ry * b + xy * c * 2);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) if(isDebugMode) cout<<#x<<"="<<x<<","
#define debugarr(arr,N,M){if(isDebugMode) rep(i,N+1){rep(j,M+1)\
	{if(arr[i][j]==INF)printf(" INF");\
		else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};

bool isDebugMode=true;
//--------------------------------------//
int r;

int main(){
	cin>>r;
	if(r<1200) cout<<"ABC"<<endl;
	else if(r<2800) cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    if N == 1:
        ans = A[0] // 2
    else:
        ans = 0
        for i in range(N - 1):
            if A[i + 1] == 0:
                ans += A[i] // 2
            else:
                s = A[i] + A[i + 1]
                q, r = divmod(s, 2)
                ans += q
                A[i + 1] = r

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12756
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int main() {
    int N;
    cin >> N;
    map<string, int> ma;
    rep(i, N) {
        string s;
        cin >> s;
        ma[s]++;
    }

    cout << "AC"
         << " "
         << "x"
         << " " << ma["AC"] << endl;
    cout << "WA"
         << " "
         << "x"
         << " " << ma["WA"] << endl;
    cout << "TLE"
         << " "
         << "x"
         << " " << ma["TLE"] << endl;
    cout << "RE"
         << " "
         << "x"
         << " " << ma["RE"] << endl;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Mod=1e9+7;
int n,m,N,a[110000],dp[1100][1100],sum[110000];
bool vis[110000];
ll fac[110000],inv[110000],f[21][110000],ans;
inline bool cmp(int a,int b){ return a>b;}
inline int ADD(int x){
	if (x>=Mod) x-=Mod;
	return x;
}
inline int MINUS(int x){
	if (x<0) x+=Mod;
	return x;
}
ll C(ll n,ll m){
	if (n<m) return 0ll;
	return fac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
int main(){
	fac[0]=1; for (int i=1;i<=100000;++i) fac[i]=fac[i-1]*i%Mod;
	inv[1]=1; for (int i=2;i<=100000;++i) inv[i]=(Mod-Mod/i)*inv[Mod%i]%Mod;
	inv[0]=1; for (int i=2;i<=100000;++i) inv[i]=inv[i-1]*inv[i]%Mod;
	sum[0]=0; for (int i=1;i<=100000;++i) sum[i]=sum[i>>1]+(i&1);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) scanf("%d",&a[i]);
	sort(a+1,a+m+1,cmp);
	f[0][0]=1; N=(1<<n);
	for (int i=1;i<=m;i++)
		for (int j=0;j<N;j++){
			f[i][j]=f[i-1][j];
			for (int k=0;k<n;k++){
				int S=(1<<k);
				if (j&S) f[i][j]=ADD((ll)f[i-1][j^S]*C(N-(j^S)-a[i],S-1)%Mod*fac[S]%Mod+f[i][j]);
			}
		}
	for (int j=0;j<N;j++){
		int tot=sum[j]; 
		if (tot&1) ans=MINUS(ans-(ll)fac[N-j-1]*f[m][j]%Mod);
		else ans=ADD(ans+(ll)fac[N-j-1]*f[m][j]%Mod);
	}
	printf("%lld\n",ans*N%Mod);
	return 0;
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define fi first
#define se second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}


clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
const int N = 100100;
ll mod=1000000007;
ll a[N],b[N],c[N];
void solve(){
	int n;
	cin>>n;
	for(int i = 0; i <= n; i++){
		cin>>a[i];
	}
	if(n == 0){
		if(a[0] == 1){
			cout<<"1"<<nl;
			return;
		}
		else{
			cout<<"-1"<<nl;
			return;
		}
	}
	for(int i = n -1 ; i >= 0; i--){
		c[i] = c[i+1] + a[i+1];
		b[i] = (b[i+1] + a[i+1] + 1)/2;
		assert(b[i]<=c[i]);
	}
	
	for(int i = 0; i <= n and i <= 60; i++){
		c[i] = min(c[i], (1ll<<i) - a[i]);
	}

	for(int i = 1; i <= n; i++){
		c[i] = min(c[i],2*c[i-1] - a[i]);
	}

	for(int i = 0; i <= n; i++){
		if(c[i] < b[i]){
			cout<<"-1"<<nl;
			return;
		}
	}

	ll ans = 0;

	for(int i= 0; i <=n; i++){
		ans+=c[i] +a[i];
	}
	cout<<ans<<nl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	startTime = clock();
	solve();
	return 0;
}



Measured memory_bytes: 5972
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    int N,A;
    cin >> N >> A;
    if (N%500<=A){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
input = STDIN.gets.split(" ")
n = input[0].to_i
m = input[1].to_i
mat = Array.new(n) { Array.new(m) }
vec = Array.new(m)

for i in 1..n
  a = gets.split.map {|s| s.to_i}
  mat[i-1] = a
end

for i in 1..m  do
  j = gets.to_i
  vec[i-1] = j
end

for i in 1..n
  s = 0
  for j in 1..m
    s += mat[i-1][j-1] * vec[j-1]
  end
  puts s
end


Measured memory_bytes: 7052
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1000,inf=0x3f3f3f3f;
char maze[maxn][maxn];
int h,w,ans=0;
void dfs(int x,int y,char sig){
	maze[x][y]='.';
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(i*j==0){
				int nx=x+i,ny=y+j;
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&maze[nx][ny]==sig)
					dfs(nx,ny,sig);
			}
		}
	}
}
int main()
{
	//freopen("read.txt", "r", stdin);
	while(cin>>h>>w&&h&&w){
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				cin>>maze[i][j];
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++){
				if(maze[i][j]!='.'){
					char c=maze[i][j];
					dfs(i,j,c);
					ans++;
				}
			}
		cout<<ans<<endl;
ans=0;
	}
	//fclose(stdin);
	return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int binpow(int a, int 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;
}
const int FACTSIZE = 200100;
int fact[FACTSIZE];
int revfact[FACTSIZE];

int ncr(int n, int r) {
  if (n < r)
    return 0;
  int rs = fact[n] * revfact[r];
  if (rs >= MOD)
    rs %= MOD;
  rs *= revfact[n - r];
  if (rs >= MOD)
    rs %= MOD;
  return rs;
}
void init() {
  fact[0] = 1, revfact[0] = 1;
  for (int i = 1; i < FACTSIZE; ++i) {
    fact[i] = fact[i - 1] * i % MOD;
    revfact[i] = binpow(fact[i], MOD - 2, MOD);
  }
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  init();
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  int ans = 0;
  REP(i, H - A) {
    int tmpans =
        ncr((B - 1) + i, i) * ncr((W - B - 1) + (H - 1 - i), H - 1 - i);
    // DEBUG(tmpans);
    ans += tmpans;
    ans %= MOD;
  }
  print(ans);
}

Measured memory_bytes: 3456
import java.util.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    String[] str = (sc.next()).split(",");
	    int[] hand = new int[5];
	    for(int i = 0; i < 5; i++)
		hand[i] = Integer.parseInt(str[i]);
	    Arrays.sort(hand);
	    String res;

	    if(straight(hand)) res = "straight";
	    else res = func(hand);

	    System.out.println(res);
	}
    }

    String func(int[] hand){
	int[] num = new int[14];
	for(int i = 0; i < 5; i++) num[hand[i]]++;
	Arrays.sort(num);
	
	if(num[13] == 4) return "four card";
	if(num[13] == 3)
	    return (num[12] == 2)? "full house" : "three card";
	if(num[13] == 2)
	    return (num[12] == 2)? "two pair" : "one pair";

	return "null";
    }

    boolean straight(int[] hand){
	boolean f;
	if(hand[0] == 1){
	    f = true;
	    for(int i = 1; i < 5 && f; i++)
		f = (hand[i] == 9+i);

	    if(f) return f;
	}
	f = true;
	for(int i = 1; i < 5 && f; i++)
	    f = (hand[i] == (hand[0]+i));

	return f;
    }

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

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> p(m),y(m);
  for(Int i=0;i<m;i++) cin>>p[i]>>y[i];
  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=0;i<m;i++) vp.emplace_back(y[i],i);
  sort(vp.begin(),vp.end());
  vector<string> ans(m);
  vector<Int> cnt(n+1,0);
  for(Int i=0;i<m;i++){
    Int x=vp[i].second;
    ans[x]=to_string(++cnt[p[x]]);
    while(ans[x].size()<6u) ans[x]='0'+ans[x];
    ans[x]=to_string(p[x])+ans[x];
    while(ans[x].size()<12u) ans[x]='0'+ans[x];
  }
  for(string s:ans) cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 12784
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

const ll MXV=200000;
vl G[MXV],color(MXV,0);
ll pcnt=0,mcnt=0;
vl ans(MXV);

void dfs(ll s,ll c){
    ll k=G[s].size();
    color[s]=c;
    if(c==1){
        pcnt++;
    }
    else{
        mcnt++;
    }
    rep(i,k){
        if(color[G[s][i]]==0){
            dfs(G[s][i],-c);
        }
    }
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    rep(i,N-1){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    dfs(0,1);
    ans.resize(N);
    ll t=3,e=1;
    if(pcnt<=N/3){
        rep(i,N){
            if(color[i]==1){
                ans[i]=t;
                t+=3;
            }
            else{
                ans[i]=e;
                e++;
                if(e%3==0&&e<=pcnt*3){
                    e++;
                }
            }
        }
        rep(i,N){
            cout << ans[i] << endl;
        }
        return 0;
    }
    if(mcnt<=N/3){
        rep(i,N){
            if(color[i]==-1){
                ans[i]=t;
                t+=3;
            }
            else{
                ans[i]=e;
                e++;
                if(e%3==0&&e<=3*mcnt){
                    e++;
                }
            }
        }
        rep(i,N){
            cout << ans[i] << endl;
        }
        return 0;
    }
    e=1+(N-1)/3*3;t=2;
    rep(i,N){
        if(color[i]==1){
            ans[i]=e;
            e-=3;
            if(e<=0){
                e=N/3*3;
            }
        }
        else{
            ans[i]=t;
            t+=3;
            if(t>N){
                t=3;
            }
        }
    }
    rep(i,N){
        cout << ans[i] << endl;
    }
}


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

using ll = long long;

ll n,a[100005],mem[100005];

ll dp(ll i)
{
	if (i==n-1)return 0;
	
	if (mem[i]!=-1)return mem[i];
	
	ll path1=abs(a[i+1]-a[i])+dp(i+1);
	ll path2=2e18;
	if (i!=n-2) path2=abs(a[i+2]-a[i])+dp(i+2);
	
	return mem[i]=min(path1,path2);
	
}


int main()
{
    memset(mem,-1,sizeof mem);
    scanf("%lld",&n);
    for (ll i=0;i<n;i++)
    scanf("%lld",&a[i]);
    printf("%lld",dp(0));
    
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<climits>
#include<queue>

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> b(N);
    for(int i = 0; i < N; i++) cin >> b[i];
    for(int i = 0; i < N; i++){
        if(b[i] > i + 1){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> atodefuyasu(N, 1);
    bool flg = false;
    do{
        flg = false;
        for(int i = N - 1; i >= 0; i--){
            if(b[i] == 1){
                flg = true;
                cout << atodefuyasu[i] << endl;
                for(; i < N; i++){
                    b[i]--;
                    atodefuyasu[i]++;
                }
                break;
            }
        }
    }while(flg);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  s.replace(5,1, " ");
  s.replace(13,1, " ");
  cout << s << endl;


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

int main(void)
{
    int e[3];
    cin >> e[0] >> e[1] >> e[2];
    sort(e, e + 3);
    cout << 10 * e[2] + e[1] + e[0] << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
alist
alistp = alist + 1
alistm = alist - 1
d = {}
for a in alist:
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1
for a in alistp:
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1
for a in alistm:
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1
print(max(d.values()))

Measured memory_bytes: 26684
from collections import deque

n, q = map(int, input().split())
p = deque()

for _ in range(n):
    p_i = input().split()
    p.append([p_i[0], int(p_i[1])])

time = 0


while p:
    if p[0][1] > q:
        p[0][1] -= q
        time += q
        p.append(p.popleft())
    else:
        time += p[0][1]
        print(f"{p[0][0]} {time}")
        p.popleft()


Measured memory_bytes: 13288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll a,b;
	cin >> a >> b;
	cout << (500*a >= b ? "Yes":"No") << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	string S; cin >> S;
	string T;
	long long j = 1;
	for (long long i = 0; i < S.size() - 1; i += j) {
		if (S.at(i) == 'B' && S.at(i + 1) == 'C') {
			T.push_back('D');
			j = 2;
		}
		else {
			T.push_back(S.at(i));
			j = 1;
		}
	}
	long long ans = 0, num = 0;
	for (long long i = 0; i < T.size(); i++) {
		if (T.at(i) == 'A') {
			num++;
		}
		else if (T.at(i) == 'D') {
			ans += num;
		}
		else num = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
vll v[100009];
ll a[100009];
void solve()
{
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    ll x,y;
    for(ll i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        x=-1;
        for(auto j:v[i])
        {
            x=max(x,a[j]);
        }
        if(a[i]>x)
            ans++;
    }
    cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}

Measured memory_bytes: 10256
#include<bits/stdc++.h>
using namespace std;
void *wmem;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> int coordcomp_L(int n, T arr[], int res[] = NULL, void *mem = wmem){
  int i, k=0;
  pair<T,int> *r=(pair<T,int>*)mem;
  for(i=0;i<n;i++){
    r[i].first = arr[i];
    r[i].second = i;
  }
  sort(r, r+n);
  if(res != NULL){
    for(i=0;i<n;i++){
      if(i && r[i].first != r[i-1].first){
        k++;
      }
      res[r[i].second] = k;
    }
  }
  else{
    for(i=0;i<n;i++){
      if(i && r[i].first != r[i-1].first){
        k++;
      }
      arr[r[i].second] = k;
    }
  }
  return k+1;
}
char memarr[64000000];
int A[100000], N, cnt[100001];
int main(){
  int i, res;
  wmem = memarr;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  coordcomp_L(N, A);
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<(N-1) + 1;KL2GvlyY++){
      cnt[A[KL2GvlyY]]^=1;
    }
  }
  {
    int Q5VJL1cS, e98WHCEY;
    if(100000+1==0){
      e98WHCEY = 0;
    }
    else{
      e98WHCEY = cnt[0];
      for(Q5VJL1cS=1;Q5VJL1cS<100000+1;Q5VJL1cS++){
        e98WHCEY += cnt[Q5VJL1cS];
      }
    }
    res =e98WHCEY;
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170908-1 [beta]

// --- original code ---
// int N, A[100000], cnt[100001];
// {
//   int i, res;
//   rd(N,A(N));
//   coordcomp(N, A);
//   cnt[A[0..N-1]]^=1;
//   res = sum(cnt(1d5+1));
//   wt(res);
// }


Measured memory_bytes: 1792
# E - Colorful Hats 2
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
count = [0]*N+[3]
used = [0]*(N+1)
ans = 1
for x in A:
    ans = (ans*(count[x-1]-used[x-1]))%MOD
    count[x] += 1
    used[x-1] += 1
print(ans)

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

int main() {
  int n, a, b, x, c[100];
  double max=0;
  cin >> n;
  cin >> a >> b;
  cin >> x;
  for(int i=0; i<n; i++) cin >> c[i];
  max=(double)x;
  int k=0,q=a;
  sort(c, c+n, greater<int>());
  while(k<n) {
    int p=q;
    double z=max;
    z+=c[k];
    p+=b;
    if((double)z/p > (double)max/q) {
      max = z;
      q=p;
    } else {
      z-=c[k];
      p-=b;
    }
    k++;
  }
  cout << (int)max/q << endl;
  return 0;
}


Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

ll dfs(string t, bool san, bool go, bool nana, bool ok){
    if(t.size()==0){
        return (san && go && nana) ? 1 : 0;
    }
    ll num = t[0] - '0';
    ll res = 0;
    t.erase(t.begin());
    if(ok) {
        res += dfs(t,true,go,nana,true);
        res += dfs(t,san,true,nana,true);
        res += dfs(t,san,go,true,true);
        if(!san && !go && !nana) res += dfs(t,san,go,nana,true);
        return res;
    }

    if(!san && !go && !nana) res += dfs(t,san,go,nana,true);

    if(num>3) res += dfs(t,true,go,nana,true);
    else if(num==3) res += dfs(t,true,go,nana,false);
    if(num>=5) {
        if(num>5) res += dfs(t,san,true,nana,true);
        else res += dfs(t,san,true,nana,false);
    }
    if(num>=7) {
        if(num>7) res += dfs(t, san, go, true,true);
        else res += dfs(t,san,go,true,false);
    }
    return res;
}

int main() {
    string s; cin >> s;
    ll ans = dfs(s,false,false,false,false);
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
    @uthor: Varun Mishra
    "varun21999" ->  Codechef, Codeforce, Hackerrank, Hackerearth;
*/
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int            long long int
#define ull            unsigned int
#define ld             long double
#define pb             push_back
#define pa             pair<int,int>
#define ppa            pair<pair<int,int>,int>
#define pap            pair<int,pair<int,int>>
#define v1d            vector<int>
#define v2d            vector<vector<int> >
#define vpa            vector<pair<int,int>>
#define M              1000000007
#define MN             LLONG_MIN
#define MX             LLONG_MAX
#define ff             first
#define ss             second
#define endl           "\n"
#define v1s            vector<string>
#define all(v)         v.begin(),v.end()
#define S(v)           sort(v.begin(),v.end())
#define RS(v)          sort(v.rbegin(),v.rend())
#define R(v)           reverse(v.begin(),v.end())
#define mxpq(T)        priority_queue <T>
#define mnpq(T)        priority_queue<T,vector<T>,greater<T>>
#define T              int tc;cin>>tc;while(tc--)
#define p2d(v)         for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)         for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)         for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define forIloop(i,n)  for(auto i=0;i<n;i++);
#define forDloop(i,n)  for(auto i=n-1;i>=0;i--);
#define qqq 400005
#define isEven(n)  (!n & 1);
const int MOD = 1e9 + 7;
// bool isEven(int n){
//     return (!(n & 1));
// }
// int popcount(int num){
//     num = num - ((num >> 1) & 0x55555555);
//     num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
//     return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
// }
// int powerOfTwo(int n){
//     return 1 << n;
// }

// int arr[1000001];
// bool temet = false;


void codeforce2(){
    int n,k; cin>>n>>k;
    v1d arr(n);
    for (int i = 0; i < n; i++)
    {
        cin>>arr[i];
    }
    S(arr);
    int ans = 0;
    for (int i = 0; i < k; i++)
    {
        ans += arr[i];
    }
    
    cout << ans << endl;
}




int32_t main(){

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    /*#ifndef _DEBUG
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif*/
    //auto start = high_resolution_clock::now();

    // Lucario();
    //codeforceContest();
    //hackerEarth();
    //codeChef();
    codeforce2();

   /* auto stop = high_resolution_clock::now();
    auto duration = duration_cast<seconds>(stop - start);
    cout << "Time: "<<duration.count()<<endl;*/
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
#include <iomanip>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: return true;
    } // n > 2 が保証された

    if(n%2 == 0) return false;

    // 上で i=2 相当は調べたので、i=3から奇数のみ調べる
    for(unsigned i=3;i*i<=n;i+=2){
        if(n%i == 0) return false;
    }

    return true;
}

ll facctorialMethod(int k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
int N;
vector<int> P,Q;
ll a,b;
ll p,q;
void dfs(int d,ll t){
    if(d==N){
        if(t<p){
            a++;
        }
        if(t<q){
            b++;
        }
    }
    REP(i,1,N+1){
        ll n=t+i*pow(10,d);
        dfs(d+1,n);
    }
    
}

int main()
{
    ll N,K,S;
    cin>>N>>K>>S;
    ll S1=S+1;
    if(S==1000000000){
        S1=S-1;
    }
    ll A[N];
    REP(i,0,N){
        if(i<K){
            A[i]=S;
        }else{
            A[i]=S1;
        }
        cout<<A[i]<<" ";
    }

    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2e5;
int dep[N],f[20][N],fst[N],to[N],n,L,q,x[N],mm,sum[N];
int query(int l,int r)
{
	int ans=0;
	for(int i=17;i>=0;i--)if(f[i][l]&&f[i][l]<r)ans+=1<<i,l=f[i][l];
	return ans+(l!=r);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",x+i);
	scanf("%d%d",&L,&q);long long s=0;
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+x[i]-x[i-1];
	for(int i=1,j=2;i<n;i++)
	{
		while(s+x[j]-x[j-1]<=L&&j<=n)s+=x[j]-x[j-1],++j;
		f[0][i]=j-1;
		s-=x[i+1]-x[i];
	}
	for(int i=1;i<=17;i++)
		for(int j=1;j<=n;j++)
			f[i][j]=f[i-1][f[i-1][j]];
	for(int i=1;i<=q;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);if(l>r)swap(l,r);
		printf("%d\n",query(l,r));
	}
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int L = S.size();
    for (int i = 0; i < L; ++i){
        bool flag = true;
        for (int j = 0; j < L; ++j){
            if (S[(i + j) % L] != T[j]){
                flag = false;
                break;
            }
        }
        if (flag){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from functools import reduce

def main():
    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    slist = input().rstrip().split(' ')
    if slist[0] == '5' and slist [1] == '5' and slist[2] == '7':
        print('YES')
    elif slist[0] == '5' and slist [1] == '7' and slist[2] == '5':
        print('YES')
    elif slist[0] == '7' and slist [1] == '5' and slist[2] == '5':
        print('YES')
    else:
        print('NO')
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
n = int(input())

AC, WA, TLE, RE = 0, 0, 0, 0

for _ in range(n):
    s = input()

    if s == 'AC':
        AC += 1
    elif s == 'WA':
        WA += 1
    elif s == 'TLE':
        TLE += 1
    else:
        RE += 1

print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(int argc, char* argv[]){
        std::string str;
        int N = 0;
        std::vector<string> v;
        std::map<std::string, int> m;

        cin >> N;
        for(int i=1; i<=N; i++){
                string tmp;
                cin >> tmp;
                try{
                        m.at(tmp);
                }
                catch(std::out_of_range&){
                        m.insert(std::make_pair(tmp, 0));
                }
        }
        int ans = m.size();
        printf("%d\n", ans);

        return 0;

}

Measured memory_bytes: 19476
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			int n = s.Length;
			if (n == 26) {
				var chars = new List<char>();
				chars.Add(s[n - 1]);
				for (int i = n - 2; i >= 0; i--) {
					if (s[i] < s[i + 1]) {
						chars.Sort();
						char next = chars.First(x => x > s[i]);
						string ans = s.Substring(0, i) + next;
						Console.WriteLine(ans);
						return;
					} else {
						chars.Add(s[i]);
					}
				}

				Console.WriteLine(-1);
			} else {
				var exists = new bool[26].ToList();
				for (int i = 0; i < n; i++) {
					exists[s[i] - 'a'] = true;
				}

				char next = (char)(exists.FindIndex(x => x == false) + 'a');
				string ans = s + next;
				Console.WriteLine(ans);
			}
		}
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n,m,p;
	while(cin>>n>>m>>p and n>0){
		int sum=0; int win;
		rep(i,n){
			int x; cin>>x;
			sum+=x;
			if(i+1==m) win=x;
		}
		cout<<(win?sum*(100-p)/win:0)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return (n%mod)*(factorial(n-1)%mod);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	return b ? gcd(b,a%b) : a;
}



/*最小公倍数*/

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/
//組み合わせの数nCrを計算
    ll calcNumOfCombination(ll n, ll r){
        return factorial(n) / (factorial(r) * factorial(n-r));
    }

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n;
    cin>>n;
    vector<ll>a(n);
    map<ll,ll>mp;
    rep(i,0,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll sum=0;
    for(auto x:mp){
        sum+=x.second*(x.second-1)/2;
    }
    ll t=sum;
    

    rep(i,0,n){
        ll sum=t;
        sum-=mp[a[i]]*(mp[a[i]]-1)/2;
        sum+=(mp[a[i]]-1)*(mp[a[i]]-2)/2;
        cout<<sum<<endl;

    }
    
    
}


Measured memory_bytes: 11008
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c;
  
  cin>>a>>b>>c;
  if(c>=a){
    if(c<=b){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	run()
}

func run() {
	setSpace()
	n, k := readN(), readN()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = readN()
	}
	if n <= k {
		fmt.Println("0")
		return
	}
	sort.Ints(as)
	sum := 0
	for _, a := range as[:(n - k)] {
		sum += a
	}
	fmt.Println(sum)
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


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

int main() {
	int s;
	cin >> s;
	int m = s / 60;
	int h = m / 60;
	if (m > 0)
		s -= m * 60;
	if (h > 0)
		m -= h * 60;
	cout << h <<  ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3112
using System;
class Program
{
	static void Main(string[] args)
        {
            int count = 0;
            string[] inputArray = Console.ReadLine().Split(' ');
            

            int total = Convert.ToInt32(inputArray[0]);
            int x = Convert.ToInt32(inputArray[1]);
            int y = Convert.ToInt32(inputArray[2]);
            while (total > 0)
            {
                count += FilterDimension(x, y);
                total--;
            }
            
            Console.WriteLine(count);
            Console.Read();
        }

        static int FilterDimension(int x, int y)
        {
            int valid = 0;
            string[] inputCutArray = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(inputCutArray[0]);
            int b = Convert.ToInt32(inputCutArray[1]);
            if (x <= a && y <= b)
            {
                valid += 1;
            }

            return valid;
        }
}

Measured memory_bytes: 11220