akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        q: u32,
        s: chars,
        lr: [[usize; 2]; q]
    }
    let mut m: [u32; 100009] = [0; 100009];
    (2..n+1).into_iter().for_each(|i| m[i] = if s[i-2] == 'A' && s[i-1] == 'C' { m[i-1] + 1 } else { m[i-1] }); 
    lr.into_iter().for_each(|lr_| {
        println!("{}", m[lr_[1]] - m[lr_[0]]);
    })
}


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

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, cnt = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < 1000; ++i) {
    int d[] = {i/100, (i/10)%10, i%10};
    int f = 0;
    for (char c : s) {
      if (c == ('0' + d[f])) f++;
      if (f == 3) break;
    }
    if (f == 3) ++cnt;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF 1e9+7
#define LLINF 1e18
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    ll a[1010][3],ans=-LLINF;
    rep(i,n){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    rep(i,8){
        vector<ll> vec;
        rep(j,n){
            ll s=0;
            rep(k,3){
                if((i/(1<<k)) %2 ==0){
                    s += a[j][k];
                }else{
                    s -= a[j][k];
                }
            }
            vec.pb(s);
        }
        sort(all(vec));
        reverse(all(vec));
        ll sum=0;
        rep(j,m) sum+= vec[j];
        ans =max(ans,sum);
    }
    cout<< ans<<endl;
    return 0;
}

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

using namespace std;

const long long mod = 1e9 + 7;

long long inv(long long x){
  long long m = mod;
  long long u = 1;
  long long v = 0;
  while(m){
    long long t = x / m;
    x -= t * m;
    swap(x, m);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if(u < 0) u += mod;
  return u;
}

void half_p_init(vector<long long>& half_p){
  half_p[0] = 1;
  for(int i = 1; i < (int)half_p.size(); i++){
    long long half = inv(2);
    half_p[i] = half_p[i - 1] * half % mod;
  }
}

void find_parent(int x, vector<vector<int>>& graph, vector<int>& parent){
  for(int child : graph[x]){
    if(child != parent[x]){
      parent[child] = x;
      find_parent(child, graph, parent);
    }
  }
}

int measure_card(int x, vector<vector<int>>& graph, vector<int>& parent, vector<int>& card){
  card[x] = 1;
  for(int child : graph[x]){
    if(child == parent[x]) continue;
    card[x] += measure_card(child, graph, parent, card);
  }
  return card[x];
}

long long exp(int x, vector<vector<int>>& graph, vector<int>& parent, vector<int>& card, vector<long long>& half_p){
  int n = graph.size();
  
  if(graph[x].size() == 1) return 0;
  
  long long prob = mod + 1 - half_p[n - 1];
  prob %= mod;
  for(int child : graph[x]){
    long long p;
    if(child == parent[x]){
      p = half_p[n - 1] * inv(half_p[n - card[x]]);
      p %= mod;
      p *= (1 - half_p[n - card[x]]);
      p %= mod;
    }else{
      p = half_p[n - 1] * inv(half_p[card[child]]);
      p %= mod;
      p *= (1 - half_p[card[child]]);
      p %= mod;
    }
    prob -= p;
    while(prob < 0) prob += mod;
    prob %= mod;
  }
  
  return (prob * half_p[1]) % mod;
}

int main(){
  int n;
  cin >> n;
  
  vector<long long> half_p(n + 1);
  half_p_init(half_p);
  
  vector<vector<int>> graph(n);
  vector<int> parent(n, -1);
  vector<int> card(n);
  
  for(int i = 0; i < n - 1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  
  find_parent(0, graph, parent);
  int tmp = measure_card(0, graph, parent, card);
  
  long long anarchy = 0;
  for(int i = 0; i < n; i++){
    anarchy += exp(i, graph, parent, card, half_p);
    anarchy %= mod;
  }
  
  cout << anarchy << endl;
  
  return 0;
}
  

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

int main () {
    int cnt = 1;
    int cnt4 = 0;
    int n;
    std::cin >> n;

    bool f = n == 1 || n == 2;
    while (1)
    {

        if (n == 4)
        {
            cnt4++;
        }

        if (cnt4 == 2)
        {
            break;
        }

        if(n%2 == 0) {
            n /= 2;
        } else {
            n *= 3;
            n++;
        }

        cnt++;
    }

    if(f) {
        std::cout << 4 << "\n";
    } else {
        std::cout << cnt << "\n";
    }
}

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

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int a, b, c;
	cin >> a >> b >> c;
	if ((a < c && c < b) || (b < c && c < a)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N = int(input())

texts = {}

for i in range(N):
  text = list(input())
  text.sort()
  text = "".join(text)
  if text not in texts:
    texts[text] = 1
  else:
    texts[text] += 1

print(sum(i * (i - 1) // 2 for i in texts.values()))


Measured memory_bytes: 17808
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};
int main(){
	int n;
	cin>>n;
	int mi=inf;
	int sum=0;
	rep(i,n){
		int a;cin>>a;
		if(a%10)mi=min(mi,a);
		sum+=a;
	}
	if(sum%10)cout<<sum<<endl;
	else{
		if(mi==inf)cout<<0<<endl;
		else cout<<sum-mi<<endl;
	}
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
int main(){
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dpa[n]={0},dpb[n]={0},dpc[n]={0};
    dpa[0]=a[0];
    dpb[0]=b[0];
    dpc[0]=c[0];
    for(int i=1;i<n;i++){
        dpa[i]=a[i]+max(dpb[i-1],dpc[i-1]);
        dpb[i]=b[i]+max(dpa[i-1],dpc[i-1]);
        dpc[i]=c[i]+max(dpb[i-1],dpa[i-1]);
    }
    cout<<max(max(dpa[n-1],dpb[n-1]),dpc[n-1]);
    return 0;
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

unordered_map<int64_t, int64_t> bunkai(int64_t N)
{
    unordered_map<int64_t, int64_t> hist;

    int64_t a = 2;
    while (N >= a * a)
    {
        if (N % a == 0)
        {
            hist[a]++;
            N /= a;
        }
        else
            a++;
    }
    hist[N]++;
    return hist;
}

int64_t mypow(int64_t x, int64_t y) //x ^ y
{
    if (y == 1)
        return x;
    else if (y % 2 == 1)
        return mypow(x, y - 1) * x % MOD;
    else
    {
        int64_t tmp = mypow(x, y / 2);
        return tmp * tmp % MOD;
    }
}

int main()
{
    int64_t N, tmp, ans = 0;
    cin >> N;

    vector<int64_t> list(N);
    unordered_map<int64_t, int64_t> LCM;

    for (int i = 0; i < N; i++)
    {
        cin >> list[i];
        auto tmp = bunkai(list[i]);
        for (auto x : tmp)
            LCM[x.first] = max(LCM[x.first], x.second);
    }

    int64_t lcm = 1;
    for (auto x : LCM)
        lcm *= pow(x.first, x.second), lcm %= MOD;
    
    for (int i = 0; i < N; i++)
        ans = (ans + lcm * mypow(list[i], MOD - 2)) % MOD;

    cout << ans;
}

Measured memory_bytes: 4288
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int x, a, b;
    std::cin>>x>>a>>b;

    std::string ans;
    if(abs(x - a) > abs(x - b)){
        ans = 'B';
    }else{
        ans = 'A';
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
string C1,C2;
bool is_mirror(string C1,string C2){
    for(int i=0;i<3;i++){
        if(C1[i]!=C2[2-i]){
        return false;
        }
    }
    return true;
}
int main(int argc, char const *argv[])
{
    cin>>C1>>C2;
    if(is_mirror(C1,C2)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    input_raw = read_func().strip().split()
    B = [int(input_raw[i]) for i in range(M)]


    count = 0
    for i in range(N):
        input_raw = read_func().strip().split()
        s = 0
        for j in range(M):
            s += int(input_raw[j]) * B[j]
        s += C
        if s > 0:
            count += 1

    print count


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int a = Integer.parseInt(strArr[0]);
            int b = Integer.parseInt(strArr[1]);
            int c = Integer.parseInt(strArr[2]);
            int d = Integer.parseInt(strArr[3]);

            if (Math.abs(a - c) <= d || (Math.abs(a - b) <= d && Math.abs(b - c) <= d)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 21076
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1000000;
int main()
{
	int a,a1,b,b1,c,c1,k,i;
	while(cin>>a>>b>>c){
		k=0;
		for(i=1;i<N;i++){
			if(a%2==0 && b%2==0 &&c%2==0){
				k++;
			}
			else{
				break;
			}
			a1=a/2;b1=b/2;c1=c/2;
			a=b1+c1;b=a1+c1;c=b1+a1;
		}
		if(i<N) printf("%d\n",k);
		else printf("-1\n");
	}
}

Measured memory_bytes: 256
int main(){
    int x, y;
    
    while(1){
        scanf("%d%d", &x, &y);
        
        if(x == 0 && y == 0)
        break;
        
        if(x <= y)
        printf("%d %d\n", x, y);
        else
        printf("%d %d\n", y, x);
    }
    
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
int n;
int a[N], b[N];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++) cin >> b[i];
    int ans = 0;
    for(int i = 2; i < n; i++) {
        ans += min(b[i - 1], b[i]);
    }
    ans += b[1] + b[n - 1];
    cout << ans;
}

Measured memory_bytes: 3632
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int ans = Math.min(B, D) - Math.max(A, C);
        System.out.println(ans >= 0 ? ans : 0) ;
    }
}


Measured memory_bytes: 25172
N, K, Q = list(map(int, input().split()))
P_list = [K for _ in range(N)]

P_list = list(map(lambda x:x-Q, P_list))


for _ in range(Q):
    a = int(input())-1
    P_list[a] += 1

for i in range(N):
    if P_list[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 7984
n = int(input())
S = []
for i in range(n):
    S.append(input())

OrdA = ord('a')
ans = ''

for alpha in range(0, 26):
    Chr = chr(OrdA + alpha)
    Count = []
    for i in range(n):
        Count.append(S[i].count(Chr))
    ans += Chr * min(Count)

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long ll;

ll d;
ll c[29];
ll a[369][29];
ll t[369];
ll b[29];
ll b2[29];
ll now[369];
ll ans;
bool vv[369];
ll ans3[369];
double ch1 = 1.1;
double ch2 = 0.05 / 26;

bool g()
{
    ll re = 0;
    for(ll i = 1; i <= 26; i++) b[i] = 0;
    for(ll i = 1; i <= d; i++)
    {
        b[now[i]] = i;
        for(ll j = 1; j <= 26; j++)
        {
            re -= (i - b[j]) * c[j];
        }
        re += a[i][now[i]];
        if(re * (ch1 - ch2 * i) < ans3[i]) return false;
    }
    if(ans < re) {ans = re; return true;}
    else return false;
}

bool f()
{
    ll x = rand() % 26 + 1;
    ll y = rand() % d + 1;
    if(vv[y])
    {
        return g();
    }
    ll ans2 = 0;
    ll t2 = now[y];
    now[y] = x;
    vv[y] = true;
    bool v = false;
    if(rand() % 100 == 0) v = f();
    else v = g();
    if(!v) now[y] = t2;
    vv[y] = false;
    return v;
}

int main()
{
//    freopen("input.txt", "r", stdin);
    srand(time(NULL));
    scanf("%lld", &d);
    for(ll i = 1; i <= 26; i++)
    {
        scanf("%lld", &c[i]);
    }
    for(ll i = 1; i <= d; i++)
    {
        for(ll j = 1; j <= 26; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    ans = 0;
    for(ll i = 1; i <= d; i++)
    {
        ll mx = -4e18, mi = 0;
        for(ll ii = 1; ii <= 26; ii++)
        {
            t[i] = ii;
            ll ans2 = 0;
            ll tt = b[t[i]];
            b[t[i]] = i;
            for(ll j = 1; j <= 26; j++)
            {
                ans2 -= (i - b[j]) * c[j];
            }
            ans2 += a[i][t[i]];
            if(mx < ans2) mx = ans2, mi = ii;
            b[t[i]] = tt;
        }
        t[i] = mi;
        b[t[i]] = i;
        for(ll j = 1; j <= 26; j++)
        {
            ans -= (i - b[j]) * c[j];
        }
        ans += a[i][t[i]];
        now[i] = mi;
        ans3[i] = ans;
    }
    ll k = 0;
    k = 150000;
    while(k--)
    {
        f();
    }
    for(ll i = 1; i <= d; i++) printf("%lld\n", now[i]);
//    printf("\n\n%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
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 INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  char s;
  cin>>s;
  if(isupper(s)){
    cout<<"A"<<endl;
  }
  else{
    cout<<"a"<<endl;
  }
}

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

///////////////////////////////////////////
const long long int INF = INT64_MAX;
//const long long int INF = 1000000;
const long long int Mod = 1000000007;
using ll = long long int;
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////

int main(){
    string s;cin>>s;
    int n = s.size()-1;
    ll sum=0;

    for(int i = 0;i < (1<<n);i++){
        int l = 0;int r;
        ll tmp =0;
        for(r=0;r<n;r++){
            if((i & (1<<r))!=0){
                ll cc = stoll(s.substr(l,r-l+1));
                sum += cc;l = r+1;
            }

        }
        sum += stoll(s.substr(l,r-l+1));
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int n,f;
    int b[100001];
    int main()
    {
        scanf("%d",&n);
        int k=0;
        int c=0;
        for(int i=1;i<=n;i++)
          {
              scanf("%d",&b[i]);
              if(b[i]%4==0) k++;
              if(b[i]%2==0) c++;
          }
          int w=c-k;
        if(((w/2)+k)>=n/2) printf("Yes");
            else printf("No");
     
    }

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 1000005;
const int MM = 998244353;

int A[MX];
int N;

bitset<2000*1000+1> t, u;

int main()
{
	int tot = 0;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", A+i), tot += A[i];

	t[0] = 1;
	for(int i = 1; i <= N; i++){
		t = t | t << A[i];
	}
	for(int i = tot/2; i >= 0; i--){
		if( t[i] ) return !printf("%d\n", tot - i);
	}
}


Measured memory_bytes: 1280
<?php
fscanf(STDIN, '%d %d %d', $n, $k, $q);
$arr = array_fill(0, $n, 0);
for ($i  = 0; $i < $q; $i++) {
    fscanf(STDIN, '%d', $a);
    $arr[$a - 1]++;
}
for ($i = 0; $i < $n; $i++) {
    if ($k - $q + $arr[$i] > 0) echo 'Yes' . PHP_EOL;
    else echo 'No' . PHP_EOL;
}

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
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 (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)

void Main() {
	int n; cin >> n;
	string s; cin >> s;
	//int ans;
	if (n % 2 == 1) {
		cout << "No";
		return;
	}
	rep(i, n / 2 ) {
		if (s[i] != s[i + n / 2]) {
			cout << "No";
			return;
		}
		//cout <<s[i]<< s[i + n / 2];
	}
	cout << "Yes";
}

signed main() {
	Main();

	return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  ll n;
  cin >> n;
  rep(x, n, 2 * n){
    bool ok = 1;
    for (ll i = 2; i * i <= x; i++){
      if (x % i == 0){
        ok = 0;
        break;
      }
    }
    if (ok){
      cout << x;
      return;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

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

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {
    multimap<string, ll> m;

    int n;
    cin >> n;
    rep(i, n) {
        int command;
        cin >> command;
        if (command == 0) {
            string key;
            cin >> key;

            ll v;
            cin >> v;
            m.insert({key, v});
        } else if (command == 1) {
            string key;
            cin >> key;

            auto p = m.equal_range(key);
            for (auto it = p.first; it != p.second; it++) {
                cout << it->second << endl;
            }
            
        } else if (command == 2) {
            string key;
            cin >> key;

            m.erase(key);
        } else if (command == 3) {
            string l, r;
            cin >> l >> r;

            for (auto it = m.lower_bound(l); it != m.end() && (*it).first <= r; it++) {
                printf("%s %lld\n", (*it).first.c_str(), (*it).second);
            }
        }
    }

}



Measured memory_bytes: 24904
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << endl;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

#ifdef _DEBUG
signed solve()
#else
signed main()
#endif
{
	auto a = IN();
	auto b = IN();
	auto c = IN();
	auto d = IN();

	if (abs(a - c) <= d)
	{
		print("Yes");
		return 0;
	}
	else if (a <= b && b <= c)
		if (abs(a - b) <= d && abs(b - c) <= d)
		{
			print("Yes");
			return 0;
		}
	else if (c <= b && b <= a)
		if (abs(a - b) <= d && abs(b - c) <= d)
		{
			print("Yes");
			return 0;
		}
	print("No");
	return 0;
}


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

int main(){
    int N; cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        if(i + 1 == N) break;
        if(d.at(i) == d.at(i + 1)) count++;
    }

    cout << N - count << endl;
    
    


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int p[] = new int[n+1];
		p[0]=Integer.MAX_VALUE;
		int min[] = new int[n+1];
		min[0]=p[0];
		for(int i=1; i<=n; i++) {
			p[i]=sc.nextInt();
			min[i]=Math.min(min[i-1], p[i]);
		}
		int cnt=0;
		for(int i=1; i<=n; i++) {
			if(min[i-1]>=p[i]) {
				cnt++;
			}
		}
		System.out.println(cnt);
		sc.close();
	}
}


Measured memory_bytes: 89144
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 100010
#define SZ 100010

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
int N;
int dp[SIZE][2];
vector<int> edges[SIZE];
void dfs(int curr,int which)
{
    int fans1 = 1;
    int fans2 = 1;
    for(int i=0;i<edges[curr].size();i++){
        if(edges[curr][i] != which){
            dfs(edges[curr][i],curr);
            int val1 = (dp[edges[curr][i]][0] + dp[edges[curr][i]][1])%MOD;
            int val2 = dp[edges[curr][i]][0];
            fans1 = (1LL*fans1*val1)%MOD;
            fans2 = (1LL*fans2*val2)%MOD;
        }
    }
    dp[curr][0] = fans1;
    dp[curr][1] = fans2;
}
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen(fi, "r", stdin);
    #endif */
    //freopen("route.in","r",stdin);
    //freopen("route.out","w",stdout);
    //cin.ignore();
    //cin.clear();
    boost;
    //cin.tie(0);
    //cout<<"Case "<<tt<<": ";
    cin>>N;
    for(int i=1;i<N;i++){
        int x,y;
        cin>>x>>y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    dfs(1,-1);
    cout<<(dp[1][0] + dp[1][1])%MOD;
    return 0;
}

Measured memory_bytes: 14848
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
  int n,i;
  string s,t;
  cin>>n;
  cin>>s>>t;
  rep(i,n){
    cout<<s[i]<<t[i];
  }
  cout<<endl;
}

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

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    if a <= 0 && 0 <= b {
        println!("Zero");
    } else if a < 0 && b < 0 && (a - b) % 2 == 0 {
        println!("Negative");
    } else {
        println!("Positive");
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int[] a = new int[3];

		for(int i = 0;i<3;i++){

			a[i] = sc.nextInt();

		}

		int sum = 0;

		if(a[0] == a[1]){
			sum++;
		}

		if(a[0] == a[2]){
			sum++;
		}

		if(a[1] == a[2]){
			sum++;
		}

		if(sum == 1){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}


	}

}

Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
	char b;
	scanf("%c",&b);
	switch(b)
	{
		case 'A':printf("T\n");break;
		case 'T':printf("A\n");break;
		case 'C':printf("G\n");break;
		case 'G':printf("C\n");break;
	}
	return 0;
 } 

Measured memory_bytes: 128
from decimal import Decimal
n = int(input())
t,a = map(int,input().split())
hl = list(map(int,input().split()))

num = 10**9
diff = 10**9
for i in range(n):
    tmp = t - Decimal(hl[i] * 0.006)
    tmp_diff = abs(tmp-a)
    
    if tmp_diff < diff:
        num = i + 1
        diff = tmp_diff
print(num)

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

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


int main(){
    int n;
    cin >> n;
    vector<int> array(n),parray(n),qarray(n);
    for(int i=0;i<n;i++) cin >> parray.at(i);
    for(int i=0;i<n;i++) cin >> qarray.at(i);
    int num = 1;
    for(int i=0;i<n;i++){
        array.at(i) = num;
        num++;
    }

    int cnt = 0,p=0,q=0;
    while(next_permutation(array.begin(),array.end())){
        cnt ++;
        if(array == parray) p = cnt;
        if(array == qarray) q = cnt;
        //next_permutation(array.begin(),array.end());
    }
    //cout << p << " " << q << endl;
    cout << abs(p-q) << endl;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    int res = 0;
    for (int i = 1; i <= n; i += 2) {
        int count = 0;
        for (int j = 3; j < i; j += 2) {
            if (i % j == 0) {
                count++;
            }
        }
        if (count == 6) {
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
l = list(map(int, input().split()))
nl = np.array(l)
X = nl.sum()
a = []
x = 0
for i in range(N-1):
    x = x + nl[i]
    a.append(abs(2 * x - X))
print(min(a))

Measured memory_bytes: 33064
#include<bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin>>n;
    if(n==25) {
        cout<<"Christmas";
    }else if(n==24) {
        cout<<"Christmas Eve";
    }else if(n==23) {
        cout<<"Christmas Eve Eve";
    }else if(n==22){
        cout<<"Christmas Eve Eve Eve";
    }
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
if A == 1 and B == 2:
  print(3)
elif A == 2 and B == 1:
  print(3)
elif A == 1 and B == 3:
  print(2)
elif A == 3 and B == 1:
  print(2)
elif A == 2 and A == 3:
  print(1)
else:
  print(1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
char ch[10][10];
int main(){
	scanf("%s%s",ch[1],ch[2]);
	if(ch[1][0]^ch[2][2]||ch[1][1]^ch[2][1]||ch[1][2]^ch[2][0])puts("NO");
	else puts("YES");
}

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

int main(){
    ll x,y;
    cin>>x>>y;
    if(x<0 && y<0) {
        if(x<y) cout<<y-x;
        else cout<<x-y+2;
    }
    else if(x>=0 && y<0) {
        if(abs(x)<abs(y)) cout<<-(x+y)+1;
        else cout<<x+y+1;
    }
    else if(x<0 && y>=0) {
        if(abs(x)<abs(y)) cout<<x+y+1;
        else {
            if(y==0) cout<<-x;
            else cout<<-(x+y)+1;
        }
    }
    else {
        if(x<y) cout<<y-x;
        else {
            if(y==0) cout<<x+1;
            else cout<<x-y+2;
        }
    }
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = in.readLine();
		char ch[] = s.toCharArray();
		for(int i = 0; i < s.length(); i++) {	
			if(Character.isLetter(ch[i])) {
				ch[i] = Character.toUpperCase(ch[i]);
			}
		}
		for(int i = 0; i < s.length(); i++) {
			System.out.print(ch[i]);
		}
		System.out.println();
	}
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define ALL(x) (x).begin(), (x).end()

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

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

// Union Find
// uとrのデータ型，データ数nはご自由に
ll pare[20] = {};
ll rk[20] = {};
void init(int n){
    rep(i, n){
        pare[i] = i;
        rk[i] = i;
    }
}
int find(int x){
    if (x == pare[x])
        return x;
    return pare[x] = find(pare[x]); // 経路圧縮
}
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) // すでに結合済
        return;

    // rkの低い方をrkの高い方に併合
    if(rk[x] < rk[y])
        pare[x] = y;
    else
        pare[y] = x;
    if(rk[x] == rk[y])
        rk[x]++;
}
bool same(int x,int y){
    return find(x) == find(y);
}

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

    int x, y;
    cin >> x >> y;
    REP(i, 1, 13) {
        init(i);
    }

    unite(1, 3);
    unite(5, 7);
    unite(8, 10);
    unite(1, 12);
    unite(5, 8);
    unite(1, 5);
    unite(4, 6);
    unite(9, 11);
    unite(4, 9);

    string ans;
    if(same(x, y)) {
        ans = "Yes";
    } else {
        ans = "No";
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, A, B = sc.nextLong()
  println {
    if ((B - A) % 2 == 0) {
      (B - A) / 2
    } else {
      (A - 1).min(N - B) + 1 + (B - A - 1) / 2
    }
  }
}


Measured memory_bytes: 55324
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);
        var c = int.Parse(spl[2]);
        var d = int.Parse(spl[3]);

        while (true) {
            c -= b;
            if (c <= 0) return Yes;
            a -= d;
            if (a <= 0) return No;
        }
    }
}


Measured memory_bytes: 27240
def PF(n):
    fs = []
    q = int(n ** 0.5) 
    for i in range(2, q + 1):
        if n % i == 0:
            r = 0
            while n % i == 0:
                n //= i
                r += 1
            fs.append([i, r])
    if n != 1:
        fs.append([n, 1])
    return fs

P=[0]*1000
x=1
N=int(input())
for i in range(2,N+1):
  A=PF(i)
  for j in range(len(A)):
    P[A[j][0]]=P[A[j][0]]+A[j][1]
P.remove(0)
for i in range(len(P)):
  x=(x*(P[i]+1))%(10**9+7)
print(x)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
    long A,B,C,D;
    cin >> A >> B >> C >> D;
    long c = (B/C) - ((A-1)/C);
    long d = (B/D) - ((A-1)/D);

    long cd = C*D;
    if(C < D){
        long tmp = C;
        C = D; D = tmp;
    }

    long r = C % D;
    while(r!=0){
        C = D; D= r; r = C % D;
    }

    long long l = cd / D;
    long lnum = (B/l) - ((A-1)/l);

    long count = B - A + 1 - (c + d - lnum);
    cout  << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>


int main()
{
    int n, m, a[20][20], b[20], c, cnt = 0, t;

    std::cin >> n >> m >> c;
    for(int i = 0;i < m;i++) std::cin >> b[i];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            std::cin >> a[i][j];
        }
    }

    for(int i = 0;i < n;i++){
        t = 0;
        for(int j = 0;j < m;j++){
            t += a[i][j] * b[j];
        }
        if(t > -c){
            cnt++;
        }
    }

    std::cout << cnt;


    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	int x[n+1],s=0;
	for(int i=0;i<n;s+=x[i],i++)scanf("%d",&x[i]);
	int count=0;
	for(int i=0;i<n;i++)if(x[i]*4*m>=s)count++;
	if(count>=m)printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  string S;
  cin >> S ;
  cout << (S=="ABC"?"ARC":"ABC")<< endl;
  
}

Measured memory_bytes: 3620
A, B, C, D = map(int,input().split())

if C % B == 0:
    taka_kougeki = C // B
else:
    taka_kougeki = C // B + 1

if A % D == 0:
    ao_kougeki = A // D
else:
    ao_kougeki = A // D + 1

if taka_kougeki <= ao_kougeki:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

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

const int INF = numeric_limits<int>::max();

ll Chu_Liu_Edmonds(vector<Edge> edge, int V, int start){
	vector<pair<int, int> > mincost(V, make_pair(INF, -1));

	for (int i = 0; i < edge.size(); ++i)
	{
		Edge e = edge[i];
		mincost[e.second.second] = min(mincost[e.second.second], make_pair(e.first, e.second.first));
	}
	mincost[start] = make_pair(-1, -1);

	vector<int> group(V, 0);
	vector<bool> isCycle(V, false);
	int cnt = 0;

	vector<bool> used(V, false);
	for (int i = 0; i < V; ++i)
	{
		if (used[i]) continue;
		vector<int> chain;
		int cursor = i;
		while (cursor != -1 && !used[cursor]) {
			used[cursor] = true;
			chain.push_back(cursor);
			cursor = mincost[cursor].second;
		}
		if (cursor != -1) {
			bool inCycle = false;
			for (int j = 0; j < chain.size(); ++j) {
				group[chain[j]] = cnt;
				if (chain[j] == cursor) {
					isCycle[cnt] = true;
					inCycle = true;
				}
				if (!inCycle) cnt++;
			}
			if (inCycle) cnt++;
		}
		else {
			for (int j = 0; j < chain.size(); ++j) {
				group[chain[j]] = cnt;
				cnt++;
			}
		}
	}

	if (cnt == V)
	{
		ll ans = 1;
		for (int i = 0; i < V; ++i)
		{
			ans += mincost[i].first;
		}
		return ans;
	}

	ll res = 0;
	for (int i = 0; i < V; ++i) {
		if (i != start && isCycle[group[i]]) res += mincost[i].first;
	}

	vector<Edge> newEdge;
	for (int i = 0; i < edge.size(); ++i) {
		Edge e = edge[i];
		int to = e.second.second;
		int gfrom = group[e.second.first];
		int gto = group[e.second.second];
		if (gfrom == gto) continue;
		else if (isCycle[gto]) newEdge.push_back(make_pair(e.first - mincost[to].first, make_pair(gfrom, gto)));
		else newEdge.push_back(make_pair(e.first, make_pair(gfrom, gto)));
	}

	return res + Chu_Liu_Edmonds(newEdge, cnt, group[start]);
}


int main(int argc, char const *argv[])
{
	int V, E, r;
	cin >> V >> E >> r;
	vector<Edge> graph;
	for (int i = 0; i < E; ++i)
	{
		int s, t, w;
		cin >> s >> t >> w;
		graph.push_back(make_pair(w, make_pair(s,t)));
	}

	cout << Chu_Liu_Edmonds(graph, V, r) << endl;
	return 0;
}


Measured memory_bytes: 3780
N = list(input())
if N[-1] == "3":
    print('bon')
elif N[-1] == "0":
    print('pon')
elif N[-1] == "1":
    print('pon')
elif N[-1] == "6":
    print('pon')
elif N[-1] == "8":
    print('pon')
else:
    print('hon')

Measured memory_bytes: 9064
import re,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
p1 = r'.*keyence'
p2 = r'k.*eyence'
p3 = r'ke.*yence'
p4 = r'key.*ence'
p5 = r'keye.*nce'
p6 = r'keyen.*ce'
p7 = r'keyenc.*e'
p8 = r'keyence.*'
if re.fullmatch(p1,S) or re.fullmatch(p2,S) or re.fullmatch(p3,S) or re.fullmatch(p4,S) or re.fullmatch(p5,S) or re.fullmatch(p6,S) or re.fullmatch(p7,S) or re.fullmatch(p8,S):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define lf double
#define E complex<lf>
#define inf 0x3f3f3f3f
#define eps 1e-8
#define pa pair<int,int>
#define pb push_back
#define ms(x,y) memset(x,y,sizeof(x))
#define l(x) (x<<1)
#define r(x) (x<<1|1)
#define mod 1000000007
#define N 210
using namespace std;
inline ll read() {
	ll x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int n;
int a[N];
int main() {
	n=read();
	for (int i=1; i<=2*n; i++) a[i]=read();
	sort(a+1,a+1+n*2);
	int ans=0;
	for (int i=1; i<=n*2; i+=2) ans+=a[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string st;
int da=0;
int he,n;
void ss(string st,int q)
{
	if(q>n-1)
	{
	    cout<<da<<endl;
		return;
	}
	if(st[q]=='I')he++;
	else he--;
	da=max(da,he);
	ss(st,q+1);
}
int main()
{
	cin>>n>>st;
	ss(st,0);
	return 0;
}

Measured memory_bytes: 256