akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Beg122C
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var M = read[1];
            var str = Console.ReadLine();
            var acInd = new int[N];
            var m = 0;
            var countACs = new int[N];
            for(int i = N - 1; i>0;i--)
            {
                if (str[i - 1] == 'A' && str[i] == 'C')
                {
                    acInd[m] = i;
                    m++;
                }
                countACs[i - 1] = m;
            }
            var subStrs = new string[M];
            var l = new int[M];
            var r = new int[M];
            var ansS = new int[M];
            for (int i = 0; i < M; i++)
            {
                var readQ = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var ans = 0;
                l[i] = readQ[0];
                r[i] = readQ[1];
                ansS[i] = countACs[l[i] - 1] - countACs[r[i] - 1];
            }
            for(int i =0;i<M;i++)
            {
                Console.WriteLine(ansS[i]);
            }
            
        }
    }
}


Measured memory_bytes: 22964
#include<bits/stdc++.h>
using namespace std;
int fa[1010],num[1010];
bool go[1010],bo[1010];
int getf(int s){if (fa[s]==s) return s;return fa[s]=getf(fa[s]);}
int main()
{
	int n;scanf("%d%*d",&n);
	for (int i=1;i<=1000;i++) fa[i]=i;
	for (int i=1;i<=n;i++)
	{
		int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
		if (c==0) c=a+500;else c=500-c;
		if (d==0) d=500-b;else d=d+500;
		fa[getf(c)]=getf(d);
		num[c]++;num[d]--;bo[c]=true;
	}
	for (int i=1;i<500;i++) if (num[i]>0) {puts("NO");return 0;}
	for (int i=501;i<1000;i++) if (num[i]<0) {puts("NO");return 0;}
	for (int i=1;i<1000;i++)
	{
		bo[getf(i)]|=bo[i];
		go[getf(i)]|=(num[i]!=0);
	}
	for (int i=1;i<1000;i++) if ((fa[i]==i)&&(bo[i])&&(!go[i])) {puts("NO");return 0;}
	puts("YES");
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

#define N_MAX 200000

using namespace std;

int main(){
    int N, K;
    int A[N_MAX];
    int count[N_MAX] = {0};
    int nunique = 1;
    int ans = 0;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A+N);
    
    count[0] = 1;

    for(int i = 1; i < N; i++){
        if(A[i] == A[i-1]){
            count[nunique-1]++;
        }else{
            nunique++;
            count[nunique-1]++;
        }
    }
    
    if(nunique <= K){
        cout << 0 << endl;
    }else{
        sort(count, count+nunique);
        for(int i = 0; i < nunique - K; i++){
            ans += count[i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char tmp1[2000];
char tmp2[2000];
int main() {
	//freopen("in","r",stdin);
	cin>>tmp1>>tmp2;
	bool flag = 0;
	for(int i=0;i<strlen(tmp1);i++) {
		int k = 0; int begin = i;
		while(1) {
			if(tmp1[begin]!=tmp2[k]) break;
			if(tmp1[begin]==tmp2[k]) {
				k++; begin++; begin %= strlen(tmp1);
			}
			if(k==strlen(tmp2)) {
				flag = 1; break;
			}
		}
		if(flag) break;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 100005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n;
    cin>>n;
    if(n>=30)cout<<"Yes";
    else cout<<"No";

    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);

int main(void){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;

    while (1)
    {
        C -= B;
        if( C <= 0)
        {
            cout << "Yes" << endl;
            break;
        }

        A -= D;
        if( A <= 0 )
        {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
// C - Dice and Coin
#include <bits/stdc++.h>
using namespace std;

int easy_log2(int n){
	int c = 0;
	bool carry = false;
	while(n>1){
		if(n&1) carry = true;
		n>>=1;
		++c;
	}
	return carry? c+1:c;
}

int main(){
	int N,K; cin>>N>>K;
	double ans = 0;
	for(int n=1; n<=N; ++n){
		int c = (K+n-1)/n;
		c = easy_log2(c);
		if(K<=n<<c) ans += 1./(N*(1<<c));
	}
	printf("%.12f\n",ans);
}

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

int main() {
    ll N; cin >> N;
    ll ans = 0;
    vector<ll> num(5, 0);
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        if (s[0] == 'M') num[0]++;
        if (s[0] == 'A') num[1]++;
        if (s[0] == 'R') num[2]++;
        if (s[0] == 'C') num[3]++;
        if (s[0] == 'H') num[4]++;
    }
    for (int i = 0; i < 5; i++) {
        for (int j = i+1; j < 5; j++) {
            for (int k = j+1; k < 5; k++) {
                ll val = num[i];
                val *= num[j];
                val *= num[k];
                ans += val;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

const int maxn = 55;


int main() {
    char a, b;
    while (cin >> a >> b) {
        if (a == 'H' && b == 'H') {
            cout << 'H' << endl;
        } else if (a == 'H' && b == 'D') {
            cout << 'D' << endl;
        } else if (a == 'D' && b == 'H') {
            cout << 'D' << endl;
        } else if (a == 'D' && b == 'D') {
            cout << 'H' << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;

    int n = s.length();
    string A(n, 'A');
    string B(n, 'B');
    if (s != A && s != B) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> s;
  int sum = 0;
  for(int i = 0; i < N; ++i){
    int x;
    cin >> x;
    if(x % 10 == 0) sum += x;
    else s.push_back(x);
  }
  sort(begin(s),end(s));
  int ans = accumulate(begin(s),end(s),0);
  if(ans % 10 != 0){
    cout << ans+sum << endl;
    return 0;
  }else if(ans == 0){
    cout << ans << endl;
    return 0;
  }
  for(int i = 0; i < s.size(); ++i){
    ans -= s[i];
    if(ans % 10 != 0){
      break;
    }
  }
  cout << ans+sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    ll  val = d/s;
    if(d%s) val++;
    if(val<=t) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()

void solve(){
 ll n,k;
  cin >> n;
 vs a(n);
  vll c(4,0); 
  rep(i,0,n) {
    cin >> a[i];
   if(a[i]=="AC") c[0]++;
   else if(a[i]=="WA") c[1]++;
   else if(a[i]=="TLE") c[2]++; 
   else if(a[i]=="RE") c[3]++;  
  }
  
  cout << "AC x "<< c[0] << endl;
cout << "WA x " << c[1] << endl;
cout << "TLE x " << c[2] << endl;
cout << "RE x " << c[3] << endl;
  
}

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

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,P;
  cin>>N>>P;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)A[i]%=2;
  vector<vector<ll>>dp(N+1,vector<ll>(2,0));
  dp[0][0]=1;
  for(int i=1;i<=N;i++){
    for(int j=0;j<2;j++){
      dp[i][j]+=dp[i-1][(j+A[i-1])%2];
      dp[i][j]+=dp[i-1][j];
    }
  }
  /*
  for(int i=0;i<=N;i++){
    for(int j=0;j<2;j++){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  cout<<dp[N][P]<<endl;
  return 0;
}


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

#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define mod 1e9 + 7
#define inf 99999999999
#define neginf -9999999999
#define vi vector<int>
#define vchar vector<char>
#define vstr vector<string> 
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   string a,b;
 cin>>a>>b;
 long int l = min(a.size(), b.size());
 long int i=0;
 for(i=0;i<l;i++){
     cout<<a[i]<<b[i];
 }
 if(a.size()!=b.size()) cout<<a[i];
   
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int c[6]={1,5,10,50,100,500};
int m[6];
int main(void){
	for(int i=0;i<6;i++)scanf("%d",&m[i]);
	int sum=0;
	for(int i=0;i<6;i++)sum+=m[i]*c[i];
	printf("%c\n",sum>=1000?'1':'0');
	return 0;
}

Measured memory_bytes: 1028
n = int(input())
a = [int(x) for x in input().split()]
count = len([x for x in filter(lambda n: n<0, a)])
b = [x for x in map(abs, a)]

p = min(b)
q = sum(b)
if count % 2 != 0:
    ans = q - 2 * p
else:
    ans = q
print(ans)

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

using namespace std;
typedef long long int ll;
const ll md = 1e9+7;
const int N = 111;
const int K = 100011;
ll n, k, dp[K][N], cum[K][N];
vector<int> v;
int main() 
{
 
	cin>>n>>k;
	v.resize(n);
	for(int i=0;i<n;i++) cin>>v[i];
	for(int i=0;i<N;i++) dp[0][i]=1, cum[0][i]=1;
	for(int i=1;i<=k;i++){
		dp[i][n-1]=v[n-1]>=i;
		cum[i][n-1]=dp[i][n-1];
		cum[i][n-1]+=cum[i-1][n-1];
	}
	for(int i=n-2;i>=0;i--)
		for(int j=1;j<=k;j++){
			ll val=v[i];
			ll l, r;
			if(j>val)
				l=val, r=j-val;
			else
				l=j, r=0;
			ll all=cum[l+r][i+1]%md;
			if(r)
				all=(all%md - cum[r-1][i+1]%md+md)%md;
			dp[j][i]=all%md;
			cum[j][i]=(cum[j-1][i]%md+dp[j][i]%md)%md;
		}
	cout<<dp[k][0];
	return 0;
}


Measured memory_bytes: 173696
#include<bits//stdc++.h>
using namespace std;
#define rep(i,b) for(int i = 0; i < (int)b; i++)
typedef long long ll;
const ll INF = 1e18;
struct edge {
	ll from, to, cost;
};
ll d[100000],V, E;
edge es[100000];
void shortest_path(ll s) {
	rep(i,V) d[i] = INF;
	d[s] = 0;
	while(true) {
		bool update = false;
		rep(i,E) {
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update) break;
	}
}
bool find_negative_loop(ll s) {
	fill(d, d + V, INF);d[s] = 0;
	rep(i,V) {
		rep(j,E) {
			edge e = es[j];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if(i == V - 1 and e.to == V - 1) return true;
			}
		}
	}
	return false;
}
int main(){
  cin >> V >> E;
  rep(i,E) {
    ll a, b, c;cin >> a >> b >> c;
    edge e = {--a, --b, -c};
    es[i] = e;
  }
  if(find_negative_loop(0)) {
    cout << "inf" << endl;
    return 0;
  }
  if(d[V - 1] == INF) cout << "inf" << endl;
  else cout << -d[V - 1] << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = input()

i = 0
for c in s:
    if i != k-1:
        print(c,end="")
    else:
        if c == "A":
            print("a",end="")
        elif c == "B":
            print("b",end="")
        elif c == "C":
            print("c",end="")
    i += 1

# if s[k-1]=="A":
#     s[k-1]="a"
# elif s[k-1]=="B":
#     s[k-1]=="b"
# elif s[k-1]=="C":
#     s[k-1]=="c"

# print(s)

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

int main(){
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A, A + 3);
    if((A[0] == 5) && (A[1] == 5) && (A[2] == 7)) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

lint LCM(lint a,lint b){
  if(a==0 || b==0) return 0;
  lint tmp,r,x;
  x=a*b;
  if(a<b) tmp=a,a=b,b=tmp;
  r=a%b;
  while(r!=0) a=b,b=r,r=a%b;
  x=x/b;
  return x;
}

lint GCD(lint a,lint b){
  if(a==0 || b==0) return max(a,b);
  else return (a*b)/LCM(a,b);
}

int main(void){
    lint N,M;
    cin >> N >> M;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint koubai=1;
    bool check=true;
    rep(i,N){
        koubai=LCM(koubai,A[i]);
        if(koubai>=100*M){
            check=false;
            break;
        }
    }
    M+=koubai/2;
    lint ans=M/koubai;
    if(!check) cout << 0 << endl;
    else{
        lint che=koubai/2;
        bool last=true;
        rep(i,N) if(che%A[i]==0) last=false;
        if(last) cout << max(0LL,ans) << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 1024
using System;
using System.IO;

class Program
{
    static void Main()
    {
        int D = int.Parse(Console.ReadLine());

        string S = null;

        switch(D)
        {
            case 22:
                S = "Christmas Eve Eve Eve";
                break;
            case 23:
                S = "Christmas Eve Eve";
                break;
            case 24:
                S = "Christmas Eve";
                break;
            case 25:
                S = "Christmas";
                break;
        }

        Console.WriteLine(S);
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(a>=b)puts("delicious");
	else if((b-a)<=x)puts("safe");
	else puts("dangerous");
	return 0;
}


Measured memory_bytes: 256
m,s,*f=10**9+7,0,1;p=->a,b{b>0?a**b[0]*p[a*a%m,b/2]:1};eval"H,W,A,B="+`tr \\  ,`;200000.times{|i|f<<f[-1]*-~i%m};(B...W).map{|i|s+=f[H-A-1+i]*f[A+W-i-2]*p[f[H-A-1]*f[i]*f[A-1]*f[W-1-i],m-2]};p s%m

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

using namespace std;

int main(){
    int K;
    string S;
    cin>>K;
    cin>>S;

    for(int i= 0; i < S.length(); i++){
        if(i>=K){
            cout<<"...";
            break;
        }else{
            cout<<S[i];
        }

    }
}


Measured memory_bytes: 3632
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

ans = 0
for i in range(n):
    t1 = min(aa[i], bb[i])
    aa[i] -= t1
    bb[i] -= t1
    ans += t1
    t2 = min(aa[i+1], bb[i])
    aa[i+1] -= t2
    ans += t2
print(ans)


Measured memory_bytes: 24116
#include<stdio.h>
void swap(int *x,int *y);
int main(){
    int x,y,r;

    scanf("%d%d",&x,&y);
    if(x < y)
        swap(&x,&y);
        r = x % y;

    while (r != 0)
    {
        x = y;
        y = r;
        r = x % y;
    }

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

    return 0;
}

void swap(int *x,int *y){
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}


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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

long kaijyo(int n){
    long ans = 1;
    REP(i, n)
        ans *= 27;
    return ans;
}

int main()
{
    int N;
    vector<pair<long, string>> str(200005);
    cin >> N;
    REP(i, N)
        cin >> str[i].second;
    REP(i, N){
        str[i].first = 0;
        REP(j, str[i].second.length())
            str[i].first += (long)(str[i].second[j] - 'a' + 1) * kaijyo(9-j);
    }
    sort(str.begin(), str.begin() + N);
    set<long> kosuu;
    int kosuuindex[200005];
    REP(i, N)
        kosuu.insert(str[i].first);
    REP(i, N)
        kosuuindex[i] = 0;
    int index = 0;
    int index2 = 0;
    int max = 0;
    for(auto itr = kosuu.begin(); itr != kosuu.end(); itr++){
        while(str[index].first == *itr){
            kosuuindex[index2]++;
            index++;
        }
        if(kosuuindex[index2] > max)
            max = kosuuindex[index2];
        index2++;
    }
    index = 0;
    REP(i, index2){
        if(kosuuindex[i] == max)
            cout << str[index].second << endl;
        index += kosuuindex[i];
    }
    return 0;
    
}



Measured memory_bytes: 25984
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <climits>
#include <iomanip>
 
using namespace std;

# define MOD 1000000007


// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int X, Y;
    cin >> X >> Y;

    long long res;

    if (((long long)X * 2 - Y) % 3 == 0) {
        long long b = ((long long)X * 2 - Y) / 3;
        long long a = (long long)X - 2 * b;

        // cout << "a:" << a << endl;
        // cout << "b:" << b << endl;

        if ((a < 0) | (b < 0)) {
            res = 0;
        } else {
            res = 1;
            for (long long i=0; i<a; i++) {
                res *= (a + b - i);
                res %= MOD;
            }
            for (long long i=1; i<=a; i++) {
                res *= modinv(i, MOD);
                res %= MOD;
            }
        }
    } else {
        res = 0;
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
ll dsum(ll x) {
    ll res=0;
    while(x) {
        res+=x%10;
        x/=10;
    }
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int maxdigits=18;
    vector<ll> stuff;
    rep(ds,1,maxdigits+1) {
        int nines=max(0,ds-3);
        ll base=0, fact=1;
        rep(i,0,nines) {
            base=10*base+9;
            fact*=10;
        }
        ll ten=1;
        rep(i,0,ds-nines-1) ten*=10;
        rep(x,ten,10*ten) {
            ll y = x*fact+base;
            stuff.push_back(y);
        }
    }
    int m = sz(stuff);
    vector<bool> bad(m);
    __int128 xnum=stuff[m-1], xden=dsum(stuff[m-1]);
    for(int j=m-2;j>=0;--j) {
        __int128 num=stuff[j], den=dsum(num);
        if(num*xden>xnum*den) bad[j]=true;
        else xnum = num, xden=den;
    }
    int k;
    int i=0;
    cin >> k;
    while(k) {
        if(!bad[i]) {
            --k;
            cout << stuff[i]<<"\n";
        }
        ++i;
    }
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int maxn = 5e3 + 7;

int p[maxn];
LL c[maxn];
LL sum[maxn];
vector<LL> v;

int main() {
	int n,k;
	sd(n),sd(k);
	rep(i,1,n) sd(p[i]);
	rep(i,1,n) slld(c[i]);
	LL ans = -INF;
	rep(i,1,n) {
		LL s = c[i];
		v.clear();
		v.push_back(s);
		for(int j = p[i] ; j != i ; j = p[j]) {
			// cout << "j = " << j << endl;
			s += c[j];
			v.push_back(s);
		}
		int len = v.size();
		rep(j,0,len-1) {
			LL res = k - j - 1;
			if(res < 0) break;
			ans = max(ans , v[j] + (res / len) * max(s,0LL));
		}
	}
	plld(ans);
	return 0;
}

Measured memory_bytes: 3960
# str型の小数(31.415 etc)が与えられて(31415,3)みたいなのを返す.
def get_int(f):
    return int(f.replace(".","")),len(f)-f.index(".")-1

a,b=input().split()
a=int(a)
x,y=get_int(b)
print(a*x//(10**y))

Measured memory_bytes: 9108
import numpy as np

N, K, *XY = map(int, open(0).read().split())

X = XY[::2]
comp_X = {}
decomp_X = {}
for i, x in enumerate(sorted(set(X))):
    comp_X[x] = i
    decomp_X[i] = x

Y = XY[1::2]
comp_Y = {}
decomp_Y = {}
for i, y in enumerate(sorted(set(Y))):
    comp_Y[y] = i
    decomp_Y[i] = y

I = len(comp_X)
J = len(comp_Y)
comp_XY = [(comp_X[x], comp_Y[y]) for x, y in zip(X, Y)]
acc = np.zeros((I + 1, J + 1), np.int32)
for c_x, c_y in comp_XY:
    acc[c_x + 1][c_y + 1] += 1
acc = np.add.accumulate(acc, axis=0)
acc = np.add.accumulate(acc, axis=1)

ans = float("inf")
for i in range(1, I + 1):
    for j in range(1, J + 1):
        cur = acc[i:, j:] + acc[:-i, :-j] - acc[:-i, j:] - acc[i:, :-j]
        for k, row in enumerate(cur):
            for l, val in enumerate(row):
                if val >= K:
                    ans = min(
                        ans,
                        (decomp_X[k + i - 1] - decomp_X[k])
                        * (decomp_Y[l + j - 1] - decomp_Y[l]),
                    )
print(ans)


Measured memory_bytes: 27400
#include<bits/stdc++.h>
using namespace std;
int a[5][5],s,x;
int main(){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++)
			cin>>a[i][j],s+=a[i][j];
		x+=a[i][i];	
	}
	if(x*3==s) cout<<"Yes"<<endl; 
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<math.h>
int isprime(int);

int main(){
  int x,n[10000],i,count=0;
  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&n[i]);
  }
  for(i=0;i<x;i++){
    if(isprime(n[i])==1)
      count++;
  }
  printf("%d\n",count);
  return 0;
}

int isprime(int x)
{
  int i;
  if(x==2) return 1;
  if(x<2 || x%2==0)
    return 0;
  i=3;
  while(i<=sqrt(x)){
    if(x%i==0)
      return 0;
      i=i+2;
  }
      return 1;
    }

Measured memory_bytes: 628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    string s[n]; rep(i,n) cin>>s[i];
    int ans=0;
    for(int a=0;a<n;a++){
        bool flg=1;
        rep(i,n)rep(j,n){
            if(s[(i+a)%n][j]!=s[(j+a)%n][i]) flg=0;
        }
        if(flg) ans+=n;
    }
    cout<<ans<<endl;
    return 0;
}


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

const ll INF = 1e10;

int main() {
    int N, M, X; cin >> N >> M >> X;
    ll ans = INF;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < 1<<N; i++) {
        vector<int> rikaido(M, 0);
        ll cost = 0;
        for (int j = 0; j < N; j++) {
            if (i>>j & 1) {
                cost += C[j];
                for (int k = 0; k < M; k++) {
                    rikaido[k] += A[j][k]; 
                }
            }
        }
        bool f = true;
        for (int j = 0; j < M; j++) {
            if (rikaido[j] < X) f = false;
        }
        if (f) {
            ans = min(ans, cost);
        }
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

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

int main() {
  int N;
  long int A = 0;
  long int B = 0;
  cin >> N;
  vector<long int> vec(N);
  vector<long int> ve(N-1);
  
  for (int i=0; i<N; i++) {
    cin >> vec[i];
    A+=vec[i];
  }
  
  for (int i=0; i<N; i++) {
    B += vec[i];
    if(A-2*B>0) ve[i] = A-2*B;
    else ve[i] = 2*B-A;
  }
  sort(ve.begin(), ve.end());
  
  cout << ve[0] << endl;


  return 0; 
  
}

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

using namespace std;

int main()
{
	int res = 0;
	vector<int> q(3);
	cin >> q[0] >> q[1] >> q[2];
	sort(q.begin(), q.end());

	while (q[0] + 2 <= q[1])
	{
		q[0] += 2;
		++res;
	}

	while (q[1] + 1 <= q[2])
	{
		++res;
		++q[0];
		++q[1];
	}

	if (q[0] != q[1])
	{
		res += 2;
	}

	cout << res << endl;
}

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


int main()
{
    int n;
    while(cin>>n)
    {
        int re=0;
        int score[105];
        int str[105];
        memset(score,0,sizeof(score));
        for(int i=0;i<n;i++){
            cin>>str[i];
                  if(1<=str[i]&&str[i]<=399)
                score[1]++;
            else if(400<=str[i]&&str[i]<=799)
                score[2]++;
            else if(800<=str[i]&&str[i]<=1199)
                score[3]++;
            else if(1200<=str[i]&&str[i]<=1599)
                score[4]++;
            else if(1600<=str[i]&&str[i]<=1999)
                score[5]++;
            else if(2000<=str[i]&&str[i]<=2399)
                score[6]++;
            else if(2400<=str[i]&&str[i]<=2799)
                score[7]++;
            else if(2800<=str[i]&&str[i]<=3199)
                score[8]++;
            else if(str[i]>=3200)
                re++;
        }
        int imin=0,imax=0,sum0=0;
        for(int i=1;i<=8;i++)
        {
            if(score[i]!=0){
                imin++;
                imax++;
           }

        }

        imax=imax+re;
        if(imin==0)
            imin=1;
        cout<<imin<<" "<<imax<<endl;

    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int sx, sy, tx, ty, dx, dy;
    cin >> sx >> sy >> tx >> ty;
    dx = tx - sx;
    dy = ty - sy;
    cout << string(dy,'U') << string(dx,'R');
    cout << string(dy,'D') << string(dx,'L');
    cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
    cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
}

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

#define vl vector<ll>
#define vi vector<int>

#define ff first
#define ss second

#define pb push_back
#define MOD 1000000007 
const int nax = 1e6+5;
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()

inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }

void add_self(ll &a , ll b){
    a += b;
    if(a>=MOD){
        a-=MOD;
    }
}

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;  cin>>str;
    int d;  cin>>d;
    vi digit;
    int n = str.length();
    for(int i =0;i<n;++i){
        digit.pb(str[i] -'0');
    }
    vector<vector<ll>> dp(d,vector<ll>(2,0));  // sum % d  and equal already
    dp[0][0]  = 1;
    for(int id = 0;id<n;++id){
        vector<vector<ll>> new_dp(d,vector<ll>(2,0));
        for(int sum = 0;sum <d;++sum){
            for(bool exceed :{false,true}){
                for(int dig =0;dig <10;++dig){
                    if(dig > digit[id] && exceed == false){
                        break;
                    }
                    add_self(new_dp[(sum+dig)%d][exceed || (dig < digit[id])] , dp[sum][exceed]);
                }
            }
        }
        dp = new_dp;
    }
    ll ans = 0;
    ans = add(dp[0][1],dp[0][0]);
    ans = sub(ans,1);
    cout << ans;
    return 0;
 }

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

int main() {
  int k,x;
  cin>>k>>x;
  
  for(int i=x-k+1;i<=x+k-1;i++){
    cout<<i<<" ";
  }
  
}



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

int main()
{
  int W, H, N;
  std::cin >> W >> H >> N;
  int left = 0, right = W, upper = H, lower = 0;
  for ( int i = 0; i < N; i++ ) {
    int x, y, a;
    std::cin >> x >> y >> a;
    if (a==1) left  = std::max(left, x);
    if (a==2) right = std::min(right, x);
    if (a==3) lower = std::max(lower, y);
    if (a==4) upper = std::min(upper, y);
  }
  int area = 0;
  if (left < right && lower < upper) area = (right - left) * (upper - lower);
  std::cout << area << std::endl;
  return 0;  
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


int main(){
  
  int  n , a , b ;
  cin >> n >> a >> b;
  string s; 
  cin >> s ;
  int sum=0;
  int abroad=0;
  rep(i,n){
    if(s[i]=='a'){
      if(sum<a+b){
        cout<<"Yes"<<endl;
        sum++;
      }
      else cout<<"No"<<endl;
    }
    if(s[i]=='b'){
      if(sum<a+b && abroad<b){
        cout<<"Yes"<<endl;
        sum++;
        abroad++;
      }
      else cout<<"No"<<endl;
    }
    if(s[i]=='c') cout<<"No"<<endl;
  }
}
  



Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;



int main(){
	int n,m;
	int a[1010],b[1010],c[1010];
	cin>>n>>m;
	int dis[110][110]={};
	//ワーシャルフロイド法;
	rep(i,0,n){
		rep(j,0,n){
			if(i!=j)dis[i][j]=dis[j][i]=INF;
		}
	}
	rep(i,0,m){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--,b[i]--;
		dis[a[i]][b[i]]=dis[b[i]][a[i]]=c[i];
	}
	rep(k,0,n){
		rep(i,0,n){
			rep(j,0,n){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	//ワーシャルフロイド法により,
	//全ての経路を最短化した.
	//この時、j==a[i]ならa[i]→b[i]が最短経路となっている;
	int ans=m;
	rep(i,0,m){
		bool f=false;
		rep(j,0,n)if(dis[j][a[i]]+c[i]==dis[j][b[i]])f=true;
		if(f)ans--;
	}
	cout<<ans<<endl;
}
	

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

int main(){

    int N;
    cin >> N;

    vector <pair<pair<string, int>, int>> R(N);

    for(int i = 0; i < N; i++){
        cin >> R[i].first.first >> R[i].first.second;
        R[i].second = i + 1;
    }

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

    /*cout << endl;
    for(int i = 0; i < N; i++){
        cout << R[i].second << " " << R[i].first.first << " score : " << R[i].first.second << endl;
    }*/

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N-1; j++){
            if(R[j].first.first == R[j+1].first.first && R[j].first.second < R[j+1].first.second){
                swap(R[j], R[j+1]);
            }
        }
    }

    /*cout << endl;
    for(int i = 0; i < N; i++){
        cout << R[i].second << " " << R[i].first.first << " score : " << R[i].first.second << endl; 
    }*/

    for(int i = 0; i < N; i++){
        cout << R[i].second << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N)
    {
        cin >> d.at(i);
    }
    int ans = 0;
    rep(i, N)
    {
        for (int j = i + 1; j < N; j++)
        {
            ans += d.at(i) * d.at(j);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * Author: ylx
 * Lang: c++
 * Prog: agc002F
 */
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void qmax(int &x, int y)
{
    if (x < y)
        x = y;
}
void qmin(int &x, int y)
{
    if (x > y)
        x = y;
}
inline ll read()
{
    char s;
    ll k = 0, base = 1;
    while ((s = getchar()) != '-' && s != EOF && !(isdigit(s)))
        ;
    if (s == EOF)
        exit(0);
    if (s == '-')
        base = -1, s = getchar();
    while (isdigit(s))
        k = k * 10 + (s ^ '0'), s = getchar();
    return k * base;
}
inline void write(ll x)
{
    static char cnt, num[20];
    cnt = 0;
    if (!x)
    {
        putchar('0');
        return;
    }
    for (; x; x /= 10)
        num[++cnt] = x % 10;
    for (; cnt; putchar(num[cnt--] + 48))
        ;
}
const int maxn = 4e6 + 100;
const ll mod = 1e9 + 7;
int jie[maxn], ny[maxn];
int n, m;
ll ksm(ll x, int y)
{
    ll sum = 1;
    while (y)
    {
        if (y & 1)
            sum = sum * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return sum;
}
void init()
{
    n = 4e6;
    jie[0] = 1;
    for (int i = 1; i <= n; i++)
        jie[i] = (ll)jie[i - 1] * i % mod;
    ny[n] = ksm(jie[n], mod - 2);
    for (int i = n; i >= 1; i--)
        ny[i - 1] = (ll)ny[i] * i % mod;
}
ll C(int x, int y)
{
    if (x < y)
        return 0;
    return (ll)jie[x] * ny[x - y] % mod * ny[y] % mod;
}
ll f[2][2030];
int main()
{
#ifdef ylx
    freopen("agc002F.in", "r", stdin);
    freopen("agc002F.out", "w", stdout);
#endif
    init();
    n = read(), m = read();
    if (m == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    f[0][0] = 1;
    for (int i = 1, p; i <= n; i++)
    {
        p = i & 1;
        memset(f[p], 0, sizeof(f[p]));
        for (int j = 0; j <= i; j++)
        {
            if (!j)
            {
                f[p][j] = f[p ^ 1][j];
                continue;
            }
            f[p][j] = f[p ^ 1][j] + f[p][j - 1] * (n - j + 1) % mod * C((n - j + 1) * (m - 1) + n - i - 1, m - 2) % mod;
        }
    }
    write(f[n & 1][n]);
}

Measured memory_bytes: 31488
'''
Created on 2020/08/21

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,A,B=map(int,pin().split())
  t=B-A-1
  if t%2==0:
    print("Borys")
  else:
    print("Alice")
  return 
main()

Measured memory_bytes: 9012
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>


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 long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

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

int main()
{
	
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	ll N; cin >> N;
	string s = "E869120";
	ll res = 0;
	for (ll i = 0; i < N; i++) {
		string x; cin >> x;
		if (x == s) res++;
	}
	cout << res << endl;
	return 0;

}



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

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  
  int a, b;
  a = A.size()-1;
  b = B.size()-1;
  
  if(A.at(a) == B.at(0) and B.at(b) ==C.at(0)){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> // Include every standard library
using namespace std;
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
#define sqr(x) ((LL)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define TC(t) while (t--)
#define ms(s, n) memset(s, n, sizeof(s))
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define size(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pi> vii;
const int MOD = (int)1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
inline ll isqrt(ll k)
{
    ll r = sqrt(k) + 1;
    while (r * r > k)
        r--;
    return r;
}
inline ll icbrt(ll k)
{
    ll r = cbrt(k) + 1;
    while (r * r * r > k)
        r--;
    return r;
}
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";

int main()
{
    IOS
    int N,W;
    scanf("%d %d", &N,&W);
    vl dp(W+1, 0);
    //dp[i]=max value when total weight is i
    vi w;
    vi v;
    for(int a=0;a<N;a++)
    {
        int wgt,val;
        scanf("%d %d", &wgt,&val);
        w.pb(wgt);
        v.pb(val);
    }
    for(int a=0;a<N;a++)
    {
        // using push forward dp
        //for(int b=0;b<=W-w[a];b++) picks up same item twice
        for(int b=W-w[a];b>=0;b--) //ierating over items that can already be in the knapsack if i pick up w[a]
        dp[b+w[a]]=max(dp[b+w[a]],dp[b]+v[a]);

    }
    ll res=*max_element(ALL(dp));
    printf("%lld", res);
}


Measured memory_bytes: 4040
Scanf.scanf "%d" (fun n ->
    let uv = Array.init (n - 1) (fun _ -> Scanf.scanf " %d %d" (fun u v -> min u v * (n + 1 - max u v))) in
    Printf.printf "%d\n" @@ n * (n + 1) * (n + 2) / 6 - Array.fold_left (+) 0 uv
)

Measured memory_bytes: 7488
#include<stdio.h>
#include<string.h>
int main(){
    int x;
    char str[101];
    scanf("%d", &x);
    scanf("%s", &str);
    int len = strlen(str);

    if(x < len){
        for(int i = 0; i < x; i++){
            printf("%c", str[i]);
        }
        printf("...");
    }else{
        printf("%s", str);
    }


}

Measured memory_bytes: 1736
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

def main():
    X = int(input())
    num_500 = int(X/500)
    num_5 = int((X%500)/5)
    print(int(num_500*1000 + num_5*5))

main()


Measured memory_bytes: 2940
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef double T;
typedef pair<T,T> P;

double pi;
// difference
P operator-(const P& lhs, const P& rhs)
{
	return P(lhs.first-rhs.first,lhs.second-rhs.second);
}

P operator+(const P& lhs, const P& rhs)
{
	return P(lhs.first+rhs.first, lhs.second+rhs.second);
}

P full(0,1);
P one(1,1);
P f(P a, P b)
{
	if(a==full){
		return b;
	}
	if(a.first+0.5<b.first){
		b=b-one;
	}
	if(b.first+0.5<a.first){
		a=a-one;
	}
	P r=P(max(a.first,b.first),min(a.second,b.second));
	if(r.first<0){
		r=r+one;
	}
	return r;
}
P ps[100];
int main(){
	pi=atan2(0,-1);
    long long N;
    scanf("%lld",&N);
    for(int i = 0 ; i < N ; i++){
		double x,y;
        scanf("%lf",&x);
        scanf("%lf",&y);
		ps[i]=P(x,y);
    }

	for(int i=0;i<N;i++){
		P r=full;
		bool zero=false;
		for(int j=0;j<N;j++){
			if(i==j)continue;
			auto v=ps[j]-ps[i];
			auto c=atan2(v.second,v.first)/(2*pi);
			P p(c-0.25,c+0.25);
			while(p.first<0){
				p=p+one;
			}
			r=f(r,p);
			//cerr << i << ", " << j << ": " << p.first << ", " << p.second << ": " << r.first << ", " << r.second << ": " << v.first << ", " << v.second << ": " << c << endl;
			//cerr << atan2(v.second,v.first) << ", " << pi << endl;
			if(r.first>=r.second){
				zero=true;
				break;
			}
		}
		if(zero){
			cout << 0 << endl;
		}
		else{
			cout << r.second-r.first << endl;
		}
	}

    return 0;
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int i, w;
    for(i=1;;i++){
        w = Y*i + Z*(i-1) + 2*Z;
        if(w > X){
            i--;
            break;
        }

    }

    cout << i << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n,a[100005];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int sum=0;	
	for(int i=0;i<n;){
		int s=0;
		for(int j=0;;j++){
			if(a[i+j]==a[i])s++;
			else break;
		}
		if(s>a[i])sum+=s-a[i];
		else if(s<a[i])sum+=s;
		i+=s;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 512
def main():
    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]

    if not(isinstance(a, int) and isinstance(b, int)):
        return
    if not(-100 <= a and a <= 100 and -100 <= b and b <= 100):
        return

    num = [a+b, a-b, a*b]

    print(max(num))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                  (ll)1<<60
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={-2,-2,1,-1,-1,-1,1,1};
int dy[8]={1,-1,-2,-2,-1,1,-1,1};
vector<int> adj[100010];
vector<int> dp(100010,0);
vector<int> vis(100010,0);
int dfs(int a)
{
    vis[a]=1;
    int maxi=0;
    for(auto i:adj[a])
    {
        if(vis[i]==0)
        {
            dfs(i);
        }
        maxi=max(maxi,dp[i]+1);
    }
    return dp[a]=maxi;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n,m;
    cin>>n>>m;
    f(i,m)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0)
            dfs(i);
    }
    int maxi=0;
    for(int i=1;i<=n;i++)
    {
        maxi=max(maxi,dp[i]);
    }
    cout<<maxi<<endl;
}


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

const int INF = 1000000000;

int main(){
	int n,k,s;
	cin >> n >> k >> s;
	
	vector<int> ret;
	
	if(s == INF){
		for(int i = 0 ; i < k ; i ++){
			ret.push_back(s);
		}
		for(int i = k ; i < n ; i ++){
			ret.push_back(INF-1);
		}
	}
	else {
		for(int i = 0 ; i < k ; i ++){
			ret.push_back(s);
		}
		for(int i = k ; i < n ; i ++){
			ret.push_back(INF);
		}
	}
	
	for(int i = 0 ; i < n ; i ++){
		printf("%d%c",ret[i],(i+1==n)?'\n':' ');
	}
}

Measured memory_bytes: 1784
// From https://www.reddit.com/r/rust/comments/3fg0xr/how_do_i_find_the_max_value_in_a_vecf64/ctoaxna?utm_source=share&utm_medium=web2x
use std::f64;

trait FloatIterExt {
    fn float_min(&mut self) -> f64;
    fn float_max(&mut self) -> f64;
}

impl<T> FloatIterExt for T
where
    T: Iterator<Item = f64>,
{
    fn float_max(&mut self) -> f64 {
        self.fold(f64::NAN, f64::max)
    }

    fn float_min(&mut self) -> f64 {
        self.fold(f64::NAN, f64::min)
    }
}

fn main() {
    let mut v: Vec<f64> = Vec::new();
    let mut input;
    loop {
        input = String::new();
        match std::io::stdin().read_line(&mut input) {
            Ok(0) => break,
            Err(_) => break,
            _ => {}
        };
        v.push(input.trim().parse::<f64>().expect("Parse error"));
    }
    println!(
        "{:.1}",
        v.iter().cloned().float_max() - v.iter().cloned().float_min()
    );
}



Measured memory_bytes: 5144