akhauriyash/Code-Regression huggingface dataset:
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll k;
     cin >> k;
     for(ll i=-1000;i<=1000;i++)
     {
          for(ll j=-1000;j<=1000;j++)
          {
               ll fisrt = i*i*i*i*i;
               ll second = j*j*j*j*j;
               if(fisrt-second==k)   
               {
                    cout<<i<<" "<<j;
                    return;
               }
          }
     }
}

int main()
{
     FAST;
     ll t = 1;
  //   cin >> t;
     while(t--)
     {    
          solve();
     }
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	string stack;

	for(auto& chr: fetch<string>()) {
		if(!stack.empty() && stack.back() == 'S' && chr == 'T') {
			stack.pop_back();
		} else {
			stack.push_back(chr);
		}
	}

	cout << len(stack) << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 916
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), m = next();
  var a = nexts(n);
  a.sort((a,b)=>b-a);
  var sum = a.reduce((a,b)=>a+b);
  return a[m-1] >= sum/4/m ? "Yes" : "No";
}

Measured memory_bytes: 21064
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*(k+1)
for i in range(k+1):
    for j in range(n):
        if i>=l[j] and dp[i-l[j]]==0:
            dp[i]=1
if dp[k]==0:
    print('Second')
else:
    print('First')

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

int main() {
	// your code goes here
	ll n,K;
	cin>>n>>K;
	ll a[n];
	for(ll i=0;i<n;i++)
	    cin>>a[i];
    ll dp[n];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    
    for(ll i=2;i<n;i++){
        dp[i]=INT_MAX;
        for(int k=1;k<=K;k++){
            if(i-k>=0)
            dp[i]=min(dp[i-k]+abs(a[i]-a[i-k]),dp[i]);
        }
    }
    cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back

#define INT 1.01

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

    ll X; // llと比較して実行時間が大幅に速い (2205ms->2ms)
    cin >> X;

    ll v = 100;
    //while(true){ //while, for文では実行時間は変わらない
    rep(ret, INF){
        if(X<=v){
            cout << ret << endl;
            break;
        }
        v *= INT; // 実行時間が2ms->6msへと伸びる
        //v += 0.01*v;
    }

    //cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	   c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,a[MAXN];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
        read(a[i]);
    }
    int pre = 1;
    int64 ans = a[1] - 1;a[1] = 1;
    for(int i = 2 ; i <= N ; ++i) {
        if(a[i] == pre + 1) pre++;
        else {
            ans += (a[i] - 1) / (pre + 1);
        }
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
  double v, y, t;
  while(scanf("%lf", &v) != EOF){
    t = v / 9.8;
    y = 4.9 * t * t;
    int i = 1;
    while((5 * i - 5) < y) i++;
    printf("%d\n", i);
  }
  return 0;
}

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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;
    vs64 a(n); rep (i, n) cin >> a[i];

    s64 ans = 0;
    s64 p = 0;
    rep (i, n)
    {
        if (a[i] == p + 1)
        {
            p = a[i];
        }
        else
        {
            ans += (a[i] - 1) / (p + 1);
            p = MAX(p, 1);
        }
    }

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



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

int main(){
    int N;
    cin >> N;
    typedef pair<string, int> store_site;
    priority_queue<store_site, vector<store_site>, greater<store_site>> que_site;
    vector<int> P(N);

    for(int i=0; i<N; i++){
        string s;
        cin >> s >> P[i];
        que_site.push(store_site(s, i));
    }

    typedef pair<int, int> store_point;
    priority_queue<store_point> que;
    string target_name = que_site.top().first;
    while (!que_site.empty()) {
        store_site s = que_site.top();
        string site_name = s.first;
        int index = s.second;
        if(site_name == target_name){
            que.push(store_point(P[index], index));
        }else{
            while(!que.empty()){
                store_point ans = que.top();
                cout << ans.second + 1 << endl;
                que.pop();
            }
            target_name = site_name;
            que.push(store_point(P[index], index));
        }
        que_site.pop();
    }
    while(!que.empty()){
        store_point ans = que.top();
        cout << ans.second + 1 << endl;
        que.pop();
    }

    return 0;    

}

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

#define rep(i, a, b) for (int i = (a); i < (b); i++)

int main() {
  int n;
  cin >> n;
  vector<int> ans(n + 1);
  rep(x, 1, n / x + 1) {
    rep(y, 1, n / y + 1) {
      rep(z, 1, n / z + 1) {
        int t = x * x + y * y + z * z + x * y + y * z + z * x;
        if (t <= n) ans[t]++;
      }
    }
  }
  rep(i, 1, n + 1) { cout << ans[i] << endl; }
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
namespace Fact{
	long f[1000001];
	long rf[1000001];
	long pow(long N,long K){
		if(K == 0){
			return 1;
		}
		else if(K % 2 == 0){
			long t = pow(N,K/2);
			return t*t%mod;
		}
		else{
			return N*pow(N,K-1)%mod;
		}
	}
	void Fact(int N){
		for(int i=0;i<N+1;i++){
			if(i == 0){
				f[i] = 1;
			}
			else{
				f[i] = (f[i-1]*i)%mod;
			}
		}
		for(int i=N;i>=0;i--){
			if(i == N){
				rf[i] = pow(f[N],mod-2);
			}
			else{
				rf[i] = rf[i+1]*(i+1)%mod;
			}
		}
	}
	long GetFact(int N){
		return f[N];
	}
	long GetPerm(int N,int R){
		return f[N] * rf[N-R] % mod;
	}
	long GetConv(int N,int R){
		return ((f[N]*rf[R])%mod*rf[N-R])%mod;
	}
	long GetRev(int N){
		if(N == 0){
			return 1;
		}
		else{
			return rf[N] * f[N-1] % mod;
		}
	}
}
void Calc(){
	int N = rei();
	Fact::Fact(1000000);
	if(N == 2){
		cout << 1 << endl;
		return;
	}
	long ans = 0;
	for(int i=2;i<N-1;i++){
		int a = i-2;
		int b = N-4-a;
		if(a >= 0 && b >= 0 && a >= b){
			ans += (i-1)*Fact::GetConv(a,b)%mod*Fact::GetFact(i)%mod*Fact::GetFact(N-2-i)%mod;
		}
	}
	ans %= mod;
	ans = (Fact::GetFact(N-1) * (N-1) % mod + mod - ans) % mod;
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 15872
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    K = ii()
    ans = 0
    for a in range(1,K+1):
        for b in range(1,K+1):
            for c in range(1,K+1):
                ans += gcd(gcd(a, b), c)
    print(ans)



main()



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

int main(){
  int a, b, c, cnt=0;
  cin >> a >> b >> c;
  rep2(i, a, b+1){
    if(c%i==0){
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

#define loop(i,n) for(int i=1;i<=n;i++)
typedef pair<int,int> P;
char a[1002][1002];
P f[12];
int d[1002][1002];

int bfs(P from,P to){
  loop(i,1000)loop(j,1000)d[i][j]=-1;
  queue<P>que;
  que.push(from);
  d[from.first][from.second]=0;
  int dir[5]={0,-1,0,1,0};
  while(!que.empty()){
    P p=que.front();que.pop();
    if(p.first==to.first&&p.second==to.second)break;
    loop(i,4){
      int qx=p.first+dir[i-1],qy=p.second+dir[i];
      if(a[qx][qy]!='X'&&d[qx][qy]==-1){
        que.push(P(qx,qy));
        d[qx][qy]=d[p.first][p.second]+1;
      }
    }
  }
  return d[to.first][to.second];
}

int main(){
  int h,w,n;
  char t;
  cin>>h>>w>>n;
  loop(i,1002)loop(j,1002)a[i-1][j-1]='X';
  loop(i,h)loop(j,w){
    cin>>t;
    if('1'<=t&&t<='9'){
      f[t-'0']=P(i,j);
    }else if(t=='S'){
      f[0]=P(i,j);
    }
    a[i][j]=t;
  }
  int c=0;
  loop(i,n){
    c+=bfs(f[i-1],f[i]);
  }
  cout<<c<<endl;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int n;
    while (cin >> n , n){
        vector<int> a(n);
        REP(i,n) cin >> a[i];
        sort(ALL(a));
        int sum = 0;
        for (int i=1; i<n-1; i++) {
            sum += a[i];
        }
        cout << sum/(n-2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = False
while True:
    for k in range(N):
        if A[k]%2!=0:
            flag = True
            break
        A[k] = A[k]//2
    if flag:
        break
    count += 1
print(count)

Measured memory_bytes: 3060
fun main(args: Array<String>){
  val input = readLine()!!.split(" ")
  val a = input[0].toInt()
  val b = input[1].toInt()

  println(
    if( 1 <= a && a <= 9 && 1 <= b && b <= 9 )
      a*b
    else
      -1
  )
}


Measured memory_bytes: 37944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl0

ll modpow(ll x, ll y, ll m){
    if(y==0) return 1;
    ll res = modpow(x,y/2,m);
    return res * res % m * (y&1 ? x : 1) % m;
}

int h,w,n,k;

int ask(int a, int b, int c, int d){
    printf("? %d %d %d %d\n", a, b, c-1, d-1);
    fflush(stdout);
    int p;
    cin >> p;
    return p;
}

int ans[50][50];

void solve(int i1, int j1, int i2, int j2, int n){
    int h = i2 - i1;
    int w = j2 - j1;
    if(n == 0 || n == h*w){
        for(int i = i1; i < i2; ++i){
            for(int j = j1; j < j2; ++j){
                ans[i][j] = n == 0 ? 0 : 1;
            }
        }
    } else {
        if(h > w){
            int x = ask(i1, j1, i1 + h/2, j2);
            solve(i1, j1, i1 + h/2, j2, x);
            solve(i1 + h/2, j1, i2, j2, n - x);
        } else {
            int x = ask(i1, j1, i2, j1 + w/2);
            solve(i1, j1, i2, j1 + w/2, x);
            solve(i1, j1 + w/2, i2, j2, n - x);
        }
    }
}

int main(){
    cin >> h >> w >> n >> k;
    memset(ans, -1, sizeof ans);
    solve(0, 0, h, w, n);

    rep(j,w){
        solve(0, j, h, j, ask(0, j, h, j));
    }

    // rep(i,h){
    //     rep(j,w){
    //         cerr << ans[i][j];
    //     }
    //     cerr << endl;
    // }

    ll sigma = 0;
    rep(i,h)rep(j,w){
        sigma += ans[i][j] * modpow(2, i*w + j, k);
        sigma %= k;
    }
    cout << "! " << sigma << endl;
}


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

int main(){
	// freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	int a[n];
	map<int,int> mp;
	for(int i = 0;i < n;i++) {cin>>a[i]; mp[a[i]] ++;}
	int ans = 0;
	for(map<int,int>::iterator it = mp.begin();it!=mp.end();it++){
		int val = it->first;
		int freq = it->second;
		if(freq < val) ans += freq;
		else ans += freq - val;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var r = new string[n, 3];
            for (int i = 0; i < n; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < 3; j++) r[i, j] = line[j];
            }
            getAns(r, n, m);
        }
    }
    static bool check(string r, string t)
    {
        for (int i = 0; i < 8; i++)
            if (r[i] != '?' && r[i] != t[i]) return false;
        return true;
    }
    static void getAns(string[,] r, int n, int m)
    {
        var oks = new List<string>();
        for (int i = 0; i < m; i++)
        {
            var s = Console.ReadLine().Trim();
            string[] line = s.Split(' ');
            var t1 = line[0];
            var t2 = line[1];
            var ok = false;
            for (int j = 0; j < n; j++)
                if (r[j, 0] == "permit")
                {
                    if (check(r[j, 1], t1) && check(r[j, 2], t2)) ok = true;
                }
                else
                {
                    if (check(r[j, 1], t1) && check(r[j, 2], t2)) ok = false;
                }
            if (ok) oks.Add(s);
        }
        Console.WriteLine(oks.Count());
        var sb = new StringBuilder();
        foreach (var x in oks) sb.Append(string.Format("{0}\n",x));
        Console.Write(sb);
    }
}


Measured memory_bytes: 22684
#include <iostream>
using namespace std;
int main(){
	long long int n;
	long long int sum = 0;
	cin >> n;
	for(long long int i = 1;i <= n;i++){
		if(i % 3 == 0||i % 5 == 0){
			continue;
		}
		sum += i;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int ans=a[n/2]-a[n/2-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	boolean result = false;
	for(int i=0;i<=N/4;i++){
	    if((N-4*i) % 7 == 0){
		result = true;
		break;
	    }
	}
	if(result) System.out.print("Yes");
	else System.out.print("No");
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ///////////////////////////////////////
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  m /= 5;
  if (m != 0) h += 1 / (12 / m);
  double k = min(abs(m - h), 12 - abs(m - h));
  double ans = pow(a, 2) + pow(b, 2) - (2 * a * b * cos(2 * M_PI * k / 12));
  cout << setprecision(20) << sqrt(ans) << endl;
  return 0;
}


Measured memory_bytes: 4152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll maxnum = max(a, max(b, c));
  ll sum = a + b + c;
  if (sum - maxnum == maxnum) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    std::map<char, int> map;
    for (int i=0;i<s.size();i++) {
        map[s[i]]++;
    }
    if (map.size()==1) {
        if (s=="a"||s=="b"||s=="c") {
            cout<<"YES"<<endl;
        } else {
            cout<<"NO"<<endl;
        }
    } else if (map.size()==2) {
        if (s=="ab"||s=="ba"||s=="ac"||s=="ca"||s=="bc"||s=="cb") {
            cout<<"YES"<<endl;
        } else {
            cout<<"NO"<<endl;
        }
    } else {
        if (abs(map['a']-map['b'])<=1&&abs(map['b']-map['c'])<=1&&abs(map['a']-map['c'])<=1) {
            cout<<"YES"<<endl;
        } else {
            cout<<"NO"<<endl;
        }
    }
}

Measured memory_bytes: 3760
(defun make-adjustable-string (s)
  (make-array (length s)
              :fill-pointer (length s)
              :adjustable t
              :initial-contents s
              :element-type (array-element-type s)))

(defun main ()
  (let ((s (read-line)) (res (make-adjustable-string "")))
    (loop :for c :across s :do
          (if (eq c #\B)
            (if (= (length res) 0) 'nil (vector-pop res))
            (vector-push-extend c res)))
    (princ res) (princ #\newline)))

(main)

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

using namespace std;

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

    string s, s2, s3;
    cin >> s >> s2 >> s3;
    cout << s[0] << s2[0] << s3[0];

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

bool check(int a, ll &k) {
    if (a != 0) a = 26-a;
    if (k >= a) {
        k -= a;
        return true;
    }
    else return false;
}

int main(int argc, char const *argv[]) {
    string s;
    ll k;
    cin >> s >> k;
    int n = s.size();
    REP(i,n) {
        if (i == n-1) {
            int tmp = (int)(s[i]+k%26);
            if (tmp > 'a'+25) tmp = tmp-26; 
            s[i] = (char)tmp;
        }
        else if (check((int)s[i]-'a', k)) {
            s[i] = 'a';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int n;
int ans=0;
int a[maxn];
int main()
{

 int n;
 cin>>n;
 for(int i=0;i<n;i++)
    cin>>a[i];
    int flag=1;
    for(int i=n-1;i>=1;i--)
    {
         if(a[i]<a[i-1])
         {
              a[i-1]--;
              if(a[i-1]>a[i])
                flag=0;

         }
    }
    if(flag)
        puts("Yes");
    else
        puts("No");
return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>

using namespace std;

typedef pair<int,int> P;

#define INF 99999999

////グローバル変数のほうがどこからでも参照できて便利 edgeはどうすればいいのか？

int main(void){
	int n,m,ans;
	ans = 0;
	vector<P> edge[110];
	int a[1100],b[1100],c[1100];
	int dist[110];

	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]=a[i]-1,b[i]=b[i]-1;
		edge[a[i]].push_back(P(b[i],c[i]));
		edge[b[i]].push_back(P(a[i],c[i]));
	}
	
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			dist[j] = INF;
		}
		int s = a[i];
		dist[s] = 0;
		priority_queue< P, vector<P> , greater<P> > pq;
		pq.push(P(0,s));

		while(pq.size()>0){
			P tmp;
			tmp = pq.top();
			pq.pop();
			int d = tmp.first;
			int from = tmp.second;

			for(int j=0;j<edge[from].size();j++){
				int to = edge[from][j].first;
				int c = edge[from][j].second;
				if(dist[to]>dist[from]+c){
					dist[to] = dist[from]+c;
					pq.push(P(dist[to],to));
				}
			}
		}
		if(dist[b[i]] < c[i]){
			ans = ans+1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {

  int h, w;
  cin >> h >> w;

  // load matrix
  vector<vector<char>> a(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    string row;
    cin >> row;
    for (int j = 0; j < w; j++)
      a.at(i).at(j) = row[j];
  }

  // check: -> row
  for (int i = 0; i < h; i++) {
    bool is_delete = false;
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '.' || a.at(i).at(j) == '_') {
        is_delete = true;
      } else {
        is_delete = false;
        break;
      }
    }
    // delete: -> row
    if (is_delete) {
      for (int j = 0; j < w; j++)
        a.at(i).at(j) = '_';
    }
  }

  // check: -> col
  for (int j = 0; j < w; j++) {
    bool is_delete = false;
    for (int i = 0; i < h; i++) {
      if (a.at(i).at(j) == '.' || a.at(i).at(j) == '_') {
        is_delete = true;
      } else {
        is_delete = false;
        break;
      }
    }
    // delete: -> col
    if (is_delete) {
      for (int i = 0; i < h; i++)
        a.at(i).at(j) = '_';
    }
  }

  // output
  for (int i = 0; i < h; i++) {
    string buf = "";
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '_')
        continue;
      else
        buf += a.at(i).at(j);
    }
    if (buf.size() > 0) cout << buf << endl;
  }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		while(sc.hasNext()) {
		int x = sc.nextInt();
		if (x == 0)
			break;
		i++;
		System.out.println("Case "+ i + ": " + x);
		}
	}
}	


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

int main(){
    int H, W, D;
    cin >> H >> W >> D;

    int *x = new int[H*W+1];
    int *y = new int[H*W+1];
    int *mp = new int[H*W+1];

    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            int a;
            cin >> a;
            x[a] = i; y[a] = j;
        }
    }
    for(int i=1;i<=H*W;i++){
        if(i<=D) mp[i] = 0;
        else mp[i] = mp[i-D] + abs(x[i] - x[i-D]) + abs(y[i]-y[i-D]);
    }
    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
        int L, R;
        cin >> L >> R;
        int ans = mp[R] - mp[L];
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n <= k)
        cout << n * x << endl;
    else
        cout << k * x + (n - k) * y << endl;
    return 0;
}

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

int main() {
	int X, Y, Z; cin >> X >> Y >> Z;
	X -= Z;
	Y += Z;
	int i = 0;
	while(true){
		X -= Y;
		if( X >= 0 ){
			i++;
		} else {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int count = min(a,k);
  k = max(0,k-a);
  k = max(0,k-b);
  count -= k;
  cout << count << endl;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
const ll mod = 1e9 + 7;
const ll inf = 1e11 + 5;
const int MaxN = 2e5 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int n, x;
	cin >> n >> x;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	for(int i = 0; i < n; i++){
		x-= a[i];
		if(x < 0){
			ans = i;
			break;
		}
		else{
			ans = i + 1;
		}
	}
	if(x > 0){
		ans--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
#include<stack>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

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

int main(void){
  string str;
  while(getline(cin,str),str!="0"){
    int a,b,c;  a = b = c = 0;
    bool one = false;
    int sum = 0;
    for(int i = 0 ; i < str.size() ; i ++){
      if(str[i]==' ')continue;
      //--
      if(str[i] == '1') {
	if(str[i+1] == ' '){
	  one = true;
	  sum ++;
	}else if(str[i+1]=='\0'){
	  one = true;
	  sum ++;
	}else {
	  sum += 10;
	  i++;
	}
      }
      //--

      else{
	sum += str[i] - '0';
      }

    }
    if(one && sum + 10 <= 21) sum += 10;
    //cout<<sum<<endl;
    cout<<(sum<=21?sum:0)<<endl;
  }
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

ll gcd(ll a, ll b){
    if (b == 0) return a;
    else return gcd(b, a % b);
}

bool solve(string s){
    int N = s.size();
    
    for(int i = 0; i < N; i++){
        if (s[i] != s[N-1-i]) return false; 
    }
    
    int first = 0, end = (N - 1) / 2;
    for(int i = 0; i < end; i++){
        if (s[i] != s[end-1-i]) return false; 
    }
    
    first = (N + 3) / 2 - 1 , end = N;
    for(int i = first; i < N; i++){
        if (s[i] != s[end-1-i]) return false; 
    }
    
    return true;
}

int main(void){
    string S; cin >> S;
    
    if (solve(S)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
nega = [a for a in A if a < 0]
A_abs = sorted(abs(a) for a in A)
if len(nega) % 2 == 0:
  ans = sum(A_abs)
else:
  ans = sum(A_abs) - 2 * A_abs[0]
print(ans)

Measured memory_bytes: 14284
import Data.List
import Data.Function

main = print . solve . map read . words =<< getLine

solve :: [Int] -> Int
solve [w,h] = minimum . map (\(a,w',h') -> solve' a w' h') $ [(w'*h,w-w',h) | w' <- [1..w]] ++ [(w*h',w,h-h') | h' <- [1..h]]

solve' a w h = minimum $ map (maximum . map score) [[wa*h,wb*h], [w*ha,w*hb]]
    where
        score = abs . subtract a
        (wa,rw) = w `quotRem` 2
        wb = wa + rw
        (ha,rh) = h `quotRem` 2
        hb = ha + rh


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n; cin >> n;
    int d, x; cin >> d >> x;
    int a[n]; rep(i, n) cin >> a[i];
    int o[d + 1]; fill_n(o, d + 1, 0);
    int sum = 0;
    rep(i, n) {
        int tmp = 0;
        while (tmp * a[i] + 1 <= d) { o[tmp * a[i] + 1]++; tmp++; sum++; }
    }
    out(sum + x);
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int a, b, s, l;
    cin >> a >> b;
    s = a * b;
    l = (a + b) * 2;
    cout << s << " " << l << endl;
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>

bool judge(int x) {
    for (int i = 2; i < x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    int X = 0;
    std::cin >> X;
    if (judge(X)) {
        std::cout << X << '\n';

    } else {
        while (true) {
            if (judge(++X)) break;
        }
        std::cout << X << '\n';

    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
	int n,x;
	int count=0;

	while(1){
		count=0;
		scanf("%d %d",&n,&x);
		if(n==0 && x==0){
			break;
		}

		for(int i=1;i<=n;i++){
			for(int j=(i+1);j<=n;j++){
				for(int k=(j+1);k<=n;k++){
					if((i+j+k)==x){
						count++;
					}
				}
			}
		}
		printf("%d\n",count);
	}

	
	

	return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=INF,a,b,c,cmp,cmpp,data,m,h,w,x,y,xcmp,ycmp,sum=0,A,B,C,W,H;

string s;

vector<int> z;

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

       cin >> h >> w;
       if(h%3==0 || w%3==0){
           Cout(0);
           return 0;
       }
       x=min(h,w);
       rrep(hh,1,h){
           W=w/2;
           A=hh*w;
           B=(h-hh)*W;
           C=(h-hh)*(w-W);
           cmp=min(min(A,B),C);
           cmpp=max(max(A,B),C);
           x=min(x,cmpp-cmp);
       }
     // cmp=0;
      // cmpp=0;
        rrep(ww,1,w){
            H=h/2;
           A=ww*h;
           B=(w-ww)*H;
           C=(w-ww)*(h-H);
           cmp=min(min(A,B),C);
           cmpp=max(max(A,B),C);
           x=min(x,cmpp-cmp);
       }
       
       Cout(x);
return 0;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;
	int n; cin >> n;
	string c; cin >> c;

	int a=0, b=n-1;
	while(c[a]=='R' && a<n) a++;
	while(c[b]=='W' && b) b--;
	int ans = 0;
	while(a<b){
		ans++;
		a++; b--;
		while(a<n&&c[a]=='R') a++;
		while(b&&c[b]=='W') b--;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

string s;

int main(){
    cin >> s;
    char now = s[0];
    int ans = s.length(), mem, n = s.length();

    for(int i = 1; i < n; i++){
        if(s[i] != s[i-1]){
            mem = max(i, n-i);
            ans = min(ans, mem);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long sq(long long X) {
    long long l = 0, h = X;
    while (h - l > 1) {
        long long m = (l+h)/2;
        if (m*m <= X) {
            l = m;
        }
        else {
            h = m;
        }
    }
    return l;
}
int main () {
    int N;
    cin >> N;
    long long C = sq(1+8*N);
    if (C*C != 1+8*N || ((C-1) & 1)) {
        puts("No");
        return 0;
    }
    long long k = (C-1) / 2;
    puts("Yes");
    cout << k+1 << endl;
    vector<vector<int>> S(k+1);
    int x = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 1; j <= k-i; j++) {
            x++;
            S[i].push_back(x);
            S[i+j].push_back(x);
        }
    }
    for (int i = 0; i <= k; i++) {
        cout << k;
        for (auto s: S[i]) {
            cout << " " << s;
        }
        cout << endl;
    }
}

Measured memory_bytes: 2304
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 1234567
int n; ll f[SZ],qzh[SZ],MOD=1e9+7;
int main()
{
	scanf("%d",&n);
	f[1]=qzh[1]=n;
	for(int i=2;i<=n;i++)
	{
		f[i]=f[i-1]+(ll)(n-1)*(n-1);
		f[i]+=(i>=3?qzh[i-3]:0);
		f[i]+=n-max(i-1,2)+1;
		f[i]%=MOD; qzh[i]=(qzh[i-1]+f[i])%MOD;
	}
	ll ans=f[n];
	ans=(ans%MOD+MOD)%MOD;
	printf("%d\n",int(ans));
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((a+b) > (c+d)){
    cout << "Left" << endl;
  } else if ((a+b) == (c+d)) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}
    

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

int h, w;
string s[50];
int d[50][50];
bool b[50][50];

int v[][2] = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };

void dfs(int x, int y) {
	for (int i = 0, nx, ny; i < 4; i++) {
		nx = x + v[i][0], ny = y + v[i][1];
		if (nx < 0 || nx >= h || ny < 0 || ny >= w || s[nx][ny] == '#')
			continue;
		if (d[nx][ny] > d[x][y] + 1) {
			d[nx][ny] = d[x][y] + 1;
			dfs(nx, ny);
		}
	}
}

int main() {
	fill(d[0], d[50], 250);
	cin >> h >> w;
	int black = 0;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#')
				black++;
		}
	}

	d[0][0] = 0;
	dfs(0, 0);
	int ans =
			d[h - 1][w - 1] != 250 ? h * w - black - (d[h - 1][w - 1] + 1) : -1;
	cout << ans << endl;

}


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

#define _GLIBCXX_DEBAC
using namespace std;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c <= 21) {
		cout << "win";
	}
	else {
		cout << "bust";
	}
		return 0;
}









Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = 0;
	
	void doIt() {
		 int r = sc.nextInt();
		 System.out.println(r * r);
			
		
		
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
			
			int max;
			int min;
			
			if (A < B) {
				max = A;
			} else {
				max = B;
			}
			
			if (N - (A + B) > 0) {
				min = 0;
			} else {
				min = (A + B) - N;
			}
			System.out.println(max + " " + min);		
		}
		
	}

}

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

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

  // ここにプログラムを追記
  int A, cnt, min = 100000000;
  for(int i=0; i<N; i++) {
    cin >> A;
    cnt = 0;
    while(A > 0) {
      if(A%2==1) {
        break;
      }
      cnt++;
      A /= 2;
    }
    if(min > cnt && A%2==1) {
      min = cnt;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 3576
#include<stdio.h>
int main(void)
{
	int x,i,j,a[5];
	for(i=0;i<5;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<5;i++) {
		for(j=0;j<5;j++){
			if(a[i]>=a[j]) {
				x=a[j];
				a[j]=a[i];
				a[i]=x;
			}
		}
	}
	printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
	return 0;
}	
		
		
		
		
		
		


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

template< typename T >
struct Dinic {
  struct edge {
    int to;
    T cap;
    int rev;
  };

  const T INF;
  vector< vector< edge > > graph;
  vector< T > min_cost;
  vector< int > iter;

  Dinic(int n) : INF(numeric_limits< T >::max()) {
    graph.resize(n);
  }

  void add_edge(int from, int to, T cap) {
    graph[from].push_back((edge) {to, cap, (int) graph[to].size()});
    graph[to].push_back((edge) {from, 0, (int) graph[from].size() - 1});
  }

  bool bfs(int s, int t) {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return (min_cost[t] != -1);
  }

  T dfs(int idx, const int t, T flow) {
    if(idx == t) return (flow);
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        T d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return (d);
        }
      }
    }
    return (0);
  }

  T max_flow(int s, int t) {
    T flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      T f = 0;
      while((f = dfs(s, t, INF)) > 0) {
        flow += f;
      }
    }
    return (flow);
  }
};

int main() {
  int H, W;
  string S[25];

  int ret = 0;

  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> S[i];
  }

  Dinic< int > flow((H * W) * 3 + 2);
  int ptr = H * W;
  int s = (H * W) * 3, t = (H * W) * 3 + 1;

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(S[i][j] == '#') {
        int u = i * W + j;
        ++ret;
        if(i && S[i - 1][j] == '#') {
          int v = u - W;
          flow.add_edge(s, ptr, 1);
          flow.add_edge(ptr, u, flow.INF);
          flow.add_edge(ptr, v, flow.INF);
          ++ptr;
          --ret;
        }

        if(j && S[i][j - 1] == '#') {
          int v = u - 1;
          flow.add_edge(u, ptr, flow.INF);
          flow.add_edge(v, ptr, flow.INF);
          flow.add_edge(ptr, t, 1);
          ++ptr;
          --ret;
        }
      }
    }
  }
  cout << flow.max_flow(s, t) + ret << endl;
}



Measured memory_bytes: 3320
import java.util.*;

// ABC 27-C
// http://abc027.contest.atcoder.jp/tasks/abc027_c
 
public class Main {
	
	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int t = in.nextInt();
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			nums[i] = in.nextInt();
		}
		
		boolean isSwitchOn = false;
		long switchOnFrom = 0;
		long switchGoesOffAt = 0;
		long answer = 0;
		
		for (int i = 0; i < n; i++) {
			if (switchGoesOffAt < nums[i]) {
				isSwitchOn = false;
				answer += switchGoesOffAt - switchOnFrom;
			}
			if (isSwitchOn) {
				switchGoesOffAt = nums[i] + t;
			} else {
				switchOnFrom = nums[i];
				switchGoesOffAt = nums[i] + t;
				isSwitchOn = true;
			}
		}
		
		if (isSwitchOn) {
			answer += switchGoesOffAt - switchOnFrom;
		}
		
		System.out.println(answer);
	}
}

Measured memory_bytes: 62548