akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int n, m, q; cin >> n >> m >> q;
    int data[q][4]; rep(i,q) rep(j,4) cin >> data[i][j];

    int num[n+m-1]; rep(i,n+m-1) num[i] = i+1;
    int ans = 0;
    // サイズnの部分集合を列挙
    for(int bit=(1<<n)-1; ; ){
        vector<int> data2;
        for(int i=0; i < (n+m-1); i++){
            if(bit & (1<<i)){
                int j = data2.size();
                data2.push_back(i-j+1);
            }
        }
        int count = 0;
        rep(i,q){
            if(data2[data[i][1]-1] - data2[data[i][0]-1] == data[i][2]) count += data[i][3];
        }
        ans = max(ans, count);
        // 次のbit
        int x = bit & -bit, y = bit + x;
        bit = (((bit & ~y)/x)>>1)|y;
        if(bit >= (1<<(n+m-1))) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    combination comb(n*m);
    
    mint ans = 0;
    mint other = comb(n*m-2, k-2);
    for (int i=1; i<=n-1; i++) {
        mint res = other;
        mint now = m*m;
        now *= (n-i);
        res *= now;
        res *= i;
        ans += res;
    } 
    for (int i=1; i<=m-1; i++) {
        mint res = other;
        mint now = n*n;
        now *= (m-i);
        res *= now;
        res *= i;
        ans += res;
    }
    
    cout << ans << endl;
    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, z, y; std::cin >> n >> z >> y;
  vi a(n); rep(i, n) cin >> a[i];
  int ans = abs(a[n-1]-y);
  if (n > 1) chmax(ans, abs(a[n-1]-a[n-2]));
  cout << ans << endl;
}


Measured memory_bytes: 256
<?php
define('MOD', pow(10, 9) + 7);

fscanf(STDIN, "%d %d", $N, $K);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
$A_rev = array_reverse($A);

$arr = [];
$inv_i = $inv_e = 0;

foreach ($A_rev as $v) {
    $tmp = search($arr, $v);
    array_splice($arr, $tmp, 0, $v);
    $inv_i += $tmp;
}
foreach ($A as $v) {
    $tmp = search($arr, $v);
    $inv_e += $tmp;
}

$total = (1 + $K) * $K / 2;
$total %= MOD;
$cnt_i = $K;
$cnt_e = $total - $cnt_i;
if ($cnt_e < 0) {
    $cnt_e += MOD;
}
$ans = $cnt_i * $inv_i + $cnt_e * $inv_e;
printf("%d", $ans % MOD);

function search($a, $b) {
    $cnt = count($a);
    if ($cnt === 0) {
        return 0;
    }
    if ($b > $a[$cnt - 1]) {
        return $cnt;
    }
    if ($b <= $a[0]) {
        return 0;
    }
    $prev_t = null;
    $l = 0;
    $r = $cnt - 1;
    while(true) {
        $t = intdiv($l + $r, 2);
        
        if ($a[$t] >= $b) {
            $r = $t;
        } else if ($a[$t + 1] >= $b) {
            return $t + 1;
        } else {
            $l = $t;
        }
        if ($prev_t === $t) break;
        $prev_t = $t;
    }
    exit('ERR');
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,A,B;
  cin >> X >> A >> B;
  //cout << X << A << B << endl;
  int a;
  a = X - (A * 1);
  
  int b = a % B;
  cout << b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] abc = new int[3];
        abc[0] = sc.nextInt();
        abc[1] = sc.nextInt();
        abc[2] = sc.nextInt();
        
        Arrays.sort(abc);
        System.out.println(abc[0]+" "+abc[1]+" "+abc[2]);
    }
}


Measured memory_bytes: 26212
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	long long ans = 1e18; //10^18
	for (long long i = 1; i * i <= n; ++i) { //i*i<=nこれはi<=jの条件（対称性よりi<=jで調べる)
		if (n % i != 0) continue; 
		long long j = n / i; //割り切れたときここに来る
		ans = min(ans, i + j - 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count =1;
		boolean bool = true;
		boolean status=false;
		boolean b = false;
		if (N==1||N==2) {
			System.out.println(1);
			return ;
		}
		int a = 0;
		for (int i=0;i<N;i++) {
			int t = sc.nextInt();
			if (b==false) {
				a = t;
				b = true;
			} else {
				if (status ==false) {
					if (a>t) {
						bool= true;
						status = true;
					}else if (a<t) {
						bool= false;
						status = true;
					}
				} else {
					if (bool==true&&a<t) {
						status = false;
						count ++;
					} else if (bool==false&&a>t) {
						status = false;
						count ++;
					}
				}
				a=t;
			}
		}
		System.out.print(count);
	}
}

Measured memory_bytes: 58784
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;
//using Graph = vector<vector<int>>;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
/*LL yaku(int x){
    vector<pair<LL, LL> a=[];
    LL xh;
    if(x==1){
        pair<LL, LL> tmp;
        tmp=MP(1,1);
        return tmp;
    }
    else{
        FOR(i, 1, x/2+1){
            if(x%i==0){
                a.append(MP(i,x/i));
            }
        }
    }
    return a;

}*/
LL cul(int a, int b){
    LL f = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
    return f;
} 
int main(){
   double a, b;
   cin >> a>> b;
   double f = a/b;
   int az = (int)a, bz=(int)b;
   int d = az/bz;
   int r = az%bz;
   cout << d << ' ' << r << ' ' ;
   printf("%f", f);
}


    





Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 10000000000
int main()
{
    ll n,cap,max_val=0;cin>>n>>cap;
    ll v[n+1],w[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        max_val+=v[i];
    }
    ll dp[n+1][max_val+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=max_val;j++)
            dp[i][j]=INF;
    }
    for(ll i=0;i<=n;i++)
        dp[i][0]=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=max_val;j++)
        {
            if(v[i]<=j)
                dp[i][j]=min((w[i]+dp[i-1][j-v[i]]),dp[i-1][j]);
            else
               dp[i][j]=dp[i-1][j];
        }
    }
    ll ans=0;
    for(ll i=1;i<=max_val;i++)
    {
        if(dp[n][i]<=cap)
            ans=max(ans,i);
    }/*
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=max_val;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<ans<<endl;
}


Measured memory_bytes: 79104
#include <iostream> // cout, endl, cin
using namespace std;

int main(void)
{
  long long int time, h, m, s;
  cin >> time;
  s = time % 60;
  time -= s;
  m = time % 3600;
  time -= m;
  m /= 60;
  h = time / 3600;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


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

int main(){
    long long h;
    int n;
    cin >> h >> n;
    long long  ans = 0;
    int in;
    for (int i = 0; i < n; i++)
    {
        cin >> in;
        ans += in;
    }
    if(ans >= h)
    cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
	long long int n, m, ans = 0;
	cin >> n >> m;
	vector<long long int >v[n+5];
	 long long int i, h[n+2];
	 for(i=1;i<=n;i++)
	 cin >> h[i] ;
	 for(i=0;i<m;i++)
	 {
	 	long long int a, b;
	 	cin >> a >> b;
	 	v[a].push_back(b);
	 	v[b].push_back(a);
	 }
	 for(i=1;i<=n;i++)
	 {
	 	long long int j;
	 	bool ok = true;
		 for(j=0;j<v[i].size();j++)
	 	{
	 		if(h[v[i][j]]>=h[i])
	 		ok = false;
		 }
		 if(ok)
		 ans++;
	 }
	 cout << ans << endl;
 	return 0;
}

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

#define ll long long
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1000000007;

using namespace std;

int n;
double dp[3010][3010];

int main(){
    memset(dp,0,sizeof(dp));
    scanf("%d",&n);

    dp[0][0]=1.0;
    for (int i=1;i<=n;i++){
        double h,t;
        scanf("%lf",&h);
        t=1.0-h;

        dp[i][0]=dp[i-1][0]*t;
        for (int j=1;j<=i;j++){
            dp[i][j]=dp[i-1][j]*t+dp[i-1][j-1]*h;
        }
    }
    double ans=0.0;
    for (int i=n;i>n/2;i--){
        ans+=dp[n][i];
    }
    printf("%.12f",ans);
	return 0;
}


Measured memory_bytes: 71168
import sys
from bisect import bisect_left
read = sys.stdin.read

N, *A = map(int, read().split())
A.sort()
zero = bisect_left(A, 0)
xy = []
minimum = A[0]
maximum = A[-1]
for i in range(1, N - 1):
    if i < zero:
        xy.append(str(maximum) + ' ' + str(A[i]))
        maximum -= A[i]
    else:
        xy.append((str(minimum) + ' ' + str(A[i])))
        minimum -= A[i]
else:
    xy.append(str(maximum) + ' ' + str(minimum))

print(maximum - minimum)
print('\n'.join(xy))

Measured memory_bytes: 20184
// --------------
// Tejas Pandey  |
// 11 - 04 - 20  |
// Atcoder BC 162|
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int gcd(int a,int b){
	return (a%b?gcd(b,a%b):b);
}

int main (void)
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  //cin >> t;
  while(t--){
  	//cout << "Case :" << c - t << ": ";
  	int n;
  	cin >> n;
  	string s;
  	cin >> s;
  	int cr = 0,cg = 0,cb = 0;
  	for(int i = 1;i < n;i++) if(s[i] == 'R') cr++;
  	else if(s[i] == 'G') cg++;
  	else cb++;
  	//cout << cr << " " << cg << " " << cb << "\n"; 
  	ll ans = 0;
  	for(int i = 1;i < n;i++){
  		if(s[i] == 'R') cr--;
  	    else if(s[i] == 'G') cg--;
     	else cb--;
  		for(int j = 0;j < i;j++){
  			if(s[i] == s[j]) continue;
  			if((s[i] == 'R' && s[j] == 'G') || (s[j] == 'R' && s[i] == 'G')){
  				ans += cb;
  				if(i + (i - j) < n && s[i + (i - j)] == 'B') ans--;
  			}
  			else if((s[i] == 'R' && s[j] == 'B') || (s[j] == 'R' && s[i] == 'B')){
  				ans += cg;
  				if(i + (i - j) < n && s[i + (i - j)] == 'G') ans--;
  			}
  			else{
  				ans += cr;
  				if(i + (i - j) < n && s[i + (i - j)] == 'R') ans--;
  			}
  		}
  	}
  	cout << ans;
  }
  return 0;
}

Measured memory_bytes: 3644
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string S;

  cin >> S;
  int n = S.size();

  if (S[n - 1] == '3')
    cout << "bon" << endl;
  else if (S[n - 1] == '0' || S[n - 1] == '1' || S[n - 1] == '6' ||
           S[n - 1] == '8')
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
  return 0;
}


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

void print(vector<int> x){
  int n;
  for (n = 1; n < x.size()-1; n++){
    cout << x.at(n) << " ";
  }
  cout << x.at(n) << endl;
}

void clean(vector<int> &x){
  for (int n = 0; n < x.size(); n++){
    x.at(n) = 0;
  }
}

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

  vector<int> A(N+1);
  vector<int> B(N+1);

  for (int n = 1; n <= N; n++){
    cin >> A.at(n);
  }

  //print(A);

  for (int k = 0; k < K; k++){
    bool is_satu = true;
    clean(B);
    for (int n = 1; n <= N; n++){
      int v = A.at(n);
      int spos = max(1, n-v);
      int epos = min(N, n+v);
      //cout << v << " " << spos << " " << epos << endl;
      B.at(spos)++;
      if (epos+1 <= N){
	B.at(epos+1)--;
      }
    }
    //print(B);
    for (int n = 1; n <= N; n++){
      B.at(n) += B.at(n-1);
      if (B.at(n) != N){
	is_satu = false;
      }
    }
    A = B;
    if (is_satu){
      break;
    }
  }
  print(A);
}


Measured memory_bytes: 5592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int cnt = 0;
        for (Integer i : erathosthenes(55555)) {
            if (i%5==2) {
                System.out.println(i);
                for (int j=2;j<i;j++) {
                    if (i%j==0) {
                        System.out.println("err");
                    }
                }
                cnt++;
            }
            if (cnt==N) {
                break;
            }
        }
    }
    public static ArrayList<Integer> erathosthenes(int x) {
        int[] nums = new int[x];
        int[] flag = new int[x];
        for (int i=2;i<x;i++) {
            nums[i]=i;
        }
        for (int i=2;i<Math.sqrt(x);i++) {
            if (flag[i]==1) {
                continue;
            }
            for (int j=2;j*i<x;j++) {
                flag[j*i]=1;
            }
        }
        ArrayList<Integer> ans = new ArrayList<Integer>();
        for (int i=2;i<x;i++) {
            if (flag[i]==0) {
                ans.add(nums[i]);
            }
        }
        return ans;
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

int euq(int a, int b) {return b ? euq(b, a%b) : a;}

signed main() {
    int N, K;
    cin >> N >> K;

    if(N>=K) cout << min(N%K, (K-N%K)) << endl;
    else cout << min(K-N, N) << endl;
 
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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




int main(){
    std::string S; std::cin >> S;
    std::vector<int> a(4);
    for(int i(0); i < 4; ++i) a[i] = S[i] - '0';
    for(int i(0), i_len(1 << 3); i < i_len; ++i){
        int sum(a[0]);
        for(int j(0); j < 3; ++j){
            if((i >> j) & 1) sum += a[j+1];
            else sum -= a[j+1];
        }
        if(sum == 7){
            std::cout << a[0];
            for(int j(0); j < 3; ++j){
                std::cout << (((i >> j) & 1) ? '+': '-');
                std::cout << a[j+1];
            }
            std::cout << "=7" << std::endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn search(i: usize, p: usize, t: usize, g: &Vec<Vec<usize>>, mut m: &mut Vec<bool>) -> bool {
    for &j in g[i].iter() {
        if j == p || m[j] { continue; }
        if j == t { return true; }
        m[j] = true;
        if search(j, i, t, g, &mut m) { return true; }
    }
    return false;
}

fn main() {
    let (n, m) = get!(usize, usize);
    let mut g = vec![Vec::new(); n];
    let mut aa = Vec::new();
    let mut bb = Vec::new();
    for _ in 0..m {
        let (a, b) = get!(usize, usize);
        g[a-1].push(b-1);
        g[b-1].push(a-1);
        aa.push(a-1);
        bb.push(b-1);
    }

    let mut r = 0;
    for s in 0..m {
        let mut memo = vec![false; n];
        memo[aa[s]] = true;
        if !search(aa[s], bb[s], bb[s], &g, &mut memo) { r += 1; };
    }
    println!("{}", r);
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

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

int main()
{
  long long int A,B,K;
  cin >> A >> B >> K;
  if(A>=K)
  {
    cout << A-K << " " << B <<endl;
  }
  else if(A<K&&A+B>=K)
  {
    cout << 0 << " " << B+A-K <<endl;
  }
  else if(A+B<K)
  {
    cout << 0 << " " << 0 <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
N, K = map(int, input().split())
P = [0]+list(map(int, input().split()))
Psum = list(accumulate(P))
total = 0
for i in range(K, N+1):
    if Psum[i]-Psum[i-K] > total:
        total = Psum[i]-Psum[i-K]
        index = i
ans = 0
for i in range(index, index-K, -1):
    ans += (P[i]+1)*0.5

print(ans)


Measured memory_bytes: 32124
using System;
using System.Collections.Generic;
using System.Linq;
 
class Pg
{
    static void Main()
    {
        var mt = new Method();
        Console.WriteLine(string.Join("\n", mt.Met().ToList()));
    }
}
class Method
{
    List<int> res = new List<int>();
    internal IEnumerable<int> Met()
    {
        try
        {
            var lst = Console.ReadLine().Split().Select(int.Parse).ToList();
            lst[0] %= lst[1];
            var r = 0;
            for (int i = 0; i < lst[2]; ++i)
            {
                lst[0] *= 10;
                r += lst[0] / lst[1];
                lst[0] %= lst[1];
            }
            res.Add(r);
            return Met();
        }
        catch
        {
            return res;
        }
    }
}


Measured memory_bytes: 18428
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
ll go(ll x) {
	return x * x * x * x* x;
}
int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	ll x; cin >> x;
	for (ll i = -70; ; i++) {
		ll tmp = - go(i);
		ll t = x - tmp;
		// A^5 = X + B^5
		for (ll j = 1; j * j <= t; j++) {
			if (go(j) == t) {
				cout << j << ' ' << i << '\n'; return 0;
			}
		}
	}

	




}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,W,v[100],w[100],dp[10001];
  fill_n(dp,10001,-1);
 
  cin >> N >> W;
  for(int i=0;i<N;i++){
    cin >> v[i] >> w[i];
  }
  dp[0]=0;
  for(int i=0;i<N;i++){
    for(int j=W;j>=w[i];j--){
      dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    }
  }
  cout << *max_element(dp, dp + W + 1) << endl;
}

Measured memory_bytes: 1200
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
typedef pair<int,int> P;
int a,b,cnt,n;
char ch;
vector < P > t;
int ans[1000];
int main(){
  cnt=0;
  while(cin>>a>>ch>>b){
    if(a==0&&b==0)break;
    t.push_back(P(b,a));
    cnt++;
  }
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  


  ans[0]=1;
  for(int i=1;i<cnt;i++){
    if(t[i].first==t[i-1].first)ans[i]=ans[i-1];
    else ans[i]=ans[i-1]+1;
  }
  while(cin>>n){
    for(int i=0;i<cnt;i++){
      if(t[i].second==n){
	cout<<ans[i]<<endl;
	break;
      }
    }
  }
  return 0;
}

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int x;
    cin >> x;

    if (x < 100) {
        cout << false;
    } else {
        double r = x % 100;
        double n = x / 100;

        // Distribute r into n where each n can't go above 5

        auto avg_dist = ceil(r / n);

        cout << (avg_dist <= 5) << endl;
    }
}


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

int main()
{
    double d, t, s;
    cin >> d >> t >> s;
    double tr = d / s;
    if (tr > t)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3704
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long min = Long.parseLong(sc.next());
        long tmp;
        for(int i=0;i<4;i++){
            tmp = Long.parseLong(sc.next());
            if(tmp < min){
                min = tmp;
            }
        }
        sc.close();
        long count = (n+min-1)/min;
        System.out.println(4+count);
    }
    
}

Measured memory_bytes: 21844
function main(input){
  const lines = input.split('\n')
  const nums = lines[0].split(' ').map(x => parseInt(x));
  var result = Math.min(nums[0]+nums[1], nums[1]+nums[2], nums[0]+nums[2])

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 22076
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
A,B,C,D = map(int,input().split())
a = gcd(C,D)
E = (C//a)*D
n1 = B//C
n2 = B//D
n3 = B//E
n = B-(n1+n2-n3)
m1 = (A-1)//C
m2 = (A-1)//D
m3 = (A-1)//E
m = A-1-(m1+m2-m3)
print(n-m)

Measured memory_bytes: 61948
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, x; cin >> n >> x;
	vi v(n); rep(i, n) cin >> v[i];
	auto f = [&](int one){
		ll tmp = (ll)x * (n + one);
		for(int i = n - 1; i >= 0; i--){
			int num = (n - i - 1) / one + 1;
			if(num == 1) tmp += 5ll * v[i];
			else tmp += v[i] * ((num + 1ll) * (num + 1) - num * num);
		}
		return tmp;
	};
	int l = 1, r = n, a, b;
	ll ans = 1e18;
	while(l + 100 < r){
		int a = (2 * l + r) / 3, b = (l + 2 * r) / 3;
		if(f(a) <= f(b)) r = b;
		else l = a;
	}
	for(int i = l; i <= r; i++) ans = min(ans, f(i));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> ti;
const int INF = 1e9;
const int MN = 110;
int g[MN][MN];
int dx[2] = {1,0};
int dy[2] = {0,1};
int dist[MN][MN];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int h,w;
	cin >> h >> w;
	for(int i=0;i<h;i++) {
		string s;
		cin >> s;
		for(int j=0;j<w;j++) {
			if(s[j] == '#') {
				g[i][j] = 0;
			} else {
				g[i][j] = 1;
			}
			dist[i][j] = INF;
		}
	}
	priority_queue<ti,vector<ti>,greater<ti> > lol;
	int be = 1-g[0][0];
	dist[0][0] = be;
	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) {
			int ad = ((g[i][j] && !g[i+1][j])?1:0);
			dist[i+1][j] = min(dist[i][j]+ad,dist[i+1][j]);
			int bd = ((g[i][j] && !g[i][j+1])?1:0);
			dist[i][j+1] = min(dist[i][j]+bd,dist[i][j+1]);
		}
	}
	cout << dist[h-1][w-1] << '\n';
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>

using namespace std;

const int MAX = 10000;

int p[MAX];
int hight[MAX];

int findSet(int v) {
	if (p[v] != v) {
		p[v] = findSet(p[v]);
	}
	return p[v];
}

void unite(int x, int y) {
	int px = findSet(x);
	int py = findSet(y);
	if (hight[px] < hight[py]) {
		p[px] = py;
	} else {
		p[py] = px;
	}
}

bool same(int x, int y) {
	if (findSet(x) == findSet(y))
		return true;
	else
		return false;
}

int main() {

	int n, q;
	scanf("%d %d", &n, &q);

	for (int i = 0; i < n; ++i) {
		p[i] = i;
		hight[i] = 0;
	}

	for (int i = 0; i < q; ++i) {
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);

		if (com == 0) {
			unite(x, y);
		} else {
			if (same(x, y))
				cout << 1 << endl;
			else
				cout << 0 << endl;
		}
	}

	return 0;
}

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

int main() {
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2)
		puts((xb2 < xa1 || xa2 < xb1 || yb2 < ya1 || ya2 < yb1) ? "NO" : "YES");
}

Measured memory_bytes: 3032
n, m, l = gets.split.map(&:to_i)
ary_A = []
ary_B = []
ary_C = []

n.times do
  ary_A << gets.split.map(&:to_i)
end
m.times do
  ary_B << gets.split.map(&:to_i)
end

n.times do |i|
    l.times do |j|
        num = 0
        m.times do |k|
            num += ary_A[i][k] * ary_B[k][j]
        end
        ary_C << num
    end
end

i = 1
ary_C.each do |num|
    if i  == l
        i = 0
        puts num
    else
        print num, " "
    end
    i += 1
end



Measured memory_bytes: 7204
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
money = s.count(s[0]) - t.count(s[0])
for i in set(s):
    if money < s.count(i) - t.count(i):
        money = s.count(i) - t.count(i)
print(money) if money >= 1 else print(0)
    




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    vector<int> A;
    A.push_back(0);

    int num;
    for (int i = 0; i < N; i++)
    {
        cin >> num;
        A.push_back(num);
    }
    A.push_back(0);

    N += 2;

    ll sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += abs(A[i + 1] - A[i]);
    }
    // printf("sum = %lld\n", sum);

    //観光スポットiを消して出力
    ll ans;
    for (int i = 1; i <= N - 2; i++)
    {
        // ans = sum - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1]);
        ans = sum - (abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i])) + abs(A[i + 1] - A[i - 1]);
        cout << ans << endl;
    }
    return (0);
}

Measured memory_bytes: 3872
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>

using namespace std;
const int N=2e5+10,inf=1e9;
int dp[N][2];
char s[N];

int main(){
    int N,M,ans;
	cin >> N >> M;
    vector<int> L(M),R(M);
    for(int i=0;i<M;i++){
        cin >> L[i];
        cin >> R[i];
    }
    int L_max = *std::max_element(L.begin(), L.end());
    int R_min = *std::min_element(R.begin(), R.end());

    ans = R_min - L_max + 1;
    if(ans<0)ans=0;
	cout << ans << endl;
}


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

int main(void){
  int i,index=0,count=0,N,K;
  string S;
  cin >> N >> K;
  cin >> S;
  vector<int> comp;
  vector<int> len(1,0);
  comp.push_back(0);
  char pre=' ';
  REP(i,N){
    if((i!=0 && pre!=S[i])){
      if(S[i]=='1')comp.push_back(-count);
      else comp.push_back(count);
      count=0;
    }
    pre = S[i];
    count++;
  }
  if(S[N-1]=='1')comp.push_back(count);
  else comp.push_back(-count);

  count = 0;
  REP(i,comp.size()){
    if(comp[i]<0){
      if(K<=count){
        len.push_back(len[index]+comp[i-2*K]-comp[i-2*K-1]);
        index++;
      }
      len[index]-=comp[i];
      count++;
    }else{
      len[index]+=comp[i];
    }
  }
  int max=0;
  REP(i,len.size()){
    if(max<len[i])max=len[i];
  }
  cout << max << endl;
  return 0;
}


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

const string Yes = "Yes";
const string No = "No";

bool isP(string s)
{
    for(int i=0;i<s.size();++i)if(s[i] != s[s.size()-1-i])return false;
    return true;
}
void solve(string S)
{
    if(isP(S) && isP(S.substr(0,S.size()/2)) && isP(S.substr(S.size()/2+1)))
        cout<<Yes<<endl;
    else
        cout<<No<<endl;
}


int main()
{
    string S;
    cin >> S;
    solve(S);
    return 0;
}


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

long long hani(int x) {
     return 26*(pow(26,x)-1)/25;
}
  

int main(){
  long long n;
  cin >> n;
  int leng =0;
  
   if(n>=1&&n<=hani(1)) leng=1;
   if(n>=hani(1)+1&&n<=hani(2)) leng=2;
   if(n>=hani(2)+1&&n<=hani(3)) leng=3;
   if(n>=hani(3)+1&&n<=hani(4)) leng=4;
   if(n>=hani(4)+1&&n<=hani(5)) leng=5;
   if(n>=hani(5)+1&&n<=hani(6)) leng=6;
   if(n>=hani(6)+1&&n<=hani(7)) leng=7;
   if(n>=hani(7)+1&&n<=hani(8)) leng=8;
   if(n>=hani(8)+1&&n<=hani(9)) leng=9;
   if(n>=hani(9)+1&&n<=hani(10)) leng=10;
   if(n>=hani(10)+1&&n<=hani(11)) leng=11;
//26進数
  vector<int> a(12);
  long long x = n - hani(leng-1)-1;
  for(int i=0;i<leng;i++){
    a[i] = x % 26;
    x /= 26;
  }
  
  for(int i=leng-1;i>=0;i--){
    cout << (char)('a'+a[i]) ;
  }
}
    
    




Measured memory_bytes: 4112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[110],alice=0,bob=0;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n,greater<int>());
  for(int i=0;i<n;i++){
    if(i%2==0) alice+=a[i];
    else bob+=a[i];
  }
  cout<<alice-bob;
}


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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    auto concat = stoi(to_string(a) + to_string(b));
    cout << ((int)sqrt(concat) * (int)sqrt(concat) == concat ? "Yes\n" : "No\n");
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
def main():

    N = int(input())
    T,A = map(int,input().split())
    H = list(map(int,input().split()))
    ans = [abs(A-(T - H[i]*0.006)) for i in range(N)]
    print(ans.index(min(ans))+1)
    
    


if __name__== "__main__":
    main() 

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> edge;
typedef pair<int,edge> state;

int toInt(string s){
  stringstream ss(s);
  int res;
  ss >> res;
  return res;
}

inline int id(string a,int m, int n){
  if(a[0] == 'C')return toInt(a.substr(1))-1;
  if(a[0] == 'L')return toInt(a.substr(1))-1 + m;
  if(a[0] == 'H')return n+m;
  return m+n+1;
}

int main(){
  int m,n,k,d;
  while(cin >> m >> n >> k >> d, n){
    vector<int> c(m);
    for(int i=0;i<m;i++)cin >> c[i];

    vector< vector<edge> > g(n+m+2);
    for(int i=0;i<d;i++){
      string A,B;
      int cost;
      cin >> A >> B >> cost;
      int a = id(A,m,n), b = id(B,m,n);

      g[a].push_back( edge(cost,b) );
      g[b].push_back( edge(cost,a) );
    }

    vector< vector<int> > dis(1<<m,vector<int>(n+m+2,1e8));
    dis[0][n+m] = 0;
    priority_queue< state,vector<state>,greater<state> > q;
    q.push(state(0,make_pair(0,n+m)));
    
    while(q.size()){
      state s = q.top(); q.pop();
      int cost = s.first, bit = s.second.first, pos = s.second.second;

      if(dis[bit][pos] < cost)continue;
      for(edge e : g[pos]){
	int nxtpos = e.second, nxtcost = cost + e.first, nxtbit = bit;
	if(nxtpos<m){
	  if((bit>>nxtpos)&1)continue;
	  nxtbit |= 1<<nxtpos;
	}
	if(dis[nxtbit][nxtpos] > nxtcost){
	  dis[nxtbit][nxtpos] = nxtcost;
	  q.push(state(nxtcost, make_pair(nxtbit,nxtpos)));
	}
      }
    }

    int res = 1e8;
    for(int bit=0;bit<(1<<m);bit++){
      int cake = 0;
      for(int i=0;i<m;i++){
	if((bit>>i)&1)cake += c[i];
      }
      res = min(res, dis[bit][n+m+1]*k - cake);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1336
#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[4];

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

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

  for(int i = 0; i < 4; i++){
    if(n[i] == 1) a[0]++;
    if(n[i] == 7) a[1]++;
    if(n[i] == 9) a[2]++;
    if(n[i] == 4) a[3]++;
  }

  int ans = 1;
  for(int i = 0; i < 4; i++){
    ans &= a[i];
  }
  cout << (ans == 1 ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t=1;
	while(t--)
	{
		int x;
		cin >> x;
		if(x>=30)
		cout << "Yes";
		else
		cout << "No";		
	}
}




Measured memory_bytes: 3620
s = input()
r = ''
for _ in s:
    if (('A' <= _) and (_ <= 'Z')):
        r += chr(ord(_) + (ord('a') - ord('A')))
    elif ('a' <= _ and _ <= 'z'):
        r += chr(ord(_) - (ord('a') - ord('A')))
    else:
        r += _
print(r)



Measured memory_bytes: 5556
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
//#include <bits/stdc++.h>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<char> right = { 'p', 'o', 'i', 'u', 'y', 'l', 'k', 'j', 'h', 'm', 'n' };
	
	while (1)
	{
		string str; cin >> str;
		vector<int> move((int)str.size() + 5, 0);
		int cnt = 0;
		if (str[0] == '#') { return 0; }
		rep(i, (int)str.size())
		{
			if (count(all(right), str[i]) > 0){ move[i] = 1;	}
		}
		for (int i = 1; i < (int)str.size(); i++)
		{
			if (move[i - 1] != move[i]){ cnt += 1; }
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
double dp[310][310][310];
int n;
double rec(int i, int j, int k){
    if(dp[i][j][k]>=0){
        return dp[i][j][k];
    }
    if(i==0 && j==0 && k==0){
        return 0.0;
    }
    double res = 0.0;
    if(i > 0){
        res += rec(i-1,j,k)*i;
    }
    if (j > 0)
    {
        res += rec(i + 1, j - 1, k) * j;
    }
    if (k > 0)
    {
        res += rec(i, j + 1, k - 1) * k;
    }
    res += n;
    res*=1.0/(i+j+k);
    return dp[i][j][k] = res;
}
int main(){
    cin >> n;
    int one =0, two = 0, three = 0;
    for(int i = 0;i<n;i++){
        int a;
        cin >> a;
        if(a==1){
            one++;
        }
        else if(a==2){
            two++;
        }
        else{
            three++;
        }
    }
    memset(dp,-1,sizeof(dp));
    printf("%.10lf",rec(one,two,three));
return 0;
}

Measured memory_bytes: 233088
mount_count = input()
mount_heights = input()
mount_heights_list = mount_heights.split()
count = 0
max_height = int(mount_heights_list[0])
for mount_height in mount_heights_list:
    if max_height <= int(mount_height):
        max_height = int(mount_height)
        count += 1
print(count)



Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

#define REP(i,n) for(int i = 0;i < n;i++)

using namespace std;
typedef long long ll;
const int INF = INT_MAX / 4;

const int max_n = 1e3;

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

  int N;
  cin >> N;
  int a[N];
  REP(i, N) cin >> a[i];

  // if (N == 1) {
  //   cout << a[0];
  //   return 0;
  // }

  int i;
  for(i = N-1;i >= 0;i -= 2) {
    cout << a[i];
    if (i > 1) cout << " ";
  }
  if (N % 2) i = 1;
  else i = 0;
  for(;i < N;i += 2) {
    cout << " " << a[i];
  }

  cout << "\n";
  return 0;
}


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

#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)

using ll = long long;
#define INF 1e9


int main(){
  int N;
  cin >> N;
  int ans = (N*(N+1))/2;
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N; cin >> N;
  if (N==1) cout << "Hello World" << endl;
  if (N==2) {
    int A, B; cin >> A >> B;
    cout << A + B << endl;
  }
  return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> v[66];
signed main(){

	string str;
	cin>>str;
	for(int i=0;i<str.size();i++) v[str[i]-'a'].push_back(i);
	for(int i=0;i<26;i++){
		if(v[i].size()>1){
			for(int j=1;j<v[i].size();j++){
				if(v[i][j]-v[i][j-1]<=2){
					cout<<v[i][j-1]+1<<" "<<v[i][j]+1;
					return 0;
				}
			}
		}
	}
	cout<<"-1 -1";
	return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    array<int, 3> pre{}, cur, cost;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j)
            cin >> cost[j];
        cur[0] = cost[0] + max(pre[1], pre[2]);
        cur[1] = cost[1] + max(pre[0], pre[2]);
        cur[2] = cost[2] + max(pre[0], pre[1]);
        swap(cur, pre);
    }
    cout << max({pre[0], pre[1], pre[2]});
}


Measured memory_bytes: 256
x, n = gets.split.map(&:to_i)
if n == 0
  puts x
  exit
end
ans = []
ary = gets.split.map(&:to_i)
ans << x unless ary.include?(x)
count = 1
while ans.length == 0
  unless ary.include?(x-count)
    ans << x-count
  end
  unless ary.include?(x+count)
    ans << x+count
  end
  count+=1
end
puts ans.min < 0 ? ans.max : ans.min


Measured memory_bytes: 14220
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main()
{
    int N; cin >> N;
    string A, B, C;
    cin >> A >> B >> C;

    int ans=0;
    REP(i,N){
        if(A[i]==B[i] and B[i]==C[i]){
            ans+=0;
        }else if(A[i]==B[i] and B[i]!=C[i]){
            ans+=1;
        }else if(A[i]!=B[i] and B[i]==C[i]){
            ans+=1;
        }else if(A[i]==C[i] and B[i]!=C[i]){
            ans+=1;
        }else{
            ans+=2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
    
    string data[3];
    int i;

    for(i=0;i<2;i++){
        cin >> data[i];
    }

    int a = stoi(data[0]);
    int b = stoi(data[1]);

    cout << a*b << " " << a*2 + b*2 << endl;

    return 0;
    
}


Measured memory_bytes: 3116