akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// DAME:
ll pmid(ll mid, ll tmp){
    // 標準だと-2/3 -> 0となってしまう
    if (mid<0 and mid%tmp!=0) return mid/tmp-1;
    return mid/tmp;
}

ll mmid(ll mid, ll tmp){
    if (mid<0 and mid%tmp!=0) return mid/tmp+1;
    return mid/tmp;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll inf = ll(1e18)+1;
    ll left = -inf, right = inf;
    // mid未満のものを数える
    while(left+1 < right){
        ll mid = (left+right)/2;
        ll cnt = 0;
        rep(i, n){
            ll tmp = a[i];
            if (tmp>0){
                int l = -1, r = n;
                while(l+1<r){
                    int c = (l+r)/2;
                    if(a[c]*tmp <= mid) l = c;
                    else r = c;
                }
                cnt += r;
            }else if (tmp==0){
                if (mid>=0) cnt+=n;
            }else{
                int l = -1, r = n;
                while(l+1<r){
                    int c = (l+r)/2;
                    if(a[c]*tmp <= mid) r = c;
                    else l = c;
                }
                cnt += n-r;
            }
            if (tmp*tmp <= mid) cnt--;
        }
        cnt /= 2;
        if (cnt >= k){
            right = mid;
        }else{
            left = mid;
        }
    }

    cout << right << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-6;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    int a[4],b[4];
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
        bool f[4]={false};
        int h=0,bb=0;
        for(int i=0;i<4;i++){
            if(a[i]==b[i]){
                f[i]=true;
                h++;
            }
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(f[j])continue;
                if(b[i]==a[j]){
                    bb++;
                    break;
                }
            }
        }
        cout<<h<<" "<<bb<<endl;
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int div2 = 0;
  int div4 = 0;
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    if(a.at(i) % 4 == 0) 
      div4++;
    else if(a.at(i) % 2 == 0)
      div2++;
  }
  
  int max = 0;
  if(div2 > 1)
    max = 2 * div4 + div2;
  else
    max = 2 * div4 + 1;
  
  if(max >= n)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 640
s = input()
X = list(s)
Y = []

for i in range(len(X)):
    if X[i] != 'B':
        Y.append(X[i])
    else:
        if Y != []:
            Y.pop(-1)

ans = ''
for i in range(len(Y)):
    ans += Y[i]

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 2010;

int n, X, Y, a[N], f[N][2], vis[N][2];

int dfs(int x, int y)
{
    if (vis[x][y]) return f[x][y]; vis[x][y] = 1;
    if (y == 0)
    {
        f[x][y] = x == 1 ? abs(a[n] - Y) : abs(a[n] - a[x - 1]);
        FOR(i, x, n - 1) f[x][y] = max(f[x][y], dfs(i + 1, y ^ 1));
    }
    else
    {
        f[x][y] = x == 1 ? abs(a[n] - X) : abs(a[n] - a[x - 1]);
        FOR(i, x, n - 1) f[x][y] = min(f[x][y], dfs(i + 1, y ^ 1));
    }
    return f[x][y];
}

int main()
{
    scanf("%d%d%d", &n, &X, &Y);
    FOR(i, 1, n) scanf("%d", &a[i]);
    printf("%d\n", dfs(1, 0));
    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
wv_array = [list(map(int, input().split())) for _ in range(N)]

max_v = N * 1000

ans_array = [[10 ** 12] * (max_v + 1) for _ in range(N + 1)]

ans_array[0][0] = 0

for n in range(1, N + 1):
    ans_array[n][0] = 0
    for v in range(1, max_v + 1):
        if wv_array[n - 1][1] > v:
            ans_array[n][v] = ans_array[n - 1][v]
        else:
            ans_array[n][v] = min(
                ans_array[n - 1][v], ans_array[n - 1][v - wv_array[n - 1][1]] + wv_array[n - 1][0])

for v in range(max_v, -1, -1):
    if ans_array[N][v] <= W:
        print(v)
        exit()


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


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

    int judge = 0;

    for(int i = 1; i < 10; i++){
        if((N % i == 0) && (N / i < 10)){
            cout << "Yes" << endl;
            judge = 1;
            break;
        }
    }

    if(judge == 0){
        cout << "No" << endl;
    }
    
    return 0;
}

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

int main(void) {
    int N,K;cin>>N>>K;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin>>H[i];
    sort(H.begin(), H.end());
    int mi = 1e9;
    for (int i = 0; i < N - K + 1; i++) {
        if (mi > H[i + K - 1] - H[i]) {
            mi = H[i + K - 1] - H[i];
        }
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 int main()
{
  long long int n,m;
  cin>>n>>m;
  map<long long int,long long int>h;
  map<long long int,long long int>check;
  for(long long int i=1;i<=n;i++)
  {
  	long long int a;
  	cin>>a;
  	h[i]=a;
  	check[i]=1;
  }
  
  while(m--)
  {
  	long long int a,b;
  	cin>>a>>b;
  	if(h[a]>h[b])
  	{
	check[b]=-1;
	if(check[a]>=0)
	check[a]++;}
  	else
  	if(h[b]>h[a])
    {
	check[a]=-1;
	if(check[b]>=0)
	check[b]++;
    }
    if(h[b]==h[a])
    check[a]=-1,check[b]=-1;
  }
  long long int count=0;
  for(long long int i=1;i<=n;i++)
  if(check[i]>0)
  count++;
  cout<<count;
  
}

Measured memory_bytes: 16124
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var i=0;i<n;i++){
   var arr=Arr.shift().split(" ").map(Number);
   (function(x1, y1, x2, y2, x3, y3, x4, y4){
      var k1=(x2-x1!=0)?(y2-y1)/(x2-x1):1;
      var k2=(x4-x3!=0)?(y4-y3)/(x4-x3):1;
      k1=k1.toFixed(6);
      k2=k2.toFixed(6);
      console.log((k1==k2)?"YES":"NO");
   }).apply(null,arr);
}

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

using ll = long long;

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++) {
        cout << s.at(i) << t.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        if (n % 2 == 0){
            Console.WriteLine(n * (n - 1) / 2 - n / 2);
            for (int i = 1;i <= n;i++){
                for (int j = i + 1;j <= n;j++){
                    if (i + j == n + 1) continue;
                    Console.WriteLine("{0} {1}",i,j);
                }
            }
            return;
        }
        Console.WriteLine(n * (n - 1) / 2 - n / 2);
        for (int i = 1;i < n;i++){
            for (int j = i + 1;j < n;j++){
                if (i + j == n) continue;
                Console.WriteLine("{0} {1}",i,j);
            }
        }
        for (int i = 1;i < n;i++)
            Console.WriteLine("{0} {1}",i,n);
    }
}

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

int main() {
    string s1,s2;cin>>s1>>s2;
    int n1,n2;
    n1 = s1.size();
    n2 = s2.size();
    if(n1>n2){
        cout<<"GREATER"<<endl;
        return 0;
    }
    if(n1<n2){
        cout<<"LESS"<<endl;
        return 0;
    }
    
    rep(i,n1){
        if(s1[i]>s2[i]){
            cout<<"GREATER"<<endl;
            return 0;
        }
        if(s1[i]<s2[i]){
        cout<<"LESS"<<endl;
        return 0;
    }
    }
    cout<<"EQUAL"<<endl;
	return 0;
}

Measured memory_bytes: 3548
#include<stdio.h>
int main ()
{
 int A,B,a,b,c;
 scanf ("%d %d",&A,&B);
 a=A+B;
 b=A-B;
 c=A*B;
     if (a>=b&&a>=c)
     {
         printf ("%d\n",a);
     }
   else if (b>=a&&b>=c)
     {
         printf ("%d\n",b);
     }
    else
     {
         printf ("%d\n",c);
     }
 return 0;
}


Measured memory_bytes: 1724
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=2e5+10;
int dp[L];
char bs[L];
int nx[L];
int last[128];
char A[L];
int main() {
	scanf("%s",A);
	int n=strlen(A);
	for(int i='a';i<='z';i++){
		last[i]=n;
	}
	dp[n]=1;
	bs[n]='a';
	nx[n]=n+1;
	for(int i=n-1;i>=0;i--){
		last[(int)A[i]]=i;
		dp[i]=L;
		for(int j='a';j<='z';j++){
			int w;
			w=1+dp[last[j]+1];
			if(w<dp[i]){
				dp[i]=w;
				bs[i]=j;
				nx[i]=last[j]+1;
			}
		}
	}
	int p=0;
	while(p<=n){
		printf("%c",bs[p]);
		p=nx[p];
	}
	puts("");

	return 0;
}



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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;

    rep(i, n) {
        if (s[i] != s[k - 1]) s[i] = '*';
    }

    rep(i, n) cout << s[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
 
const int maxn = 2e5 + 5;
const int INF = 998244353;
 
int n, ans = 0;
int dp[maxn][3][3][2];
string s;
map<string, int> vis;
 
inline void dfs(string str){
	if(vis[str])
		return;
	vis[str] = true;
	++ans;
	FOR(i, 0, 2) if(str[i] != str[i + 1]){
		string t = str;
		if(t[i] == 'a' && t[i + 1] == 'b' || t[i + 1] == 'a' && t[i] == 'b')
			t[i] = t[i + 1] = 'c';
		else if(t[i] == 'a' && t[i + 1] == 'c' || t[i + 1] == 'a' && t[i] == 'c')
			t[i] = t[i + 1] = 'b';
		else if(t[i] == 'b' && t[i + 1] == 'c' || t[i + 1] == 'b' && t[i] == 'c')
			t[i] = t[i + 1] = 'a';
		dfs(t);
	}
	return;
}
 
int main(){
	cin >> s;
	n = s.size();
	if(n == 2)
		putchar('1' + (s[0] != s[1]));
	else if(n == 3){
		dfs(s);
		cout << ans << endl;
	}
	else{
		int sum = 0;
		bool f1 = false, f2 = true;
		FOR(i, 0, n){
			if(i != n - 1)
                            f1 |= (s[i] != s[i + 1]), f2 &= (s[i] != s[i + 1]);
			(sum += s[i] - 'a') %= 3;
		}
		if(!f1)
			puts("1");
		else{
			FOR(k, 0, 3)
				dp[0][k][k][0] = 1;
			FOR(i, 0, n - 1) FOR(j, 0, 3) FOR(k, 0, 3) FOR(l, 0, 2) if(dp[i][j][k][l]) FOR(k_, 0, 3)
				(dp[i + 1][(j + k_) % 3][k_][l || (k == k_)] += dp[i][j][k][l]) %= INF;
			FOR(k, 0, 3)
				(ans += dp[n - 1][sum][k][1]) %= INF;
			(ans += f2) %= INF;
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 14596
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define ll long long
using namespace std;
int N;
vector<pair<int,int> > edges[111111];

ll dist_from_root[111111];
void dfs(int par, int u, ll curr_dist) {
    dist_from_root[u]=curr_dist;
    for(int j=0;j<edges[u].size();j++) {
        int v=edges[u][j].first;
        if (v == par)
            continue;
        dfs(u,v,curr_dist+edges[u][j].second);
    }
}

int main() {
    cin>>N;
    for(int i=1;i<=N-1;i++) {
        int u,v,c;
        cin>>u>>v>>c;
        
        edges[u].push_back(make_pair(v,c));
        edges[v].push_back(make_pair(u,c));
    }
    
    
    int Q,K;
    cin>>Q>>K;
    
    dfs(-1,K,0);
    
    for(int q=1;q<=Q;q++) {
        int x,y;
        cin>>x>>y;
        cout << dist_from_root[x]+dist_from_root[y] << endl;
    }
    
}

Measured memory_bytes: 14592
N = int(input())
choices = []
for i in range(N):
  choices.append(list(map(int, input().split())))
dp = [[0, 0, 0] for _ in range(N+1)]
for i, choice in enumerate(choices):
  if i==0:
    dp[0]=choice
    continue
  else:
    for j in range(3):
      dp[i][j] = max(dp[i-1][j-1]+choice[j], dp[i-1][j-2]+choice[j])
print(max(dp[N-1]))

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(c-a+b>=0)cout<<c-a+b<<endl;
  else cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;
int gcd(int x, int y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(x%y,y);
}

int main(){
	int i,n,ans;
	cin >> n;
	for(i=0;i<n;i++){
		int a; cin >> a;
		if(i==0) ans = a;
		else ans = gcd(ans,a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    S = input()
    if S == "AAA" or S == "BBB":
        print("No")
    else:
        print("Yes")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9916
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 


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

    string S;  cin >> S;
    int N = S.size();

    const ll MOD = 1e9 + 7;
    const int M = 13;
    vl dp(M, 0);
    dp[0] = 1;

    int dig = 1;
    for(int i=1; i<=N; i++) {
        vl nxDp(M, 0);

        if (S[N-i]=='?') {
            for (int d = 0; d<=9; d++) {
                for(int j=0; j<M; j++) {
                    nxDp[(j + d*dig) % M] += dp[j];
                    nxDp[(j + d*dig) % M] %= MOD;
                }
            }
        } else {
            int d = S[N-i] - '0';
            for(int j=0; j<M; j++) {
                nxDp[(j + d*dig) % M] += dp[j];
                nxDp[(j + d*dig) % M] %= MOD;
            }
        }

        dig *= 10;
        dig %= M;
        dp = nxDp;
    }

    ll ans = dp[5];
    cout << ans << endl;

    return 0;
}

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

using namespace std;
#define         MAX         1000000
#define         ll          long long
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)

long long int sum;

int main() {

    int n;
    cin>>n;
    sum = 0;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum += __gcd(i,__gcd(j,k));
            }
        }
    }

    cout<<sum<<endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<map>
using namespace std;
long long a[200005],s[200005];
map<long long,long long> mod;
int main()
{
	long long n,k,sum=0;
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
	s[0]=0;a[0]=0;
	for(int i=1;i<=n;i++)
	{
		mod[(s[i-1]-i+1)%k]++;
		if(i>=k)mod[(s[i-k]-(i-k))%k]--;
		sum+=mod[(s[i]-i)%k];
	}
	printf("%lld\n",sum);
}

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

#define MOD 1000000007
#define REP(i,n) for ((i)=0;i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define LL long long
#define ULL unsigned long long

int compare_ll(const void *a, const void *b){
	return *(ULL*)b - *(ULL*)a;
}



int main(void) {
	long g,p,N;
	char c;
	g = 0;
	p = 0;
	N = 0;

	while(1){
		c = getchar();
		if(c == 'g'){
			g++;
		}else if(c == 'p'){
			p++;
		}else{
			break;
		}
		N++;
	}

	printf("%ld\n", (N/2)-p);


	return 0;
}

/* 最後の改行忘れるな！！ */


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

int main (int argc, char* argv[]) {
	ll n;
	cin >> n;
	ll res = 0;
	for (ll i = 1; i < n; i++) {
		res += i;
	}
	cout << res << endl;
}


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

ll dp[51][2501][51];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll n,a;
  cin>>n>>a;
  vector<ll> x(n+1);
  rep(i,n) cin>>x[i+1];
  // rep(i,n) {
  //   cout << "x["<<i+1<<"]="<<x[i+1] << " ";
  // }
  // cout << endl;
  memset(dp,0,sizeof(dp));
  rep(i,n+1) {
    dp[i][0][0] = 1;
  }
  repeat(i,1,n+1) {
     repeat(k,1,i+1){
      repeat(s,1,2501) {
        dp[i][s][k] = dp[i-1][s][k];
        // dp[2][9][1] = 0になってる...
        // dp[2][9][1] = dp[1][9][1]+dp[1][0][0];
        if(s-x[i]>=0) {
          dp[i][s][k]+=dp[i-1][s-x[i]][k-1];
        }
      }
    }
  }
  // rep(i,n+1) {
  //   cout << "i="<<i<<endl;
  //   rep(s,40) {
  //     rep(k,n+1) {
  //       cout << "dp["<<i<<"]["<<s<<"]["<<k<<"]="<<dp[i][s][k]<<endl;
  //     }
  //   }
  // }
  ll ans=0;
  repeat(k,1,n+1) {
    ans+=dp[n][a*k][k];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 51072
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;


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

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

    sort(v, v + N);

    double ans = 0;
    int power = 1;
    for (int i = N - 1; i >= 0; i--) {
        ans += v[i] / pow(2, power);
        if (i >= 2) {
            power++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
const int MX = 200005 ;

int h[MX], k, n;
long long ans;

int main()
{
    scanf("%d%d", &n, &k);
    for(int i=1;i<=n;i++)   scanf("%d", &h[i]);
    sort(h+1, h+n+1);
    for(int i=1;i<=n-k;i++) ans += (long long)h[i];
    cout<<ans<<endl;
}

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

int main(void){
    vector<int> c(3);
    cin>>c[0]>>c[1]>>c[2];
    int ans=1;
    sort(c.begin(),c.end());
    for (int i=1;i<3;i++){
        if (c[i]!=c[i-1]) ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

struct UnionFind {
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N,M; cin >> N >> M;
    UnionFind UF(N);
    REP(i,M) {
        int a,b; cin >> a >> b;
        a--,b--;
        UF.merge(a,b);
    }
    int ans = 0;
    REP(i,N) if(UF.root(i) == i) ans++;
    cout << ans-1 << endl;
}


Measured memory_bytes: 4828
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		if (b.equals("A")){
			System.out.println("T");
		}else if (b.equals("T")){
			System.out.println("A");
		}else if (b.equals("G")){
			System.out.println("C");
		}else {
			System.out.println("G");
		}
	}
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n, m;
	cin >> n >> m;
	
	int left = 1, right = n;
	for(int i = 0; i < m; ++i){
		int l, r;
		cin >> l >> r;
		left = max(left, l);
		right = min(right, r);
	}
	int ans = max(0, right - left + 1);
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  char c;
  cin >> c;
  
  if(c == 'A')
    cout << 'T' << endl;
  if(c == 'T')
    cout << 'A' << endl;
  if(c == 'G')
    cout << 'C' << endl;
  if(c == 'C')
    cout << 'G' << endl;
  
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
xl = [list(map(int, readline().split())) for i in range(n)]
pm = [[0] * 2 for _ in range(n)]
for i in range(n):
    pm[i][0] = xl[i][0] + xl[i][1]
    pm[i][1] = xl[i][0] - xl[i][1]
pm.sort()
ans = 1
check = pm[0][0]
for i in range(1, n):
    if check <= pm[i][1]:
        check = pm[i][0]
        ans += 1
print(ans)


Measured memory_bytes: 41348
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  
  //even,even
  int ans1 = N * (N-1)/2;
  //odd,odd
  int ans2 = M * (M-1)/2;
  
  cout << ans1 + ans2 << endl;
}

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

using namespace std;

const int N = 100010;

int n, a[N];
char s[N], b[N];

int main() {

    scanf("%d %s", &n, s);

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            a[0] = i;
            a[1] = j;
            for (int k = 1; k + 1 < n; k++) {
                if (a[k] == 0 && s[k] == 'o') {
                    a[k + 1] = a[k - 1];
                } else if (a[k] == 0 && s[k] == 'x') {
                    a[k + 1] = 1 - a[k - 1];
                } else if (a[k] == 1 && s[k] == 'o') {
                    a[k + 1] = 1 - a[k - 1];
                } else if (a[k] == 1 && s[k] == 'x') {
                    a[k + 1] = a[k - 1];
                }
            }
            for (int k = 0; k < n; k++) {
                int x = (k - 1 + n) % n;
                int y = (k + 1) % n;
                if (a[k] == 0) {
                    b[k] = (a[x] == a[y]) ? 'o' : 'x';
                } else if (a[k] == 1) {
                    b[k] = (a[x] == a[y]) ? 'x' : 'o';
                }
            }
            bool ok = true;
            for (int k = 0; k < n; k++) {
                ok &= b[k] == s[k];
            }
            if (ok) {
                for (int k = 0; k < n; k++) {
                    printf("%c", a[k] == 0 ? 'S' : 'W');
                }
                exit(0);
            }
        }
    }

    puts("-1");

    return 0;

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
#define F first
#define S second
int INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
double pie = 3.141592653589793238;
//cout << fixed << setprecision(15); (小数点以下表示)

signed main () {
  int N,M,pass=1,siz,re;
  queue<int>next;
  next.push(1);
  cin >> N >> M;
  vec A(M+1),B(M+1),to(N+1,INF);
  mat can(N+1,vec());
  for(int i=1;i<M+1;i++){
    cin >> A.at(i) >> B.at(i);
    can.at(A.at(i)).pb(B.at(i));
    can.at(B.at(i)).pb(A.at(i));
  }
  to.at(1)=0;
  for(int i=0;i<INF;i++){
    re=next.front();
    next.pop();
    for(int j=0;j<can.at(re).size();j++){
      if(to.at(can.at(re).at(j))==INF){
        next.push(can.at(re).at(j));
        to.at(can.at(re).at(j))=re;
        pass++;
      }
    }
    if(pass>=N)break;
  }
  cout << "Yes" << endl;
  for(int i=2;i<=N;i++){
    cout << to.at(i) << endl;
  }
}

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

string rev(string str){
	reverse(str.begin(),str.end());
	return str;
}

int getPattern(string str){
	set<string> s;
	for(int i=0;i<str.size();i++){
		string sub1 = str.substr(0,i);
		string sub2 = str.substr(i,str.size());
		s.insert(rev(sub1)+sub2);
		s.insert(sub1+rev(sub2));
		s.insert(rev(sub2)+sub1);
		s.insert(sub2+rev(sub1));
		s.insert(rev(sub2)+rev(sub1));
		s.insert(rev(sub1)+rev(sub2));		
		s.insert(sub2+sub1);
		// s.insert(sub1+sub2);		
	}
	return s.size();
}

int main(){

	int n;
	cin >>n;
	while(n--){
		string str;
		cin >> str;
		cout<<getPattern(str)<<endl;
	}
	return 0;
}

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

const int INF = 100000000;
int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n){
    cin >> c[i];
    rep(j, m){
      cin >> a[i][j];
    }
  }
  
  int ans = INF;
  rep(i, 1<<n){
    vector<int> skill(m, 0);
    int cost = 0;
    rep(j, n){
      if (i>>j & 1){
        cost += c[j];
        rep(k, m) skill[k] += a[j][k];
      }
    }
    bool flag = true;
    rep(j, m){
      if (skill[j] < x){
        flag = false;
        break;
      }
    }
    if (flag) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

ll h,w,k,mod=1e9+7,dp[10][105],s[10][2];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> h >> w >> k;
    if(w==1){
        cout << 1;
        return 0;
    }
    s[0][0]=1;
    for(int i=1;i<=w;i++){
        s[i][0]=(s[i-1][0]+s[i-1][1])%mod;
        s[i][1]=s[i-1][0];
    }
    dp[1][1]=s[w-1][0];
    dp[2][1]=s[w-1][1];
    for(int i=2;i<=h;i++){
        for(int j=1;j<=w;j++){
            dp[j][i]=(dp[j][i-1]*s[j-1][0]%mod*s[w-j][0]%mod+dp[j-1][i-1]*s[j-1][1]%mod*s[w-j][0]%mod+dp[j+1][i-1]*s[j-1][0]%mod*s[w-j][1]%mod)%mod;
        }
    }
    cout << dp[k][h];
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  vector<int> cnt(4);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++cnt[x];
  }
  int ones = cnt[1];
  int twos = cnt[2];
  int triples = cnt[3];
  
  using real_t = long double;
  vector<vector<vector<real_t>>> dp(n + 1, vector<vector<real_t>>(n + 1, vector<real_t>(n + 1)));
  for (int s = 1; s <= ones + twos + triples; ++s) {
    for (int i = s; i >= 0; --i) {
      for (int j = s - i; j >= 0; --j) {
        int k = s - i - j;
        auto p_zero = (real_t) (n - s) / n;
        auto wait = (real_t) 1 / (1 - p_zero) - 1;
        dp[i][j][k] = wait + 1;
        auto total = i + j + k;
        if (i) {
          dp[i][j][k] += (real_t) i / total * dp[i - 1][j][k];
        }
        if (j) {
          dp[i][j][k] += (real_t) j / total * dp[i + 1][j - 1][k];
        }
        if (k) {
          dp[i][j][k] += (real_t) k / total * dp[i][j + 1][k - 1];
        }
      }
    }
  }
  cout << setprecision(12) << fixed << dp[ones][twos][triples] << '\n';
  return 0;
}


Measured memory_bytes: 431360
# include <iostream>
# include <math.h>
using namespace std;
int main()
{
	int a[3],k,sum;
	while(cin>>a[0]>>a[1]>>a[2])
	{
		for(int i=0;i<2;i++)
		{
			for(int j=i+1;j<3;j++)
			{
				if(a[i]>a[j])
				{
					k=a[i];
					a[i]=a[j];
					a[j]=k;
				}
			}
		}
		sum=fabs(a[1]-a[0])+fabs(a[1]-a[2]);
		cout<<sum<<endl;
	}
	return 0;
}


		


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

const long long INF = 1LL << 60;
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; }

typedef long long ll;
#define vl vector<ll>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<(ll)(n);i++)

int main() {

	int N; cin >> N;
    vl h(N);
    rep(i, N) cin >> h[i];

    vl dp(N, INF);
    dp[0] = 0;
    
    rep1(i,N) {

        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));

    }

    cout << dp[N - 1] << endl;

}

Measured memory_bytes: 1792
s = input()

l = []
for i in range(2**(len(s)-1)):
  pat = ''
  for j in range(len(s)-1):
    pat += s[j]
    if i >> j & 1:
      pat += '+'
  l.append(pat+s[-1])
  
ans = 0
for i in range(len(l)):
  ans += eval(l[i])
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#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 N; cin >> N;
  int t = 0;
  rep(i,N.size()) {
    t += (int)(N[i] - '0');
    t %= 9;
  }
  if (t%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3688
import Control.Monad
import Control.Applicative
import Debug.Trace

main :: IO ()
main = do
  m <- readLn :: IO Int
  replicateM_ m $ do
    (n, (fs, ls)) <- getInput
    let fs' = flatten fs
        ls' = flatten ls
        len = length (filter (== 'Y') (fs' ++ ls'))
--    trace (fs' ++ "," ++ ls') (return ())
    let add1 = if lastY fs' ls'
               then 0
               else 1
    let ans = len + n + add1 +
          if lastY (reverse fs') (reverse ls')
          then 0
          else 1
    print ans

getInput = do
  n <- readLn :: IO Int
  (fs, ls) <- splitAt (2*n) <$> getLine
  return (n, (fs, ls))

flatten :: String -> String
flatten str@(s:ss) = s : go (tail str)
  where
    go [] = []
    go [x] = [x]
    go (x:y:z) = case (x, y) of
                   ('N', 'N') -> 'N' : go z
                   (_, _) -> 'Y' : go z

lastY :: String -> String -> Bool
lastY (x:xs) (y:ys) = case (x, y) of
                        ('Y', _) -> True
                        (_, 'Y') -> False
                        (_, _) -> lastY xs ys

Measured memory_bytes: 6580
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0};
const int INF = 1e9+101;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(ll i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}
void Yes(bool f){
    puts(f?"Yes":"No");
}
bool solve() {
    int N;
    int A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    --A;--B;--C;--D;
    string str;
    cin >> str;
    reps(i,A,max(D,C)){
        if(str[i] == '#' && str[i+1] == '#'){
            return false;
        }
    }
    if (D < C) {
        reps(i,B-1,D) {
            if (str[i] == '.' && str[i+1] == '.' && str[i+2] == '.'){
                return true;
            }
        }
        return false;
    }
    return true;
}
int main() {
   Yes(solve());
   return 0;  
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	int n;
	cin >> n;
	set<int> se;
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		se.insert(c);
	}
	int ans = se.size();
	if (ans == 3) {
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}
	return 0;
}

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

int main() {
  string S;  cin >> S;
  int A = S.at(0) - '0';
  int B = S.at(1) - '0';
  int C = S.at(2) - '0';
  int D = S.at(3) - '0';
  
  if (A + B + C + D == 7)
    printf("%d+%d+%d+%d=7\n", A, B, C, D);
  else if (A + B + C - D == 7)
    printf("%d+%d+%d-%d=7\n", A, B, C, D);
  else if (A + B - C + D == 7)
    printf("%d+%d-%d+%d=7\n", A, B, C, D);
  else if (A + B - C - D == 7)
    printf("%d+%d-%d-%d=7\n", A, B, C, D);
  else if (A - B + C + D == 7)
    printf("%d-%d+%d+%d=7\n", A, B, C, D);
  else if (A - B + C - D == 7)
    printf("%d-%d+%d-%d=7\n", A, B, C, D);
  else if (A - B - C + D == 7)
    printf("%d-%d-%d+%d=7\n", A, B, C, D);
  else if (A - B - C - D == 7)
    printf("%d-%d-%d-%d=7\n", A, B, C, D);
  
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

class TaskB {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int X, Y, Z;
    in >> X >> Y >> Z;
    out << (X - Z) / (Y + Z);
  }
};


int main() {
  TaskB solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      price = i*500+j*100+k*50
      if price == X:
        ans += 1
print(ans)

Measured memory_bytes: 9132
cards = [[False] * 14 for i in range(4)]
n = int(input())
for i in range(n):
    suit, rank = input().split()
    r = int(rank)
    if suit == "S":
        s = 0
    elif suit == "H":
        s = 1
    elif suit == "C":
        s = 2
    else:
        s = 3
    cards[s][r] = True

name = ["S", "H", "C", "D"]
for s in range(4):
    for r in range(1, 14):
        if not cards[s][r]:
            print(name[s], r)

Measured memory_bytes: 7656
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * mod_pow(10, s.size() - i - 1, INF);
	}
	return cnt;
}
/*--------Library Zone!--------*/

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


Measured memory_bytes: 768
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

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

#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp                       __builtin_popcount

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    speed upp
    int n,m,x,y=0;
    cin>>n>>m;
    f(i,1,m)
    {
        cin>>x;
        y+=x;
    }
    if(y>n)
        cout<<"-1";
    else
        cout<<n-y;
}

Measured memory_bytes: 3612
fn main() {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).unwrap();
  let mut iter = s.split_whitespace();
  let A: i32 = iter.next().unwrap().parse().unwrap();
  let P: i32 = iter.next().unwrap().parse().unwrap();
  println!(
    "{}",
    (A*3+P) / 2
  );
}

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

Measured memory_bytes: 1156
if __name__ == '__main__':
	alp = ['a','b','c','d','e','f','g','h','i','j']
	N = int(input())

	lst = [['a',1]]

	for i in range(2,N+1):
		anslst = []
		for j in range(len(lst)):
			s = lst[j][0]
			n = lst[j][1]
			for l in range(n+1):
				ss = s
				if l == n:
					n += 1
				ss = ss + alp[l]
				anslst.append([ss,n])

		lst = anslst

	for i in range(len(lst)):
		print(lst[i][0])

Measured memory_bytes: 25716
x,y= map(int,input().split())
if x==2 or y ==2:
  print('No')
elif x in [4,6,9,11] and y in [4,6,9,11]:
  print('Yes')
elif x not in [4,6,9,11] and y not in [4,6,9,11]:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 2940
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e6+5;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
bool check(string s){
    ll l=0,r=sz(s)-1;
    while(l<=r){
        if(s[l]!=s[r])return false;
        l++;
        r--;
    }
    return true;
}
int main(){

    fio;
    ll n,k;
    cin>>n>>k;
    vi a(n+1),dp(n+1,inf);
    fr(i,1,n)cin>>a[i];
    dp[1]=0;
    fr(i,1,n){
        fr(j,i-k+1,i+k){
            if(j>=1){
                dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
            }
        }
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    }
   if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	System.out.println("No");
   }
}
}


Measured memory_bytes: 46284
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class CPrison {
public:
        int N,M;
void solve(std::istream& cin, std::ostream& cout) {
    cin >> N >> M;
    int L = -1, R = 101010;
    _for(i,M){
        int l,r;
        cin >> l >> r;
        L = max(l, L), R = min(R,r);
    }
    if(L > R)cout << 0 << endl;
    else cout << R - L + 1 << endl;
}
};


#undef int
int main() {
	CPrison solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256