akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;

#define DIV ((long) (1e9 + 7))

#define COUT cout <<
#define SPACE_COUT << " " 
#define COLON_COUT << ": "
#define COMMA_COUT << ", "
#define ENDL << endl;

int
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    
    int len = s.length();
    vi v(len);
    for (int i = 0; i < len; ++i) {
        v[i] = s[i] - '0';
    }

    int bitset = 1 << (len-1);
    long total = 0;
    for (int i = 0; i < bitset; ++i) {
        long sub = 0;        
        for (int j = 0; j < len; ++j) {
            sub = sub * 10 + v[j];
            if((i >> j) & 1) {
                total += sub;
                sub = 0;
            } 
        }
        total += sub;
    }
    cout << total << endl;;
    return 0;
}


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

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll N; cin >> N;
	ll d[101] = {  };
	ll a;
	ll cnt = 0;
	rep(i, 0, N) {
		cin >> a;
		if (d[a] == 0) {
			cnt++;
		}
		d[a]++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
n,i;
ea[2<<17],eb[2<<17],next[2<<17],first[1<<17];
long M,dp1[1<<17],dp2[1<<17],R[2<<17];
/*dfs1(u,p,i)
{
	dp1[u]=1;
	for(i=first[u];i;i=next[i])eb[i]-p?dfs1(eb[i],u),dp1[u]=dp1[u]*-~dp1[eb[i]]%M:0;
}*/
dfs1(u,p,i,I)
{
	dp1[u]=1;
	for(i=first[u];I=eb[i];i=next[i])I-p?dfs1(I,u),dp1[u]=dp1[u]*-~dp1[I]%M:0;
}
/*dfs2(u,p,x,i)
{
	i=first[u];
	dp2[u]=dp1[u]*x%M;
	make(i,p,x);
	for(;i;i=next[i])
	{
		if(eb[i]!=p)dfs2(eb[i],u,L[i]*R[next[i]]%M+1);
	}
}
make(i,p,x,t)
{
	if(i)
	{
		L[i]=x;
		t=eb[i]-p?-~dp1[eb[i]]:1;
		make(x=next[i],p,t%M*x%M);
		R[i]=R[x]*t%M;
	}
}*/
/*
dfs2(u,p,x,i)
{
	i=first[u];
	dp2[u]=dp1[u]*x%M;
	make(i,p);
	for(;i;i=next[i])eb[i]-p?dfs2(eb[i],u,R[next[i]]*x%M+1),x=x%M*-~dp1[eb[i]]%M:0;
}
*/
/**/
dfs2(u,p,x,i,I)
{
	//dp2[u]=dp1[u]*x%M;
	for(make(i=first[u],p);I=eb[i];i=next[i])I-p?dfs2(I,u,R[next[i]]*x%M+1,0,0),x=x*-~dp1[I]%M:0;
	dp2[u]=x%M;
}
/**/
make(i,p)
{
	if(i)make(next[i],p),R[i]=R[next[i]]*(eb[i]-p?-~dp1[eb[i]]:1)%M;
}
main(u,v)
{
	/*for(scanf("%d%d",&n,&M);~scanf("%d%d",&u,&v);)
	{
		i++;
		ea[i]=u;
		eb[i]=v;
		i++;
		ea[i]=v;
		eb[i]=u;
	}*/
	//for(;~scanf("%d%d",&u,&v);)i++?ea[i]=eb[i+1]=u,ea[i+1]=eb[i]=v,i++:(n=u,M=v);
	for(;~scanf("%d%d",&u,&v);i++)i++?ea[i-1]=eb[i]=u,ea[i]=eb[i-1]=v:(n=u,M=v);
	//for(;~scanf("%d%d",&u,&v);)i++?ea[i-1]=eb[i]=u,eb[i-1]=ea[i++]=v:(n=u,M=v);
	for(;--i;first[ea[i]]=i)next[i]=first[ea[i]];
	dfs1(*R=1,0);
	dfs2(1,0,1);
	for(;i++<n;)printf("%d\n",dp2[i]);
}

Measured memory_bytes: 13824
#include <stdio.h>

int main(void) {
    int L,R,d,i,a;
    a=0;
    scanf("%d" ,&L);
    scanf("%d" ,&R);
    scanf("%d" ,&d);
    for (i=L; L<=i && i<=R; i++) {
        if (i%d==0) {
            a++;
        }
    }
    printf("%d\n" ,a);
    return 0;
}


Measured memory_bytes: 1704
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

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

	
	int x = 0;
	vector<int> v;
	v.push_back(x);

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'I') {
			x++;
		}
		else {
			x--;
		}
		v.push_back(x);
	}
	cout << *max_element(v.begin(), v.end()) << endl;

	return 0;
}

Measured memory_bytes: 3584
import sys
readline = sys.stdin.readline


def solve(writer):
    N, A, B, C = map(int, input().split())

    variables = {
        'A': A,
        'B': B,
        'C': C
    }

    queries = (list(readline().strip()) for _ in range(N))

    next_q = next(queries)

    for i in range(N):

        let_1, let_2 = next_q
        next_q = next(queries) if i != N - 1 else ()

        if variables[let_1] == variables[let_2] == 0:
            return False

        if variables[let_1] == variables[let_2] == 1 and let_2 in next_q \
                or variables[let_1] > variables[let_2]:
            let_1, let_2 = let_2, let_1

        variables[let_1] += 1
        variables[let_2] -= 1

        writer.append(let_1)

    return True


def main():
    writer = ['Yes']
    ok = solve(writer)
    if ok:
        for w in writer:
            print(w)
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9900
def solve_testcase():
    n, r = map(int, raw_input().split())
    if (n, r) == (0, 0):
        return 1

    cards = range(n, 0, -1)
    for i in range(r):
        p, c = map(int, raw_input().split())
        cards[:c], cards[c:p+c] = cards[p-1:p+c], cards[:p-1]

    print cards[0]
    return 0

def main():
    while not solve_testcase():
        pass

if __name__ == '__main__':
    main()

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

int main () {
      int n;
      cin >> n;
      int a[n+10], b[n+10];
      for (int i=0; i<n; i++) {
            cin >> a[i] >> b[i];
      }
      int flag=0;
      for (int i=0; i<n-2; i++) {
            if (a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2]) {
                  flag = 1;
                  cout << "Yes" << endl;
                  break;
            }
      }
      if (flag==0) {
            cout << "No" << endl;
      }
      return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n, m; cin >> n; m = n;
	int dsum = 0;
	while (m) {
		dsum += m % 10; m /= 10;
	}
	if (n%dsum)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    int l = (int)s.size();
    REP(i,l){
        if(s[i]!=t[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, p[20], c;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
	}
	for (int i = 1; i < N - 1; ++i) {
		if (min(p[i - 1], p[i + 1]) < p[i] && p[i] < max(p[i - 1], p[i + 1])) {
			++c;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
const lnt INF = 0xffffffffffffff;
lnt d[10][10];
lnt n,x,y,z;
lnt used[10];
int main()
{while(1){

	cin>>n;
	if(!n) return 0;
	fill(d[0],d[10]+10,INF);
	fill(used,used+10,0);
	for(lnt i=0;i<n;i++){
		cin>>x>>y>>z;
		used[x]=1;
		used[y]=1;
		d[x][y]=z;
		d[y][x]=z;
	}
	for(lnt i=0;i<10;i++){
		if(used[i]) d[i][i]=0;
	}
	for(lnt k=0;k<10;k++){
		for(lnt i=0;i<10;i++){
			for(lnt j=0;j<10;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	P ans=P(-1,INF);
	lnt sum;
	for(lnt i=0;i<10;i++){
		if(!used[i]) continue;
		sum=0;
		for(lnt j=0;j<10;j++){
			if(!used[j]) continue;
			sum+=d[i][j];
		}
		if(ans.second>sum){
			ans.first=i;
			ans.second=sum;
		}
	}
	cout<<ans.first<<' '<<ans.second<<endl;
}}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}

ll T;
void ave(ll &s,ll &t){
    ll z=mod((s+t)*T);
    s=z;
    t=z;
}

int main(){fastio
    T=bunbo(2);
    ll n,q;cin>>n>>q;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll dp[n][n];memset(dp,0,sizeof(dp));
    rep(i,0,n-1)rep(j,0,n-1){
        if(a[i]>a[j])dp[i][j]=1;
    }
    rep(zzzz,1,q){
        ll x,y;cin>>x>>y;x--;y--;
        rep(i,0,n-1){
            if(i!=x&&i!=y){
                ave(dp[i][x],dp[i][y]);
                ave(dp[x][i],dp[y][i]);
            }
        }
        ave(dp[x][y],dp[y][x]);
    }
    
    ll ans=0;
    rep(i,0,n-1)rep(j,i+1,n-1){
        Add(ans,dp[i][j]);
    }
    cout<<mod(ans*po(2,q))<<endl;
    
    return 0;
}


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

int main() {
  int N, A, x;
  cin >> N >> A;

  x = N % 500; 
  
  if (A >= x) {
    cout << "Yes" << endl;
  }
  else {
    cout  << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())


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

    int s;

    cin >> s;
    int a = s / 100;
    int b = s % 100;

    if (1 <= a && a <= 12) {
        if (1 <= b && b <= 12)cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }
    else {
        if (1 <= b && b <= 12)cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		boolean result = false;
		
		for(int i = 0 ; i < N ; i ++){
			if("Y".equals( sc.next() ) ){
				result = true;
			}
		}
		
		System.out.println( result ? "Four" : "Three" );
	}
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int k[n],p[n];
    for(int i=0;i<n;i++){
        cin >> k[i]>>p[i];
        int s=k[i]%p[i];
        if(s){
            cout << s<< endl;
        }
        else{
            cout << s+p[i]<< endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3124
from math import ceil
time_list = [int(input()) for i in range(5)]
sum_list = []
time_list_0 = []
for i in range(5):
    time_list_0.append(ceil(time_list[i] / 10) * 10)
for j in range(5):
    if time_list[j] % 10 == 0:
        sum_list.append(sum(time_list_0))
    else:
        sum_list.append(sum(time_list_0) - 10 + (time_list[j] % 10))
print(min(sum_list))


Measured memory_bytes: 3060
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    N=int(input())
    ret=0
    if N==2:
        ret=1
    else:
        div=make_divisors(N)
        div=div+make_divisors(N-1)
        div.append(N)
        div.append(N-1)
        for k in div:
            n=N
            while n%k==0:
                n=n//k
            ret += n%k==1
        if N==2:
            ret = 1
    print(ret)

if __name__ == '__main__':
    main()

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

int main() {
    LL a, v;
    cin >> a >> v;
    LL b, w;
    cin >> b >> w;
    LL t;
    cin >> t;

    if (v > w && abs(a-b) <= t*(v-w)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}


Measured memory_bytes: 3616
import random

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]


def calc(T):
  L = [0 for i in range(26)]
  score=0
  for d in range(D):
    score += S[d][T[d]-1]

    L[T[d]-1] = d+1
    down = 0
    for i in range(26):
      down+=C[i] * ((d+1) - L[i])

    score -=down
  return score

max_score=0
bestT=[]

for i in range(10):
  T = [random.randrange(1,26) for i in range(D)] 
  score = calc(T)

  if score > max_score:
    bestT = T
    max_score = score

for t in T:
  print(t)

Measured memory_bytes: 9880
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more scores.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

const ll lim = 2e18;
const int mod = 1e9 + 7;

ll fib[1000];
int mx[810][810];
int val[810][810];

inline int dfs(ll x, ll y, int d, ll Lx, ll Ly, int &ans) {
	if(x * fib[d - 1] + y * (d > 1 ? fib[d - 2] : 0) > Lx) return 0;
	if(x * fib[d] + y * fib[d - 1] > Ly) return 0;
	if(d == 1) {
		if(Lx >= x + y) ans = (ans + (Lx - y) / x) % mod;
		return ans = (ans + (Ly - y) / x) % mod, 1;
	}
	for(int i = 1 + (!y); ; ++i)
		if(!dfs(y + x * i, x, d - 1, Lx, Ly, ans)) return i > 1;
}

int main() {
	fib[0] = 1, fib[1] = 1;
	int N = 1;
	while(fib[N] <= lim) ++N, fib[N] = fib[N - 1] + fib[N - 2];
	int q = ri;
	for(int i = 1; i <= 800; i++)
		for(int j = 1; j <= 800; j++) {
			if(i > j) mx[i][j] = mx[j][i];
			else mx[i][j] = mx[j % i][i] + 1;
			val[i][j] = 1;
		}
	for(int i = 1; i <= 800; i++)
		for(int j = 1; j <= 800; j++)
			if(mx[i][j] == mx[i][j - 1]) val[i][j] += val[i][j - 1];
			else if(mx[i][j] < mx[i][j - 1]) mx[i][j] = mx[i][j - 1], val[i][j] = val[i][j - 1];
	for(int i = 1; i <= 800; i++)
		for(int j = 1; j <= 800; j++)
			if(mx[i][j] == mx[i - 1][j]) val[i][j] += val[i - 1][j];
			else if(mx[i][j] < mx[i - 1][j]) mx[i][j] = mx[i - 1][j], val[i][j] = val[i - 1][j];
	while(q--) {
		ll x = rl, y = rl; if(x > y) swap(x, y);
		int idx = upper_bound(fib + 1, fib + 1 + N, x) - fib - 1;
		int idy = upper_bound(fib + 1, fib + 1 + N, y) - fib - 1;
		if(y <= 800) printf("%d %d\n", mx[x][y], val[x][y]);
		else {
			if(x == 1) {
				printf("1 %d\n", y % mod);
			} else {
				int mx = min(idy - 1, idx), ans = 0;
				printf("%d %d\n", mx, (dfs(1, 0, mx, x, y, ans), ans));
			}
		}
	}
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

//#define FILE_INPUT
//#define DEBUG_MODE

int memo[100000][3];
int happys[100000][3];
int h[100000];

int Search(int n, int day, int before)
{
	if (day == n) {
		return 0;
	}
	if (before >= 0) {
		if (memo[day][before] >= 0) {
			return memo[day][before];
		}
	}
	int max = 0;
	for (int i = 0; i < 3; ++i) {
		if (before != i) {
			int happy = happys[day][i] + Search(n, day + 1, i);
			if (happy > max) {
				max = happy;
			}
		}
	}
	memo[day][before] = max;
	return max;
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> happys[i][j];
			memo[i][j] = -1;
		}
	}

	int total = Search(n, 0, -1);
	cout << total << endl;

	return 0;
}

Measured memory_bytes: 10368
def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

n, m = map(int, input().split())
S = input()
T = input()

l = lcm(n, m)
        
if S[::n // gcd(n, m)] == T[::m // gcd(n, m)]:
    print(l)
else:
    print(-1)

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

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<int> a(n);
	int sum = 0, cnt = 0;
	for (auto& e : a) cin >> e, sum += e;
	for (auto e : a)
		if (4 * m * e >= sum) ++cnt;
	cout << (cnt < m ? "No" : "Yes") << endl;

	return 0;
}

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

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int parent[N], subSize[N];

int Find(int a) {
    return parent[a] == a ? a : parent[a] = Find(parent[a]);
}

bool Check(int a, int b) {
    return Find(a) == Find(b);
}

void Union(int a, int b) {
    a = Find(a);
    b = Find(b);
    if (a != b) {
        subSize[a] += subSize[b];
        parent[b] = a;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        parent[i] = i;
        subSize[i] = 1;
    }
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        Union(u, v);
    }
    set<int> pt;
    for (int i = 1; i <= n; i++) {
        pt.insert(Find(i));
    }
    multiset<int> ms;
    for (auto i : pt) {
        ms.insert(subSize[i]);
    }
    int red = 0, ans = 0;
    for (auto i : ms) {
        int tmp = i - red;
        ans += tmp;
        red += tmp;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 23928
object Main{
  case class Job (days: Int, pay: Int)

  def main(args: Array[String]) : Unit = {
    val start = System.currentTimeMillis()
    System.err.println("ok")

    val sc = new java.util.Scanner(System.in)
    val n,m = sc.nextInt
    val jobs = (1 to n).map{_ => 
      val a,b = sc.nextInt
      Job(a,b)
    }
    .groupBy { job => job.days }

//    System.err.println(s"inputted. time: ${System.currentTimeMillis() - start}")

    val candidate = collection.mutable.PriorityQueue[Job]()(Ordering.by{job => job.pay})
    var result = 0
    (1 to m).foreach { x =>
//      System.err.println(x)

      jobs.getOrElse(x,List.empty).foreach{
        job => 
          candidate += job
      }

      var select:Job = null
      if(! candidate.isEmpty) {
        select = candidate.dequeue
//        System.err.println(select)
        result += select.pay
      }
    }
    println(result)
  }
}



Measured memory_bytes: 152768
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t,c,d,s;
	cin>>a>>b>>c>>d;
	s=0;
	if(d<=a)
	{
		s+=d;
		d=0;
    }
	else
	{
		s+=a; d-=a;
	}
	d-=b;
	d=max((ll)0,d);
	s-=d;
	cout<<s<<endl;
	

}

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

int main(){
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> L(Q), R(Q);
  for(int i=0; i<Q; i++){
    cin >> L.at(i) >> R.at(i);
  }
  vector<int> K(N);
  for(int i=0; i<N-1; i++){
    if(S.at(i)=='A' && S.at(i+1)=='C'){
      K.at(i+1)=K.at(i)+1;
    }
    else{
      K.at(i+1)=K.at(i);
    }
  }
  for(int i=0; i<Q; i++){
    cout << K.at(R.at(i)-1)-K.at(L.at(i)-1) << endl;
  }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int t;
    cin>>t;
    int ans = t;
    for(int i =1;i<n;i++){
        cin>>t;
        ans = ans*(t/__gcd(t,ans));
    }
    cout<<ans<<endl;








    }















































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int x; cin >> x;
    long long int ans = (x / 11) * 2;
    int r = x % 11;
    if (0 < r && r < 7) ans++;
    else if(6 < r && r < 11) ans += 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iterator>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;

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

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    {
      let mut v = Vec::new();
      for _ in 0..$i {
        v.push($e.get::<$t>());
      }
      v
    }
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

fn binary_search<T>(vec: &Vec<T>, val: T) -> Option<usize>
  where T: Sized + Ord
{
  let (mut l, mut r) = (0, vec.len());
  let mut m = (l + r) / 2;
  while l < r {
    if vec[m] == val {
      return Some(m);
    }
    else if vec[m] < val { l = m + 1 }
    else { r = m }
    m = (l + r) / 2;
  }
  None
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let n = scan!(sc; i32);
  let s = scan!(sc => n; i32);
  let q = scan!(sc; i32);
  let t = scan!(sc => q; i32);
  let mut ans = 0;
  for &i in t.iter() {
    if let Some(_) = binary_search(&s, i) {
      ans += 1;
    }
  }
  println!("{}", ans);
}



Measured memory_bytes: 5052
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n>>m;
	if(n>9||m>9){
		cout << -1 << endl;
	}else{
		cout << n*m << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import math

N, K = map(int, input().split())
probability = 0

for n in range(1, N + 1):
	if n < K:
		p = math.ceil((math.log2(K / n )))
		probability = probability + 1/((2**p)*N)
	else:
		probability = probability + 1 / N

print(probability)

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

int main() {
  double n, k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a.at(i);
  cout << ceil((n-1)/(k-1)) << endl;
  return 0;
}

Measured memory_bytes: 640
fun main (args : Array<String>) {
	val s = readLine()!!.toString()
	var list : MutableList<String> = mutableListOf()
	for (i in s) {
		list.add(i.toString())
	}
	for (i in 0..list.size - 1) {
		if (i == 0 || (i % 2) == 0) {
			if ( (list[i] != "R") && (list[i] != "U") && (list[i] != "D")) {
				return println("No")
			}
		} else {
			if ( (list[i] != "L") && (list[i] != "U") && (list[i] != "D")) {
				return println("No")
			}
		}
	}
	println("Yes")
}

Measured memory_bytes: 33788
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

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

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

bool jud(int y,int x,int h,int w){//グラフないか判断.
	return (0<=y and y<h)and(0<=x and x<w);
}

int main(){//BFSで解く!
	using type=tuple<bool,int,int,int,int>;//tuple(jud,cnt,y,x,dp).
	
	int h,w;
	cin>>h>>w;
	
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	ch--, cw--, dh--, dw--;
	
	vector<string> s(h);
	REP(i,h) cin>>s[i];
	
	vvi dp(h,vi(w,INF));
	dp[ch][cw]=0;
	priority_queue<type> pque;//コストが少ないものを優先的に探索する.
	int cnt=0;//探索回数(マイナスでカウントするのに注意).
	pque.push(type(true,cnt--,ch,cw,0));
	while(!pque.empty()){
		int y,x,value;
		tie(ignore,ignore,y,x,value)=pque.top();
		pque.pop();
		if(value>dp[y][x]) continue;
		
		FOR(i,-2,2)FOR(j,-2,2){
			int ny=y+i, nx=x+j;//移動先.
			if(jud(ny,nx,h,w)){
				bool flag=false;//移動Aでいけるか.
				REP(k,4){
					if(i==dy[k] and j==dx[k]) flag=true;
				}
				
				if(s[ny][nx]=='.'){
					if(chmin(dp[ny][nx],dp[y][x]+(flag?0:1))){
						pque.push(type(flag,cnt--,ny,nx,dp[ny][nx]));//注意!!!
					}
				}
			}
		}
	}
	
	if(dp[dh][dw]==INF) cout<<-1<<endl;
	else cout<<dp[dh][dw]<<endl;
}

Measured memory_bytes: 9444
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

x=intput()
if x==0:
    print(1)
else:
    print(0)

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

typedef long long ll;
const double PI = 3.1415926535897932384626433;
const int MOD = 1e9+7;
const int INF = 1e9;
#define rep(i, n) for(int i=0;i<(n);++i)
#define SIZE 20

//prototype declaration

//gloval variable


typedef struct{
  int size;
  int count;
  char data[SIZE];
  char * top;
}stack;

void initialize(stack * s){
  s->size = SIZE;
  s->count = 0;
  s->top = &(s->data[SIZE]);
}

void push(stack * s, char x){
  if(s->count >= s->size){
    fprintf(stderr, "Error: stack overflow.\n");
    exit(1);
  }else{
    s->top--;
    *(s->top) = x;
    s->count++;
  }
}

int pop(stack * s){
  int x;
  if(s->count <= 0){
    return 0;
  }else{
    x = *(s->top);
    s->top++;
    s->count--;
    return x;
  }
}

void print_all(stack * s){
  char * p = (s->top)+(s->count-1);
  for(int i = 0; i < s->count; i++, p--){
    printf("%c", *p);
  }
  printf("\n");
}

int main(void){
  char s[10];
  scanf("%s", s);
  stack stack;
  initialize(&stack);
  for(int i = 0; s[i]!='\0'; i++){
    if(s[i] != 'B'){
      push(&stack, s[i]);
    }else{
      pop(&stack);
    }
  }
  print_all(&stack);
  return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    bool seen[n];
    rep(i,n) seen[i] = false;
    int a[n];
    rep(i,n) cin >> a[i];
    int next = 0;
    rep(i,n){
        if(next == 1){
            cout << i  << endl;
            return 0;
        }
        seen[next] = true;
        next = a[next]-1;
        if(seen[next] == true){
            cout << -1 << endl;
            return 0;
        }

    }
    return 0;
}

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

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

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

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

int main(){
  int r;cin >> r;
  cout << r * r * 3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
string substring(string text, int low, int digit){
    string output = "";
    for(int i = low; i < low + digit; i++){
        output.push_back(text[i]);
    }

    return output;
}
 
int main(){
    int N;
    int M;
    cin >> N >> M;
    string A[N];
    string B[M];
    bool ok = false;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N - M + 1; i++){
        for(int j = 0; j < N - M + 1; j++){
            bool ok = true;
            for(int k = 0; k < M; k++){
            	for(int l = 0; l < M; l++){
            		if(A[i + k][j + l] != B[l][k]){
            			ok = false;
            			break;
            		}
            	}
            	if(!ok){
            		break;
            	}
            }
            if(ok){
            	cout << "Yes" << endl;
            	return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
//#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 1, 0, -1, 0 };
vi yy = { 0, 1, 0, -1 };
string dir = "LRUD";

const int N = 2e5 + 50, oo = 5e18 + 500;
//const int mod = 998244353;
const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-6, PI = 2 * acos(0.0);
int n, m, k;
int cnt = 0;
int lg = 18;
vi g[N];
vi rg[N];
vi visit(N, 0);

vi fact(N);

int inv(int a)
{
	int deg = mod - 2;
	int res = 1;
	while (deg)
	{
		if (deg & 1)
		{
			res = res * a % mod;
		}

		deg >>= 1;
		a = a*a % mod;
	}
	return res;
}

int C(int n, int k)
{
	return fact[n] * inv(fact[k]) % mod*inv(fact[n - k]) % mod;
}


signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n >> m;
	int a, b;
	cin >> a >> b;

	fact[0] = 1;
	for (int i = 1; i <= n+m; i++)
	{
		fact[i] = fact[i - 1] * i % mod;
	}

	int x = n - a, y = b + 1;

	while (x > 0 && y <= m)
	{
		cnt = (cnt + C(x + y - 2, x - 1)*C(n - x + m - y, n - x)) % mod;
		x--;
		y++;
	}

	cout << cnt << endl;
}



Measured memory_bytes: 15048
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N, M; cin >> N >> M;
  vector <int> WA(N);
  vector <bool> AC(N);

  int C = 0, P = 0;
  for (int i = 0; i < M; i++){
    int A; cin >> A; A--;
    string S; cin >> S;
    if (S == "AC"){
      if (AC[A] == false){
        AC[A] = true;
        C++;
        P += WA[A];
      }
    }else{
      WA[A]++;
    }
  }
  cout << C << " " << P << endl;
  
  
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using static System.Console;
 
public class B{
  static void Main(string[] args)
  {
    var s = Array.ConvertAll(new string[] { ReadLine(), ReadLine(), ReadLine(), ReadLine(), ReadLine() }, int.Parse);
    var sum = s.Aggregate(0, (n, elem) => elem % 10 == 0 ? n + elem: n + elem - elem%10 + 10);
    var min = s.Where(x => x % 10 != 0);
    var frac = min.Any() ? min.Min(x => x % 10) -10 : 0;
    WriteLine(sum + frac);
  }
}

Measured memory_bytes: 11348
console.log((args=>{
  const [HW,...S] = args.trim().split`\n`;
  const [H,W] = HW.split` `.map(v=>v|0);
  const map = Array.from({length:H},_=>Array(W).fill(0));
  for ( let i = 0; i < H; i++ ) {
    let w = 0;
    for ( let j = 0; j <= W; j++ ) {
      if ( j === W || S[i][j] === '#' ) {
        for ( let k = j-w; k < j; k++ ) map[i][k] += w;
        w = 0;
      } else w++;
    }
  }
  let max = 0;
  for ( let i = 0; i < W; i++ ) {
    let h = 0, hmax = 0;
    for ( let j = 0; j <= H; j++ ) {
      if ( j === H || S[j][i] === '#' ) {
        if ( max < hmax + h ) max = hmax + h;
        h = 0; hmax = 0;
      } else {
        ++h;
        if ( hmax < map[j][i] ) hmax = map[j][i]
      }
    }
  }
  return `${max-1}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int A = 0, B = 0;

	for (int i = 0; i < n; i++)
	{
		char c;
		if (i % 2 == 0) c = '0';
		else c = '1';
		if (s[i] != c) A++;
	}
	for (int i = 0; i < n; i++)
	{
		char c;
		if (i % 2 == 1) c = '0';
		else c = '1';
		if (s[i] != c) B++;
	}
	int ans = min(A, B);
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
int a,b,c,d,e;
while(1){
scanf("%d %d %d\n",&a,&b,&c);
if(a==-1 && b==-1 && c==-1){
break;
}
else{
d=3600*a+60*b+c;
d=7200-d; 
e=d*3;
a=d/3600;
d=d-a*3600;
b=d/60;
d=d-b*60;
c=d;
if(c<10 && b<10){
printf("0%d:0%d:0%d\n",a,b,c);
}
else if(c<10 && b>9){
printf("0%d:%d:0%d\n",a,b,c);
}
else if(c>9 && b<10){
printf("0%d:0%d:%d\n",a,b,c);
}
else{
printf("0%d:%d:%d\n",a,b,c);
}
a=e/3600;
e=e-a*3600;
b=e/60;
e=e-b*60;
c=e;
if(c<10 && b<10){
printf("0%d:0%d:0%d\n",a,b,c);
}
else if(c<10 && b>9){
printf("0%d:%d:0%d\n",a,b,c);
}
else if(c>9 && b<10){
printf("0%d:0%d:%d\n",a,b,c);
}
else{
printf("0%d:%d:%d\n",a,b,c);
}
}
}
return 0;
}



Measured memory_bytes: 2016
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		int max = 0;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			max = Math.max(tmp, max);
			sum += tmp;
		}
		System.out.println(sum - max > max ? "Yes" : "No");
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
enum COLOR{WHITE, BLACK};

struct Edge{
    int w, i, j;
    Edge(int w_, int i_, int j_) : w(w_), i(i_), j(j_) {}
    bool operator< (const Edge& right) const{
        return w > right.w;
    }
};

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> G[i][j];
            if (G[i][j] == -1) G[i][j] = 1e8;
        }
    }
    vector<COLOR> state(n, WHITE);
    priority_queue<Edge> prim;
    state[0] = BLACK;
    int sum = 0;
    int idx_new_gray = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (state[j] != WHITE) continue;
            prim.push(Edge(G[idx_new_gray][j], idx_new_gray, j));
        }
        while (state[prim.top().j] == BLACK) prim.pop();
        sum += G[prim.top().i][prim.top().j];
        state[prim.top().j] = BLACK;
        idx_new_gray = prim.top().j;
        prim.pop();
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3196
from collections import deque

N = int(input())
ans = deque()

while N > 0:
    N -= 1

    tmp = input().split()

    if tmp[0] == "delete":
        # for文だとTLEになる
        # for i in range(len(ans)):
        #     if ans[i] == tmp[1]:
        #         ans.pop(i)
        #         break

        try:
            ans.remove(tmp[1])
        except:
            pass

    elif tmp[0] == "deleteFirst":
        ans.popleft()

    elif tmp[0] == "deleteLast":
        ans.pop()

    else:
        ans.appendleft(tmp[1])

print(*ans)


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n), b(n);
	long long suma = 0, sumb = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		suma += a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		sumb += b[i];
	}

	if (sumb > suma) {
		cout << -1 << endl;
		return 0;
	}

	vector<long long> diff;
	for (int i = 0; i < n; i++) {
		if (a[i] >= b[i]) {
			diff.emplace_back(a[i] - b[i]);
		}
	}
	sort(diff.rbegin(), diff.rend());
	for (int i = 1; i < diff.size(); i++) {
		diff[i] += diff[i - 1];
	}

	int ans = 0;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < b[i]) {
			sum += b[i] - a[i];
			ans++;
		}
	}
	if (sum != 0) {
		for (int i = 0; i < diff.size(); i++) {
			if (sum <= diff[i]) {
				ans += i + 1;
				break;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
    	Scanner s = new Scanner(System.in);
    	int n = s.nextInt();
    	int[] a = new int[] {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    	
    	System.out.println(a[n-1]);
    	}
    }


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

int main() {
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  if (n < 1000) cout << "ABC" << '\n';
  else cout << "ABD" << '\n';
  return 0;
}

Measured memory_bytes: 256