akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,n,sum=0;
    cin >> n;
    vector<long long>a(n+1);
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    for(i=1; i<n; i++){
        if(a[i]<a[i-1]){
            sum += a[i-1]-a[i];
            a[i]+=a[i-1]-a[i];
        }
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 4784
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]
judge = False
target = [-1 for i in range(N)]
for i in range(M):
    if sc[i][1] + target[sc[i][0]-1] == sc[i][1]-1 or sc[i][1] + target[sc[i][0]-1] == 2*sc[i][1]:
        target[sc[i][0]-1] = sc[i][1]
    else:
        print(-1)
        judge = True
        break

if judge is False:
    for i in range(N):
        if len(target) == 1:
            if target[0] == -1:
                target[0] = 0
        else:
            if i == 0 and target[i] == -1:
                target[i] = 1
            elif target[i] == -1:
                target[i] = 0

    res = 0
    for i in range(N):
        res = res+target[i]*(10**(N-i-1))
    if len(str(res)) != N:
        print(-1)
    else:
        print(res)


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

int main()
{
	string s;
	cin >> s;
	int cou = 0;

	for (int i = 0; i < 3; i++) {
		if (s[i] == 'A') {
			cou++;
		}
	}

	if (cou == 3 || cou == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


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

/*
 b
lurd
 f
*/
struct Dice {
  long long l, r, f, b, d, u, x, y;
  Dice(long long _l = 4, long long _r = 3, long long _f = 2,
       long long _b = 5, long long _d = 6, long long _u = 1,
       long long _x = 0, long long _y = 0)
      : l(_l), r(_r), f(_f), b(_b), d(_d), u(_u), x(_x),
        y(_y) {}

  void RollN() {
    long long buff = d;
    d = b;
    b = u;
    u = f;
    f = buff;
    ++y;
  }

  void RollS() {
    long long buff = d;
    d = f;
    f = u;
    u = b;
    b = buff;
    --y;
  }

  void RollE() {
    long long buff = d;
    d = r;
    r = u;
    u = l;
    l = buff;
    ++x;
  }

  void RollW() {
    long long buff = d;
    d = l;
    l = u;
    u = r;
    r = buff;
    --x;
  }

  void RollL() {
    long long buff = f;
    f = l;
    l = b;
    b = r;
    r = buff;
  }

  void RollR() {
    long long buff = f;
    f = r;
    r = b;
    b = l;
    l = buff;
  }

  vector<Dice> makeDice() {
    vector<Dice> ret;
    for(int i = 0; i < 6; i++) {
      Dice d(*this);
      if(i == 1) d.RollN();
      if(i == 2) d.RollS();
      if(i == 3) d.RollS(), d.RollS();
      if(i == 4) d.RollE();
      if(i == 5) d.RollW();
      for(int j = 0; j < 4; j++) {
        ret.emplace_back(d);
        d.RollL();
      }
    }
    return (ret);
  }

  bool operator==(const Dice &di) const {
    return l == di.l && r == di.r && f == di.f &&
           b == di.b && d == di.d && u == di.u;
  }
};
long long a, b, c, d, e, f;
vector<vector<Dice>> v;

int main() {
  for(int i = 0; i < 2; ++i) {
    cin >> a >> b >> c >> d >> e >> f;
    v.emplace_back(Dice(d, c, b, e, f, a).makeDice());
  }
  for(int i = 0; i < 24; ++i)
    for(int j = 0; j < 24; ++j)
      if(v[0][i] == v[1][j]) {
        cout << "Yes" << endl;
        return 0;
      }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			if (a == -1 && b == -1 && c == -1)
				break;
			if (a == -1 || b == -1)
				System.out.println("F");
			else if (a + b >= 80)
				System.out.println("A");
			else if (a + b >= 65)
				System.out.println("B");
			else if (a + b >= 50)
				System.out.println("C");
			else if (a + b >= 30)
				if (c >= 50)
					System.out.println("C");
				else
					System.out.println("D");
			else
				System.out.println("F");
		}

	}
}

Measured memory_bytes: 19100
#include<iostream>
using namespace std;
int main()
{
  double N;
  double a;
  double b;
  cin >> N;
  for(int i=1;i<=N;i++){
    if(i%2==1){
      a++;
    }
  }
  b=a/N;
  cout << b;
  return 0;
}

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

int main(void)
{
    int a, b;
    cin >> a >> b;
    int kosu = a;
    int i = 1;
    if(b==1)
    {
        cout << 0 << endl;
        return 0;
    }
    while (kosu < b)
    {
        kosu += a - 1;
        i++;
    }
    cout << i << endl;
    return 0;
}

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


def main():
    A, B = map(int, input().split())
    result = 0
    for i in range(A, B + 1):
        i = str(i)
        if i[::] == i[::-1]:
            result += 1
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int X,N;
    cin >> X >> N;
    vector<int> p(N);
    map<int,int> pm;
    for (int i = 0; i < N; i++)
    {
        cin >> p.at(i);
        pm.insert(make_pair(p.at(i),i));
    }
    int i = 0;
    int po = -1;
    while (po == -1)
    {
        if(pm.find(X-i) == pm.end())
        {
            po = X-i;
        }else if(pm.find(X+i) == pm.end()){
            po = X+i;
        }
        i++;
    }
    cout << po;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String S  = keyboard.next();
		
		String ans = "No";
		int a = 0;
		int b = 0;
		
		for(int i=0;i<3; i++) {
			if(S.charAt(i) == 'A') {
				a++;
			}else {
				b++;
			}
		}
		
		if(a != 0 && b != 0 ) {
			ans = "Yes";
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 35704
import math
import bisect
A,B,Q = list(map(int,input().split(" ")))
Ss = [int(input())for _ in range(A)]
Ts = [int(input())for _ in range(B)]
Xs = [int(input())for _ in range(Q)]
Ss.sort()
Ts.sort()
ss = len(Ss)
ts = len(Ts)
for x in Xs:
    si = bisect.bisect_right(Ss,x)
    ti = bisect.bisect_right(Ts,x)

    cands = [[],[]]
    if si > 0:
        cands[0].append(Ss[si-1])
    if si < ss:
        cands[0].append(Ss[si])
    if ti > 0:
        cands[1].append(Ts[ti-1])
    if ti < ts:
        cands[1].append(Ts[ti])
 
    anss = []
    temp = 0
    for i in [0,1]:
        for t1 in cands[i]: #最初による所
            for t2 in cands[1-i]: #次に寄る所
                temp = abs(x-t1) +  abs(t2-t1)
                anss.append(temp)
    print(min(anss))

Measured memory_bytes: 16168
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>

using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mod 998244353
# define pi acos(-1)
# define fi first
# define se second
int add(int a, int b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

int mul(ll a, int b) {
	a *= b;
	return a % mod;
}
signed main()
{
    gok
  int n;
  cin>>n;
  map<string,int> mp;
  int an=0;
  while(n--)
  {
      string s;
      cin>>s;
      if(mp[s]==0)
      {
          mp[s]=1;
          an++;
      }
      mp[s]=1;
  }

  cout<<an;
















    return 0;
    }


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

int main(){
    int n; cin >> n;
    int ans = 0;
    if(n%2 == 0){
        ans = n/2 - 1;
    }else{
        ans = n/2;
    }
    cout << ans << endl;
    
    

}


Measured memory_bytes: 256
h,w,k = map(int,input().split())
mod = 10**9+7

if w == 1:
    print(1)
    exit()

dp = [[0]*w for i in range(h+1)]
dp[0][0] = 1

l = [[0]*3 for i in range(w)]

for i in range(2**(w-1)):
    if "11" in bin(i):
        continue

    for j in range(w-1):
        if (i >> j) & 1:        
            l[j][2] += 1
            l[j+1][0] += 1

fib = [1,1]
for i in range(10):
    fib.append(fib[-1]+fib[-2])
for i in l:
    i[1] = fib[w] - sum(i)

for i in range(h):
    for j in range(w):
        dp[i+1][j] += dp[i][j]*l[j][1]%mod
        if j != 0:
            dp[i+1][j] += dp[i][j-1]*l[j][0]%mod
        if j != w-1:
            dp[i+1][j] += dp[i][j+1]*l[j][2]%mod
        dp[i+1][j] %= mod

print(dp[-1][k-1]%mod)

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

int main()
{
	string s;
	cin >> s;
	if (s.at(2) == s.at(3) && s.at(4) == s.at(5))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main(void){
  int n;cin>>n;
  vector<pair<int,int>>vp;
  for(int i=1;i<=n;i++){
    int a;cin>>a;
    vp.push_back(make_pair(a,i));
  }
  SORT(vp);
  rep(i,vp.size()){
    cout<<vp[i].second<<endl;
  }
  return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    string segments[11] = {
        "0111111",
        "0000110",
        "1011011",
        "1001111",
        "1100110",
        "1101101",
        "1111101",
        "0100111",
        "1111111",
        "1101111",
        "0000000"};
    while(cin >> n, n!=-1){
        int before = 10;
        rep(i, n){
            int m;
            cin >> m;
            rep(i, segments[m].size()){
                if(segments[before][i] == segments[m][i]) cout << 0;
                else cout << 1;
            }
            cout << endl;
            before = m;
        }
    }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

    ll h, w;cin >> h >> w;
    vector<P> v;
    REP(i, h){
        REP(j, w){
            char c;
            cin >> c;
            if(c == 'B'){
                v.EB(i, j);
            }
        }
    }

    ll ans = 0;
    REP(i, v.size()){
        REP(j, i){
            ans = max(ans, abs(v[i].FI - v[j].FI) + abs(v[i].SE - v[j].SE));
        }
    }

    cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1001001001;
const int di[]={-1,0,1,0};
const int dj[]={0,-1,0,1};

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int h,w;cin>>h>>w;
  vector<string> s(h);
  rep(i,h){
    cin>>s[i];
  }
  int ans=0;
  rep(si,h){
    rep(sj,w){
      if(s[si][sj]=='#'){
        continue;
      }
      vector<vector<int>> dist(h,vector<int>(w,INF));
      queue<P> q;
      auto update=[&](int i,int j,int x){
        if(dist[i][j]!=INF){
          return;
        }
        dist[i][j]=x;
        q.push(P(i,j));
      };
      update(si,sj,0);
      while(!q.empty()){
        int i=q.front().first;
        int j=q.front().second; q.pop();
        rep(dir,4){
          int ni=i+di[dir],nj=j+dj[dir];
          if(ni<0||ni>=h||nj<0||nj>=w){
            continue;
          }
          if(s[ni][nj]=='#'){
            continue;
          }
          update(ni,nj,dist[i][j]+1);
        }
      }
      rep(i,h){
        rep(j,w){
          if(dist[i][j]==INF){
            continue;
          }
          ans=max(ans,dist[i][j]);
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i <= b; i++)

#include <iostream>

using namespace std;

int main()
{
    int a, b, h; cin >> a >> b >> h;

    cout << ((a+b)*h)*0.5 << endl;
}

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

int main() {
  string N;
  cin >> N;
  
  for(int i=0; i<3; i++) {
    if(N[i]=='1') {
      N[i] = '9';
    } else {
      N[i] = '1';
    }
  }
  
  cout << N << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int M[N][N];
int n;
int color[N],d[N],f[N],tt;
void dfs_v(int u/* arguments */) {
  /* code */
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for (v = 0; v < n; v++) {
    /* code */
    if(M[u][v]==WHITE){
      continue;
    }
    if(color[v]==WHITE){
      dfs_v(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}
void dfs(){
  int u;
  for(u=0;u<n;u++){
    color[u]=WHITE;
  }
  tt=0;
  for(u=0;u<n;u++){
    if (color[u]==WHITE/* condition */) {
      /* code */
      dfs_v(u);
    }
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}


int main(){
  int i, j, u, k, v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for (j = 0; j < n; j++) {
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
  for(j=0;j<k;j++){
    scanf("%d", &v);
    v--;
    M[u][v]=1;
    }
  }

  dfs();

  /*for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0){
        printf(" ");
      }
      printf("%d",M[i][j]);
    }
    printf("\n");
  }*/
  return 0;
}



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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
	io();
	int h, a; cin >> h >> a;
	int ans = 0;
	vector<int> v(a);
	for(int i = 0; i < a; ++i){
		cin >> v[i];
		ans += v[i];
	}
	cout << (ans >= h ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
ll power(ll x,ll y)
{
	ll res=1;
	x=x%mod;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%mod;
		
		y=y>>1;
		x=(x*x)%mod;
	}
	return res;
}
struct Matrix{ 
	int a[2][2] = {{0,0},{0,0}};
	Matrix operator *(const Matrix& other){
		Matrix product;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
						product.a[i][k] =product.a[i][k] + (ll)a[i][j]*other.a[j][k];
				}
			}
		}
		return product;
	}
};
//int modInverse(int n,int p)
//{
	//return power(n,p-2,p);
//}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 ll n;
	 cin>>n;
	 ll ans1 = power(10,n);
	 ll ans2 = power(8,n);
	 ll ans3 = (2*(power(9,n) - ans2 + mod)%mod)%mod;
	 ll ans = ((ans1 - ans2 + mod)%mod - ans3 + mod)%mod;
	 cout<<ans<<'\n';
	 return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
using namespace std;

string a;

int main(){
	cin>>a;
	if(a[0]==a[1]&&a[1]==a[2]||a[3]==a[1]&&a[1]==a[2])
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}

signed main()
{
   int a, b, c, k;
   cin >> a >> b >> c >> k;

   if (k % 2 == 0) {
      cout << a - b << endl;
   } else {
      cout << b - a << endl;
   }

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;


int main(){
  fastio;

  int n,x,t;
  cin >> n >> x >> t;

  int qtd = 0;
  int ans = 0;

  while(qtd < n)
    ans+=t,qtd +=x;

  cout << ans << endl;

  return 0;
}

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

int main() {
  int n; cin >> n;
  vector<tuple<string, int, int>> a;
  for (int i=1; i<=n; i++) {
    string s;
    int p;
    cin >> s >> p;
    p = -p;
    a.push_back(tie(s, p, i));
  }
  
  sort(a.begin(), a.end());
  
  for(int i=0; i<n; i++) {
    cout << get<2>(a[i]) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a,b;
    cin>>a>>b;
    cout<<(a+b+1)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
n, q = map(int,input().split())
s = input()
x = [0] * (n + 1)
a = False

for i in range(n):
    p = x[i]
    if s[i:i+2] == "AC":
        p += 1
    x[i+1] =  p

for i in range(q):
    a, b = map(int,input().split())
    print(x[b-1] - x[a-1])



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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  while(a > 0 && d > 0) {
    c -= b;
    a -= d;
  }

  if (c <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
// C - Domino Quality
#include <bits/stdc++.h>

using namespace std;

const char *a3[] = {
	"a..",
	"a..",
	".bb",
};

const char *a4[] = {
	"abcc",
	"abdd",
	"ccab",
	"ddab",
};

const char *a5[] = {
	"accdd",
	"ae..a",
	"be..a",
	"b.ffb",
	"ccddb",
};

const char *a6[] = {
	"aabc..",
	"ddbc..",
	"..aabc",
	"..ddbc",
	"bc..aa",
	"bc..dd",
};

const char *a7[] = {
	"aabbcc.",
	"dd.dd.a",
	"..d..da",
	"..d..db",
	"dd.dd.b",
	"..d..dc",
	"..d..dc",
};

int main(int argc, char *argv[])
{
	int n;
	cin >> n;

	bool ok = false;
	vector<string> a(n, string(n, '.'));

	int tt[] = {3, 4, 5, 6, 7};
	const char **aa[] = {a3, a4, a5, a6, a7};

	for (int l = 0; l < 5; l++) {
		if (n % tt[l] == 0) {
			for (int k = 0; k < n; k += tt[l])
				for (int i = 0; i < tt[l]; i++)
					for (int j = 0; j < tt[l]; j++) a[i + k][j + k] = aa[l][i][j];
			ok = true;
			break;
		}
	}

	for (int x = 0, y = n; x < n && !ok; x += 4, y -= 4) {
		for (int l = 2; l < 5 && !ok; l++) {
			if (y % tt[l] == 0) {
				for (int k = 0; k < x; k += 4)
					for (int i = 0; i < 4; i++)
						for (int j = 0; j < 4; j++) a[i + k][j + k] = a4[i][j];
				for (int k = x; k < n; k += tt[l])
					for (int i = 0; i < tt[l]; i++)
						for (int j = 0; j < tt[l]; j++) a[i + k][j + k] = aa[l][i][j];
				ok = true;
			}
		}
	}

	if (ok)
		for (int i = 0; i < n; i++) cout << a[i] << endl;
	else
		cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    int res[6];
    res[0] = 10*a[0] + a[1] + a[2];
    res[1] = 10*a[0] + a[2] + a[1];
    res[2] = 10*a[1] + a[0] + a[2];
    res[3] = 10*a[1] + a[2] + a[0];
    res[4] = 10*a[2] + a[0] + a[1];
    res[5] = 10*a[2] + a[1] + a[0];

    int sol = 0;
    for(int i=0; i<6; i++)
        sol = max(sol, res[i]);
    cout << sol;

    return 0;
}

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

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

  int A, B, C; cin >> A >> B >> C;
  if (A > B) swap(A, B);
  if (B > C) swap(B, C);
  if (A > B) swap(A, B);

  int ans = 0;
  ans += (B - A) / 2;
  if ((B - A) % 2) {
    C++;
    ans++;
  }
  ans += C - B;

  cout << ans << "\n";
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        Console.WriteLine(s.Count(x => x == 'R') > s.Count(x => x == 'B') ? "Yes" : "No" );
    }
}


Measured memory_bytes: 11220
N,K = map(int,input().split())

from collections import defaultdict
d = defaultdict(int)

for i in range(N):
  a,b = map(int,input().split())
  d[a]+=b

d = sorted(d.items())

cnt = 0
for a,b in d:
  cnt += b
  if cnt >= K:
    print(a)
    break

Measured memory_bytes: 14948
#include <stdio.h>
int main()
{
  int cou,s,a,b,c,sm,am,bm,cm,tic,mai;
  for(cou=0;cou<4;cou++){
    scanf("%d %d",&tic,&mai);
      if(tic==1){
	s=tic;
	sm=mai;
	printf("%d\n",sm*6000);
      }else
	if(tic==2){
	  a=tic;
	  am=mai;
	  printf("%d\n",am*4000);
	}else
	  if(tic==3){
	    b=tic;
	    bm=mai;
	    printf("%d\n",bm*3000);
	  }else
	    if(tic==4){
	      c=tic;
	      cm=mai;
	      printf("%d\n",cm*2000);
	    }
  }
  return 0;
}
    

Measured memory_bytes: 1028
#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(int i=0;i<n;++i)
#define REPR(i,n) for(int 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(int 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 ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0){
    printf("0\n");
    return 0;
  }

  if(a == b && b == c){
    printf("-1\n");
    return 0;
  }
  llong ans = 0;
  while(true){
    int newa = b + c, newb = a + c, newc = a + b;
    if(newa % 2 != 0 || newb % 2 != 0 || newc % 2 != 0){
      break;
    }
    ans++;
    a = newa / 2; b = newb / 2; newc = c / 2;
  }

  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 256
n,k=map(int, input().split())
ans=0
for i in range(k, n+2):
    i_min = (i*(i-1))//2
    i_max = ((n*2 - i+1)*i)//2
    ans+=(1-i_min+i_max)
print(int(ans)%(10**9+7))


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

int main() {
  int N;
  cin>>N;
  vector<vector<int>> s(2,(vector<int>(N)));
    for(int i=0;i<2;i++){
      for(int j=0;j<N;j++){
        cin>>s.at(i).at(j);
      }
    }
  int ans=0;
  for(int k=0;k<N;k++){
    if (s.at(0).at(k)-s.at(1).at(k)>0){
      ans += s.at(0).at(k);
      ans -= s.at(1).at(k);
    }
  }
  cout << ans << endl;
}
 

Measured memory_bytes: 256
def init_fact(n):
    ret=[0]*(n+1)
    ret[0]=1
    for i in xrange(1,n+1):
        ret[i]=ret[i-1]*i%mod
    return ret

mod=10**9+7
n,m=map(int,raw_input().split())
if abs(n-m)>=2:
    print 0
    exit()
fact=init_fact(10**5+5)
if n==m:
    print fact[n]*fact[m]*2%mod
else:
    print fact[n]*fact[m]%mod

Measured memory_bytes: 30188
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const LL LINF = INF *(LL) INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int get(VI a, VI b, bool first)
{
	if (a == b) return 0;
	
	if (first)
	{
		int mx = 0;
		FOR(i, 0, SZ(a))
			if (a[i])
			{
				--a[i];
				mx = max(mx, 1 + get(a, b, first ^ 1));
				++a[i];
			}
			
		return mx;
	}
	else
	{
		int mn = INF;
		FOR(i, 0, SZ(b))
			if (b[i])
			{
				--b[i];
				mn = min(mn, get(a, b, first ^ 1));
				++b[i];
			}
			
		return mn;
	}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	
	int n;
	while(cin >> n)
	{
		VI a(n), b(n);
		FOR(i, 0, n) cin >> a[i] >> b[i];
		LL s = 0;
		FOR(i, 0, n) s += a[i];
		LL mn = s;
		FOR(i, 0, n) 
			if (a[i] > b[i]) mn = min(mn, (LL)b[i]);
		
		cout << s - mn << endl;
	}
	
	cerr << "Time elapsed: " <<  clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
#include <math.h>
#define INF 0x3f3f3f3f
using namespace std;
int main() 
{
char s[100];
scanf("%s",s);
int len=strlen(s);
printf("%c%d%c",s[0],len-2,s[len-1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;


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

  int N, X; cin >> N >> X;
  int mn = 1000;
  rep(i, N) {
    int m; cin >> m;
    X-=m;
    mn = min(mn, m);
  }
  cout << N+X/mn << endl;

  return 0;
}


Measured memory_bytes: 256
/**
*    author:  y_takano
*    created: 22.06.2020 16:45:01
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

using namespace std;

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

    int n, taro = 0, hanako = 0;
    string st, sh;
    cin >> n;

    REP(i, n)
    {
        cin >> st >> sh;
        if (st > sh)
        {
            taro += 3;
        }
        else if (st < sh)
        {
            hanako += 3;
        }
        else
        {
            taro++;
            hanako++;
        }
    }

    cout << taro << ' ' << hanako << '\n';

    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin >> n >> m;
	ll ans = min(n,m/2);
	n -= ans;
	m -= ans*2;
	DUMP(ans);
	DUMP(n);
	DUMP(m);
	if(m > 1){
		DUMP(m/4);
		ans += m / 4;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll minx = min(a,c);
    c-=minx;
    a-=minx;
    minx = min(c,b);
    b-=minx;
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////

#define N 10
int n,m;
bool edge[N][N];

int ans=0;

int main(){
    cin>>n>>m;
    while(m--){
        int a,b;cin>>a>>b;
        edge[a][b]=edge[b][a]=true;
    }
    vector<int>perm;
    perm.push_back(1);
    rep(i,1,n-1)perm.push_back(i+1);
    
    do{
        bool flag=true;
        rep(i,0,n-2){
            int a=perm[i],b=perm[i+1];
            if(!edge[a][b]){
                flag=false;
                break;
            }
        }
        if(flag)ans++;
    }while(next_permutation(perm.begin()+1,perm.end()));
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a, i, total = 0;
	for (i = 0; i < 5; i++){
		scanf("%d", &a);
		if (a > 40)	total += a;
		else total += 40;
	}
	printf("%d\n", total/5);
	return 0;
}

Measured memory_bytes: 600
from collections import deque

K = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

while q:
    n = q.popleft()
    K -= 1
    
    if K==0:
        print(n)
        exit()
    
    for m in range(max(0, n%10-1), min(9, n%10+1)+1):
        q.append(10*n+m)


Measured memory_bytes: 47708
#define _GLIBCXX_DEBUG 
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

int main() {
  bool flag = true;
  string s;
  cin >> s;
  string s_rev;
  s_rev = s;
  int n;
  n = s.size();
  reverse(s_rev.begin(), s_rev.end());
  if (s_rev == s) {
    string s2 = s.substr((n+3)/2-1); //文字列Sのl文字目から最後の文字までの部分文字列を返す(一番初めは0文字目)
    string s1 = s.substr(0, (n-1)/2); //文字列Sのl文字目からl+r-1文字までの部分文字列を返す(同上)
    string s1_rev = s1;
    string s2_rev = s2;
    reverse(s1_rev.begin(), s1_rev.end());
    reverse(s2_rev.begin(), s2_rev.end());
    if (s1_rev == s1) {
      if (s2_rev == s2) {
        coYes;
        flag = false;
      }
    }
  }
  if (flag) {
    coNo;
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;
const int MAX_N=1e5;
int divup(int x,int y){
    if(x%y==0)return x/y;
    else return x/y+1;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
typedef pair<int,int>P;

signed main(){
    int n,m;cin>>n>>m;
    int ans=0;
    for(int i=1;i<=sqrt(m);i++){
        if(m%i!=0)continue;
        if(m/i>=n)chmax(ans,i);
        if(i>=n)chmax(ans,m/i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
aList = [int(x) for x in input().split()]

def calc(x, cache):
    if x % 2 == 0:
        return calc(x//2, cache+1)
    else:
        return cache

count = 0
for x in aList:
    if x % 2 == 0:
        count += calc(x, 0)

print(count)

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

using namespace std;

const int N=200000+5;

int n;
int dis[N];
long long front1[N];
long long front2[N];
int s=1;
int t=1;
long long ans;

int main()
{
	cin>>n;
	front2[0]=0;
	front1[0]=0;
	for(int i=1;i<=n;++i)
	{
		cin>>dis[i];
		front1[i]=front1[i-1]^dis[i];
		front2[i]=front2[i-1]+dis[i];
	}
	for(;;)
	{
		while(t<=n&&(front1[t]^front1[s-1])==(front2[t]-front2[s-1]))
		{
			t++;
		}
		ans+=t-s;
		s++;
		if(s>n)break;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7512
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  vector<int> a(4);
  rep(i,0,4) cin>>a[i];
  asort(a);
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9) cout<<"YES";
  else cout<<"NO";
}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase


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

"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""



def inpt():
    return [int(k) for k in input().split()]


def main():
    n,x,t=map(int,input().split())
    q=n//x
    r=n%x
    ans=q*t
    if(r):
        ans+=t
    print(ans)


BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9516
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int Q, H, S, D;
    cin >> Q >> H >> S >> D;
    int min_one = min({4 * Q, H * 2, S});
    int64_t N;
    cin >> N;
    if (D > 2 * min_one) {
        cout << N * min_one << endl;
    } else {
        int64_t amari = N % 2;
        int64_t syou = N / 2;
        cout << (amari * min_one) + (syou * D) << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= k + x; i++)
	{
		if (i < x + k)
		{
			printf("%d ", i);
		}
		else
		{
			printf("\n");
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll n;
    cin >> n;
    vs g = ga<string>(n);

    map<string, ll> freq;
    ll maxfreq = 0;
    for (auto s : g) {
        freq[s]++;
        amax(maxfreq, freq[s]);
    }

    set<string> ans;
    for (auto s : freq) {
        if (s.second == maxfreq)
            ans.insert(s.first);
    }

    for (const auto &x : ans)
        cout << x << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 34816
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_n = []

for i in range(n):
    a_n.append(a[i])
    a_n.append(a[i]-1)
    a_n.append(a[i]+1)


counter=Counter(a_n)

print(a_n.count(counter.most_common()[0][0]))



                
            

            


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

int main() {
	int N, i;
	cin >> N;
	long long S = 0;
	for (i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			S += i;
		}
	}
	cout << S << endl;
	
}



Measured memory_bytes: 3636
N,M = map(int,input().split())
H = list(map(int,input().split()))
hikaku = [list(map(int,input().split())) for x in range(M)]

high = []
low = []
for i in range(M):
    if H[hikaku[i][0]-1] > H[hikaku[i][1]-1]:
        high.append(hikaku[i][0])
        low.append(hikaku[i][1])
    elif H[hikaku[i][0]-1] < H[hikaku[i][1]-1]:
        high.append(hikaku[i][1])
        low.append(hikaku[i][0])
    else:
        low.append(hikaku[i][0])
        low.append(hikaku[i][1])

Ans = len(set(high)) - len(set(high) & set(low)) + (N - len(set(high+low)))

print(Ans)

Measured memory_bytes: 41440
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c;std::cin >> a >> b >> c;
  ll k;std::cin >> k;
  ll cnt = 0;
  for(;cnt<k&&a>=b;cnt++) b *= 2;
  for(;cnt<k;cnt++) c*=2;
  std::cout << (b<c?"Yes":"No") << '\n';
  return 0;
}


Measured memory_bytes: 3132
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
void fo (){fflush(stdout);}
using namespace std;
ll fact (int x ){return (x <= 1 ? 1 : 1LL * x * fact (x-1));}
int n ;
int main ()
{
  cin >> n ;
  ll ans = 1;
  int m = 1e9 + 7 ;
  for (int i = 2 ; i <= n ;i++)
  {
    ans = (ans * i );
    ans %= m ;
  }
  cout << ans <<"\n";
  cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


Measured memory_bytes: 256