akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
   su;
   int k;
   cin>>k;
   ll x=7%k;
   lo(i,1,3*k+1)
   {
     if(x==0)
     {
       return cout<<i<<nl,0;
     }
     x=(x*10+7)%k;
   }
   cout<<-1<<nl;
   return 0;
}


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

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
signed main(void)
{
	int h, w;
	cin >> h >> w;
	char s[h][w];
	bool ok, flag;

	rep(i, h) rep(j, w) cin >> s[i][j];
	ok = true;
	rep(i, h) 
	{
		rep(j, w)
		{
			if (s[i][j] == '#')
			{
				flag = false;
				rep(k, 4)
				{
					if (i + dy[k] < 0 || i + dy[k] >= h ||\
							j + dx[k] < 0 || j + dx[k] >= w)
						continue;
					if (s[i + dy[k]][j + dx[k]] == '#')
						flag = true;
				}
				if (!flag) ok = false; 
			}
		}
	}
	if (!ok)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  int A[3];
  cin>>A[0]>>A[1]>>A[2];
  int sum=0;
  while(true){
    if(A[0]==A[1]&&A[1]==A[2]){
      break;
    }
    sort(A,A+3);
    if(A[1]-A[0]>=2){
      A[0]+=2;
    }else{
      A[0]++;
      A[1]++;

    }
    sum++;
  }
  cout<<sum<<endl;

  
  
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int x,a,b,c,ans=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	{
		int aa=500*i;
		int bb=100;
		int cc=50;
		for(int j=0;j<=b;j++)
		{
			bb=100*j;
			for(int k=0;k<=c;k++)
			{
				cc=50*k;
				//cout<<"aa=>"<<aa<<endl<<"bb=>"<<bb<<endl<<"cc=>"<<cc<<endl<<"total=> "<<aa+bb+cc<<endl;
				int total=aa+bb+cc;
				if(x==total)
					ans++;
			}
		}
	}
	cout<<ans<<endl;
}

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

int main(){
	char c;
	cin >> c;
	
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
		cout << "vowel" << endl;
	}
	else{
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
using namespace std;
int a[105];
int ss[]={2 ,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int main(int argc, char *argv[])
{
    int n;
    scanf("%d",&n);
    if(n<=9){
        printf("0\n");
        return 0;
    }
    for(int i=1;i<=n;i++){
        int x=i;
        while(x!=1){
            int j;
            for(j=0;j<25&&ss[j]<=x;j++)
                    if(!(x%ss[j])){
                        a[ss[j]]++,x/=ss[j];
                        break;
                    }

        }

    }
    int $2=0,$4=0,$14=0,$24=0,$74=0;
    for(int i=1;i<=100;i++){
        if(a[i]>=2)
            $2++;
        if(a[i]>=4)
            $4++;
        if(a[i]>=14)
            $14++;
        if(a[i]>=24)
            $24++;
        if(a[i]>=74)
            $74++;
    }
    int sssss=0;
    sssss+=$74;
    sssss+=($2-1)*$24;
    sssss+=($4-1)*$14;
    sssss+=($2-2)*$4*($4-1)/2;
    printf("%d\n",sssss);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,n,m;
    scanf("%d %d %d",&a,&b,&c);
    n=(b-a);
    m=(c-b);
    if(n==m)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int r, D, x2000;
  std::cin >> r >> D >> x2000;

  for (int i = 0; i < 10; ++i) {
    x2000 = r * x2000 - D;
    int result = x2000;
    std::cout << result << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::cin >> N;
	std::cout << (N/3) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N,b;
cin>>N;
long long answer=0;
map<long long , long long>L;
for(int i=1;i<=N;i++){
cin>>b;
answer+=L[i-b];
L[i+b]++;}
cout<<answer<<endl;}



Measured memory_bytes: 26152
from math import gcd
n = int(input())
if n == 2:
    a,b = [int(i) for i in input().split()]
    for i in range(1,gcd(a,b)+1):
        if a % i == 0 and b % i == 0:
            print(i)
else:
    a,b,c = [int(i) for i in input().split()]
    g = gcd(gcd(a,b),c)
    for i in range(1,g+1):
        if a % i == 0 and b % i == 0 and c % i == 0:
            print(i)


Measured memory_bytes: 5672
//itp1_topic4_a
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(12);
  int a, b;
  cin>>a>>b;
  cout<< a / b <<" ";
  cout<< a % b <<" ";
  cout<<(double)a / b <<endl;
  return 0;
}


Measured memory_bytes: 3268
// 4/29
// 過去問攻略

#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;

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

    int ans = 0;

    ans += N * (N - 1) / 2;
    ans += M * (M - 1) / 2;

    cout << ans << endl;
}


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

#define llint long long int
#define MOD 2019

using namespace std;

llint mod_pow(llint a, llint n, llint p){
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        llint d = mod_pow(a, n / 2, p);

        return (d * d) % p;
    } else {
        return (a * mod_pow(a, n - 1, p)) % p;
    }
}
int main(){
    string S;

    cin >> S;

    int n = S.length();

    vector<int> mod(n);

    mod[n - 1] = S[n - 1] - '0';

    for(int i = n - 2; i >= 0; i --){
        mod[i] = ((S[i] - '0') * mod_pow(10, n - i - 1, MOD) + mod[i + 1]) % MOD;
    }
    llint ans = 0;
    int count = 0;

    for(int i = 0; i < n; i ++){
        if(mod[i] == 0){
            count ++;
        }
    }
    ans += count * (count + 1) / 2;

    for(int i = 1; i < MOD; i ++){
        count = 0;

        for(int j = 0; j < n; j ++){
            if(mod[j] == i){
                count ++;
            }
        }
        ans += count * (count - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4356
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
	
	int N;
	while (1) {
		cin >> N;
		if (!N)break;
		VI w(N);
		int dp[310][310];
		REP(i, 310)REP(j, 310)dp[i][j] = 0;
		REP(i, N) cin >> w[i];

		eFOR(W, 2, N) {

			REP(i, N) {
				
				
				
				int r = i + W;
				if (r > N)continue;
				if (dp[i + 1][r - 1] == W - 2 && abs(w[i] - w[r - 1]) <= 1)
					dp[i][r] = W;
				
				
				
				
				eFOR(mid, i, r) {
					dp[i][r] = max(dp[i][r], dp[i][mid] + dp[mid][r]);
				}
			}
		}
		/*
		eREP(i, N) {
			eREP(j, N)cout << dp[i][j] << " ";
			cout << endl;
		}
		*/
		cout << dp[0][N] << endl;


	}
	
	return 0;
}




Measured memory_bytes: 3976
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n;
    cin >> n;
    vs32 x(n), y(n);
    rep (i, n) cin >> x[i] >> y[i];

    vs32 v(n);
    rep (i, n) v[i] = i;

    double sum = 0;
    do {
        rep (i, n - 1)
        {
            int s = v[i];
            int t = v[i + 1];
            sum += sqrt((double)(x[t] - x[s]) * (x[t] - x[s]) + (double)(y[t] - y[s]) * (y[t] - y[s]));
        }
    } while (next_permutation(v.begin(), v.end()));

    double div = 1.0;
    rep (i, n) div *= (double)(i + 1);
    sum /= div;

    cout << setprecision(10) << sum << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n;
double p, dp[2][3004];

int main() {
	cin>>n;
	dp[0][0] = 1.0;
	for(int i = 1;i<=n;i++){
		cin>>p;
		for(int j = 0;j<=i;j++)
			dp[i%2][j] = dp[(i-1)%2][j]*(1-p)+dp[(i-1)%2][j-1]*p;
	}
	double ans = 0;
	for(int i = (n+1)/2;i<=n;i++)
		ans += dp[n%2][i];
	printf("%.10f",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n, m;
    cin >> n >> m;

    vector<int> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    set<int> c;
    rep(i, n){
        if(c.find(a[i]) != c.end()){
            cout << 0 << endl;
            return 0;
        }
        c.insert(a[i]);
    }
    c = set<int>();
    rep(i, m){
        if(c.find(b[i]) != c.end()){
            cout << 0 << endl;
            return 0;
        }
        c.insert(b[i]);
    }

    vector<int> s(n * m + 1);
    vector<bool> t(n * m + 1, false), u(n * m + 1, false);
    rep(i, n){
        rep(j, m){
            int x = min(a[i], b[j]);
            s[x]++;
            u[x] = true;
            if(a[i] == b[j]){
                t[x] = true;
            }
        }
    }

    if(s[n*m] == 0){
        cout << 0 << endl;
        return 0;
    }

    sort(ALL(a), greater<int>());
    sort(ALL(b), greater<int>());
    int tar = n * m;
    rep(i, n){
        rep(j, m){
            if(a[i] == b[j]){
                tar = min(tar, a[i] - 1);
                while(tar > 1 && u[tar]){
                    tar--;
                }
                s[tar] += s[a[i]] - 1;
                s[a[i]] = 1;
            }
        }
    }

    int sum = 0;
    int ans = 1;
    for(int i = 1; i <= n * m; i++){
        if(sum + s[i] > i){
            cout << 0 << endl;
            return 0;
        }
        if(not t[i]){
            int tmp = 1;
            int x = i - sum;
            rep(j, s[i]){
                tmp *= x;
                tmp %= MOD;
                x--;
            }
            if(u[i]){
                int x = i - sum - 1;
                int tmp2 = 1;
                rep(j, s[i]){
                    tmp2 *= x;
                    tmp2 %= MOD;
                    x--;
                }
                tmp = (tmp + MOD - tmp2) % MOD;
            }
            ans *= tmp;
            ans %= MOD;
        }
        sum += s[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8320
#include<iostream>

using namespace std;

int N;
int ans = 0;

void dfs(long long n, int x, int y, int z){
    if (n > N){
        return;
    }
    if (x == 1 && y == 1 && z == 1){
        ans++;
    }
    dfs(10 * n + 3, 1, y, z);
    dfs(10 * n + 5, x, 1, z);
    dfs(10 * n + 7, x, y, 1);
    return;
}

int main(){
    cin >> N;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s, t;
  cin >> s >> t;

  llong ans = 0;
  REP(i,s.length()){
    if(s[i] != t[i]) ans++;
  }

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



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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<string> v = {"dream", "erase", "dreamer", "eraser"};
    rep(i, v.size()){
        reverse(v[i].begin(), v[i].end());
    }
    int j = 0;
    while(j < s.size()){
        bool flag = false;
        rep(i, v.size()){
            int k = v[i].size();
            if(s.substr(j, k) == v[i]){
                j += k;
                flag = true;
                break;
            }
        }
        if(!flag){
            break;
        }
    }
    if(j < s.size()){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
main :: IO ()
main = do
  [n,a,b] <- map read . words <$> getLine 
  print $ f n a b

f :: Int -> Int -> Int -> Int
f n a b = sum [ m | m <- [1..n]
                  , a   <= g m
                  , g m <= b ]
  where
    g = sum . int2lst

int2lst
  :: Int -> [Int]
int2lst n
  | q == 0 = [r]
  | otherwise = r: int2lst q
  where
--    (q,r) = quotRem n 10
    (q,r) = divMod n 10


Measured memory_bytes: 892
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		ArrayList<String> array = new ArrayList<String>();
		for(int i = 0;i<N;i++){
			String str = scanner.next();
			array.add(str);
			//System.out.println(str);
		}
		if(array.contains("Y")){
			System.out.println("Four");
		}else{
			System.out.println("Three");
		}
		//int B = scanner.nextInt();
		//String S = scanner.nextLine();
		scanner.close();
	}
}


Measured memory_bytes: 21844
N, K = map(int, input().split())
ab=[]
for _ in range(N):
    ab.append(tuple(map(int, input().split())))
ab=sorted(ab, key=lambda x:x[0])
#print(ab)
accum=[0]
for i in range(len(ab)):
    accum.append(accum[i]+ab[i][1])
#print(accum)
for i in range(len(ab)):
    #print(accum[i], accum[i+1])
    if accum[i] < K <= accum[i+1]:
        print(ab[i][0])
        break

Measured memory_bytes: 68184
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    vi as(4);
    for (int i = 0; i < 4; i++) {
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    vi bs = {1, 4, 7, 9};
    for (int i = 0; i < 4; i++) {
        if (as[i] != bs[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<iostream>
int main(){
  int n,q,count=0;

  std::cin>>n;
  int S[n];
  for(int i=0;i<n;i++){
    std::cin>>S[i];
  }

  std::cin>>q;
  int T[q];
  for(int i=0;i<q;i++){
    std::cin>>T[i];
  }

  for(int k=0;k<q;k++){
    for(int i=0;i<n;i++){
      if(T[k]==S[i]){
	count++;
	break;
      }
    }
  }
  std::cout<<count<<"\n";
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef vector<ll> vll;

#define fin(ans) cout << (ans) << endl;

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

void Main()
{
  ll n; cin >> n;
  vll p(n); V(p);
  ll flag = 0;
  for(ll i = 2;i < n;i++)
  {
    vll b(3);
    b[0] = p[i - 2];
    b[1] = p[i - 1];
    b[2] = p[i];
    Sort(b);
    if(b[1] == p[i - 1]) flag++;
  }
  fin(flag);
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for_each(a.begin(), a.end(),[](auto&e){
    cin>>e;
  });
  vector<bool> score;
  for (int i = 0; i < n; ++i)
  {
    if(i+k>=n) break;
    if(a[i]<a[i+k]) score.push_back(true);
    else score.push_back(false);
  }
  for (int i = 0; i < score.size(); ++i)
  {
    if(score[i]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4980
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int A = cin.nextInt();
        int B = cin.nextInt();

        WriteLine((A % 2 == 1 && B % 2 == 1) ? "Yes" : "No");
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long n = scn.nextLong();
		fun(n);
	}
	public static void fun(long n) {
		if(n<27) {
			System.out.print((char)(n+96));
			return;
		}else if(n<703) {
			if(n%26!=0) {
			System.out.print((char)(n/26 + 96));
			System.out.print((char)(n%26 + 96));}
			else {
				System.out.print((char)(n/26 + 95));
				System.out.print((char)(26 + 96));
				return;
			}
		}else {
			if(n%26!=0) {
			fun(n/26);
			System.out.print((char)(n%26 + 96));}
			else {
				fun(n/26 - 1);
				System.out.print((char)(26 + 96));}
			return;
		}
	}
}	

Measured memory_bytes: 27052
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		double ansDiff = 1000000;
		int ansNum = 0;
		for(int i = 0; i < n; i++) {
			double diff = Math.abs(t - h[i] * 0.006 - a);
			if(diff < ansDiff) {
				ansDiff = diff;
				ansNum = i +1;
			}
		}
		System.out.println(ansNum);
	}
}

Measured memory_bytes: 24148
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=1000001;

ll power(ll x,ll n)
{
    if(n==0){return 1;}
    if(n==1){return x%M;}
    if(n%2==0){
        return power((x*x)%M,n/2);
    }
    else{
        return (x*power((x*x)%M,n/2))%M;
    }
}

int dp[N][2][2];

ll func(ll n,ll a,ll b)
{
    if(n==0){
        if(a==1&&b==1){return 1;}
        return 0;
    }
    if(dp[n][a][b]==-1){
    ll ans=((8*func(n-1,a,b))%M + func(n-1,1,b)%M + func(n-1,a,1)%M)%M;
    dp[n][a][b]=ans;
    }
    return dp[n][a][b];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    cout<<func(n,0,0);
    

    return (0);
}


Measured memory_bytes: 97212
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll N;
    cin>>N;
    for(ll a = 1;a<=3500;a++){
        for(ll b = 1;b<=3500;b++){
            if(4*a*b-N*(a+b) <= 0) continue;
            if((N*a*b)%(4*a*b-N*(a+b)) == 0 ) {
                ll c = (ll)(N*a*b)/((ll)(4*a*b)-(ll)(N*(a+b)));
                if(c>0){
                    cout<<a<<" "<<b<<" "<<c<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

vector<long long> enum_divisors(long long N) {
  vector<long long> res;
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      // 重複しないならば i の相方である N/i も push
      if (N / i != i) res.push_back(N / i);
    }
  }
  // 小さい順に並び替える
  sort(res.begin(), res.end());
  return res;
}

void solve(ll N, std::vector<ll> A) {
  vector<ll> d0 = enum_divisors(A.at(0));
  vector<ll> d1 = enum_divisors(A.at(1));
  // copy(d1.begin(), d1.end(), back_inserter(d0));

  map<ll, int> mp;
  for (auto v : d0) {
    if (mp.count(v))
      mp.at(v)++;
    else
      mp.insert({v, 1});
  }
  for (auto v : d1) {
    if (mp.count(v))
      mp.at(v)++;
    else
      mp.insert({v, 1});
  }

  for (ll i = 2; i < N; i++) {
    for (auto v : mp) {
      if (v.second > 0 && A.at(i) % v.first != 0) {
        mp.at(v.first)--;
      }
    }
  }

  ll ans = 0;
  for (auto v : mp) {
    if (v.second > 0) {
      ans = max(ans, v.first);
    }
  }

  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 4064
def insert(r, n):
    if 0 == len(T):
        T[n] = [None, None]
    else:
        if n < r:
            left = T[r][0]
            if left == None:
                T[r][0] = n
                T[n] = [None, None]
            else:
                insert(left, n)
        if r < n:
            right = T[r][1]
            if right == None:
                T[r][1] = n
                T[n] = [None, None]
            else:
                insert(right, n)

def find(n):
        if n in T:
            return True
        else:
            return False

def print_inorder(r):
    left = T[r][0]
    right = T[r][1]
    ans = ""
    if left != None:
        ans += print_inorder(left)
    ans += " {}".format(r)
    if right != None:
        ans += print_inorder(right)
    return ans

def print_preorder(r):
    left = T[r][0]
    right = T[r][1]
    ans = " {}".format(r)
    if left != None:
        ans += print_preorder(left)
    if right != None:
        ans += print_preorder(right)
    return ans

n = int(input())
T = {}

root = None
for i in range(n):
    inst = input()
    if inst[0] == 'i':
        num = int(inst[7:])
        if i == 0:
            root = num
        insert(root, num)
    elif inst[0] == 'f':
        num = int(inst[5:])
        if find(num):
            print("yes")
        else:
            print("no")
    elif inst[0] == 'p':
        print(print_inorder(root))
        print(print_preorder(root))

Measured memory_bytes: 95240
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let p: Vec<f64> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect::<_>();
    
    let ans = ((p[0] - p[2]).powi(2) + (p[1] - p[3]).powi(2)).sqrt();

    println!("{}", ans);
}
    



Measured memory_bytes: 5060
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
const int N = 1e5+7,MOD = 1e9+7;
typedef long long ll;

int phi[N],primes[N],cnt;
bool st[N];
int qpow(int a,int b)
{
    int res = 1 % MOD;
    while(b)
    {
        if(b & 1)   res = ((ll)res * a) % MOD;
        a = (ll)a * a % MOD;
        b >>= 1;
    }
    return res;
}
void init(int N)
{
    phi[1] = 1;
    for(int i = 2;i <= N;++i)
    {
        if(!st[i])  primes[cnt++] = i,phi[i] = i - 1;
        for(int j = 0;j < cnt && primes[j] * i <= N;++j)
        {
            st[primes[j] * i] = 1;
            if(i % primes[j] == 0)
            {
                phi[i * primes[j]] = primes[j] * phi[i];
                break;
            }
            phi[i * primes[j]] = (primes[j] - 1) * phi[i];
        }
    }
}
void add(int &x,int y) 
{
    x+=y;
    if(x>=MOD) x-=MOD;
}
signed main()
{
    init(N - 1);
    int n,k;scanf("%d%d",&n,&k);
    int res = 0;
    for(int i = 1;i <= k;++i)
        add(res,1LL*qpow(k/i,n)*phi[i]%MOD);
    printf("%d",res);
    return 0;
}


Measured memory_bytes: 3740
#include <stdio.h>

int main(void)
{
    int n=0,m=0,ans=0;
    scanf("%d %d",&n,&m);
    if(n>=2) ans+=n*(n-1)/2;
    if(m>=2) ans+=m*(m-1)/2;

    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1696
n=int(input())
a=list(map(int,input().split()))

mod=10**9+7
import numpy as np

cum=[]

prev=0
for i in range(n):
    tmp = prev%mod +a[i]%mod
    cum.append(tmp)
    prev = cum[-1]


ans=0
for i in range(n-1):
    p=a[i]
    t = cum[-1] - cum[i]

    ans+=(p*t)%mod

print(ans%mod)

Measured memory_bytes: 42456
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    vector<ll> x(100);
    ll r, d;
    cin >> r >> d >> x[0];
    for (ll i = 1; i < 11; ++i) {
        x[i] = r * x[i-1] - d;
        cout << x[i] << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	long long int amin = INT_MAX, amax = INT_MIN, sum = 0;
	for (int i = 0;i < n; i++)
	{
		long long int a;
		cin >> a;
		amin = min(amin, a);
		amax = max(amax, a);
		sum += a;
	}
	cout << amin << " " << amax << " " << sum << endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}


//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int N;
	int ans = 0;
	int sum = 0;
	bool flg = false;

	cin >> N;
	vector<int> S;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		sum += tmp;
		if (tmp % 10) {
			flg = true;
			S.push_back(tmp);
		}
	}

	if (flg) {
		sort(S.begin(), S.end());
		if (sum % 10) {
			cout << sum << endl;
		}
		else {
			cout << sum - S[0] << endl;
		}
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

int n, x, m;
int[] l, r, s;
int maximum = -1;
void main() {
    int[] input = readln.split.to!(int[]);
    n = input[0];
    x = input[1];
    m = input[2];
    l = new int[m];
    r = new int[m];
    s = new int[m];
    foreach(i; 0..m) {
        input = readln.split.to!(int[]);
        l[i] = input[0]-1;
        r[i] = input[1]-1;
        s[i] = input[2];
    }

    int[] ans = rec(0, new int[n]);
    if (ans.empty) {
        writeln(-1);
    } else {
        ans.to!string.split(",").reduce!"a~b"[1..$-1].writeln;
    }
}
int[] rec(int depth, int[] ary) {
    if (depth == n) {
        int sum = ary.sum;
        if (sum <= maximum) {
            return [];
        } else {
            foreach(i; 0..m) {
                if (ary[l[i]..r[i]+1].sum != s[i]) return [];
            }
            maximum = sum;
            return ary;
        }
    } else {
        int[] result = [];
        foreach(i; 0..x+1) {
            int[] _ary = ary.dup;
            _ary[depth] = i;
            int[] temp = rec(depth+1, _ary);
            if (!temp.empty) result = temp;
        }
        return result;
    }
}

Measured memory_bytes: 3224
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[A[i]-B[i] for i in range(N)]
#print(C)

C.sort()
tmp=0
cnt=0
for i in C:
  if i>=0:
    break
  tmp+=i
  cnt+=1
#print(tmp)

C.sort(reverse=True)
for i in C:
  if tmp>=0 or i<=0:
    break
  tmp+=i
  cnt+=1

print(cnt if tmp>=0 else -1)

Measured memory_bytes: 18524
#include <bits/stdc++.h>
typedef   long long int ll;
using namespace std;
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p  
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
// Returns nCr % p using Fermat's little 
// theorem. 

int main ()
{
     ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ll n,a,b,k,p=1000000007,sum=0;cin>>n>>a>>b;
     k=power(2,n,p);
     k=k-1;
    // cout<<k<<endl;
       ll o,pro=1,pro1=1,u1=0,u2=0;
    ll fac[1000005]; 
    fac[0]=1;
    for (ll i=1 ; i<=1000004; i++) { 
        fac[i] = (fac[i-1]*i)%p;
        //fac.push_back(o);
    }
  //  cout<<fac[141421]<<endl;
  if (n>=a) {
     for (ll i=n-a+1;i<=n;i++) {
         pro*=i;
         pro=pro%p;
     }
      u1=power(fac[a],p-2,p);
      u1=u1*pro;
      u1=u1%p;
  }
  
     //cout<<pro<<endl;
     if (n>=b) {
      for (ll i=n-b+1;i<=n;i++) {
         pro1*=i;
         pro1=pro1%p;
     }
      u2=power(fac[b],p-2,p);
      u2=u2*pro1;
      u2=u2%p;
     }
     //cout<<k<<sum<<endl;
    // cout<<u1<<" "<<u2<<endl;
    sum=u1+u2;
    sum=sum%p;
     if (k-sum<0) cout<<(k-sum)+p<<endl;
     else {
     cout<<k-sum<<endl;
     }
}





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

int main(){
  int a,b,c;
  int m,n,o;
  cin>>a>>b>>c;

  m=max(a,max(b,c));
  n=min(a,min(b,c));
  o=a+b+c-m-n;
  cout<<n<<" "<<o<<" "<<m<<endl;

  return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,h;

    priority_queue<int> a,b;

    Scd2(n,h);

    int x,y;

    Rep(i,n){
        Scd2(x,y);
        a.push(x);
        b.push(y);
    }

    int ans = 0;


    while( !b.empty() ){
        if( a.top() <= b.top() ){
            h -= b.top();
            b.pop();
            ans++;
            if( h <= 0 ){
                printf ("%d\n", ans);
                return 0;
            }
        }
        else{
            break;
        }
    }

    ans += (h + a.top() - 1) / a.top();

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

    return 0;
}



Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  vector<ll> B(N,0);
  ll cnt=1;
  ll now=0;
  ll roop=0;
  REP(i,N+1){
    if(B.at(now)==0){
      B.at(now)=cnt;
      now=A.at(now)-1;
      cnt++;
    }else{
      roop = cnt-B.at(now);
      break;
    }
  }

  if(K<B.at(now)-1){
    REP(i,N){
      if(K==B.at(i)-1){
        cout << i+1 << endl;
      }
    }
  }else{
    REP(i,N){
      if((K-(B.at(now)-1))%roop+B.at(now)==B.at(i)){
        cout << i+1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 6396
#include <iostream>

using namespace std;
int main(){
	string a,b,c;
	int i,n,cnt = 0;
	cin >> n >> a >> b >> c;
	for(i=0;i<n;i++){
		if(a[i]==b[i] && a[i]==c[i]) cnt += 0;
		else if(a[i]!=b[i] && b[i]!=c[i] && a[i]!=c[i]) cnt += 2;
		else cnt ++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <valarray>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
const double PI = 3.1415926535;

double rad(double d) {
  return d*PI/180;
}

typedef double number;
typedef valarray<number> point;

point coord(double R, double lon, double lat) {
  point res(3);
  res[0] = R*cos(lon)*sin(lat);
  res[1] = R*sin(lon)*sin(lat);
  res[2] = R*cos(lat);
  return res;
}
number dot(const point& a, const point& b) {
  return (a * b).sum();
}
point cross(const point& a, const point& b) {
  return a.cshift(+1)*b.cshift(-1)
       - a.cshift(-1)*b.cshift(+1);
}
// ツベツクツトツδ仰づ慊づュツづィツづ個嘉アツ転
point rotate(point axis, double ang, point a) {
  return a * cos(ang) + (1.0 - cos(ang)) * dot(a, axis) * axis + cross(axis, a) * sin(ang);
}

bool judge(double a, double h, double ang) {
  return (rotate(coord(1, 0, rad(46.8)), -ang, coord(10,-a,h))[2] >= 0);
}

int main() {
  int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  int T;
  cin >> T;
  while(T--) {
    int mon,day,hh,mm;
    scanf("%d/%d %d:%d",&mon,&day,&hh,&mm);
    int min = 0;
    REP(i, mon-1)
      min += month[i] * 24 * 60;
    min += (day-1) * 24 * 60 + hh * 60 + mm;
    double ang = rad((1.0+1.0/365.24) * 360 * min / (24 * 60));
//    cout << min << " " << ang << endl;
    //ang = mod(ang, (2*PI));
    int n;
    cin >> n;
    REP(i,n) {
      string name;
      cin >> name;
      int m;
      cin >> m;
      bool f = 1;
      REP(j,m) {
        double a,b;
        cin >> a >> b;
        b = 90.0 - b;
        if (!judge(rad(a), rad(b), ang)) {
          f = 0;
        }
      }
      if (f)
        cout << name <<endl;
    }
  }
}

Measured memory_bytes: 1008
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  ll K, A, B;
  cin >> K >> A >> B;
  if (A + 2 >= B) cout << (K + 1) << endl;
  else {
    cout << (A + (K - A + 1)/2 * (B - A) + (K - A + 1) % 2) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

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

    ll L[87];
    L[0] = 2;
    L[1] = 1;

    for (int i = 2; i <= N; i++) {
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[N] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int dp[n+1];
    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);
    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]),dp[i-2] + abs(a[i] - a[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#define endl ("\n")
#define pi (3.141592653589)

#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) cc.begin(), c.end()
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
// long long moduloMultiplication(long long a, 
//                             long long b, 
//                             long long mod) 
// { 
//     long long res = 0; // Initialize result 
  
//     // Update a if it is more than 
//     // or equal to mod 
//     a %= mod; 
  
//     while (b) 
//     { 
//         // If b is odd, add a with result 
//         if (b & 1) 
//             res = (res + a) % mod; 
  
//         // Here we assume that doing 2*a 
//         // doesn't cause overflow 
//         a = (2 * a) % mod; 
  
//         b >>= 1; // b = b / 2 
//     } 
  
//     return res; 
// } 


int32_t main(){
    fast
    string s,t;
    cin>>s>>t;
    int x=100000;
    
    for(int i=0;i<=s.size()-t.size();i++)
    {
        int diff=0;

        for(int j=0;j<t.size();j++)
        {
            if(t[j]!=s[i+j])
            diff++;
        }
        x=min(x,diff);  
    }
    cout<<x<<endl;
    return 0;
}
    


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll x; cin >> x;

    for (ll i = -1000; i <= 1000; ++i) {
        for (ll j = -1000; j <= 1000; ++j) {
            ll a = i * i * i * i * i;
            ll b = j * j * j * j * j;

            if (a - b == x) {
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3628
#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);
    }
    int x = N / 2;
    int y = x + 1;
    sort(d.begin(), d.end());
    cout << d.at(y - 1) - d.at(x - 1) << endl;
}


Measured memory_bytes: 640
def main():
  p = 2019
  L, R = list(map(int, input().split()))
  
  if (R - L) >= p:
    ans = 0
    print(ans)
    
  else:
    L, R = L % p, R % p
    ans = 2019 ** 2
    for i in range(L, R + 1):
      for j in range(i+1, R+1):
        tmp = (i * j) % p
        if tmp < ans:
          ans = tmp
    print(ans)
    
main()


Measured memory_bytes: 40048