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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int sx, sy, tx, ty;

	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	tx -= sx;
	ty -= sy;
	for(int i=0; i < 4; i++) {
        if(i==2){
            tx++;   ty++;
        }
		if(i >= 2)
			printf((i%2) ? "U" : "D");
		for(int j=0; j < tx; j++) {
			printf((i%2) ? "L" : "R");
		}
		for(int j=0; j < ty; j++) {
			printf((i%2) ? "D" : "U");
		}
		if(i >= 2)
			printf((i%2) ? "R" : "L");
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s, t;
	int n, z = 0, ans = 0, jud;
	cin >> s >> n;
	for (int i = 0; i<n; i++){
		cin >> t;
		t += t;
		for (int j = 0; j < t.size(); j++){
			if (s[0] == t[j]){
				for (int k = 1; k < s.size(); k++){
					if (s[k] != t[j + k]){
						jud = -1;
						break;
					}
				}
				if (jud == 0){
					ans++;
					break;
				}
				jud = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    string s;
    cin>>s;
    int i=1,ans=1;
    bool d=false;
    while(i<s.size()){
        if(d){
            ++ans;
            ++i;
            d=false;
        }
        else if(s[i-1]!=s[i]){
            ++ans;
            ++i;
            d=false;
        }
        else{
            if(i==s.size()-1){
                break;
            }
            ++ans;
            i+=2;
            d=true;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
def fct(i):
    if i==0:
        return 1
    return i*fct(i-1)

from itertools import permutations

n = int(input())
x = []
y = []
for i in range(n):
    X, Y = [int(i) for i in input().split()]
    x.append(X)
    y.append(Y)

perms = list(permutations([i for i in range(n)]))


num = 0

def dist(ax, ay, bx, by):
    return ((ax-bx)**2 + (ay-by)**2)**0.5

def solve(curperm):
    distance = 0
    for coord in range(1, len(curperm)):
        distance += dist(x[curperm[coord-1]], y[curperm[coord-1]], x[curperm[coord]], y[curperm[coord]])
    #print(distance, curperm)
    return distance

for curperm in perms:
    #print(curperm, solve(curperm))
    num += solve(curperm)
print(num/fct(n))


Measured memory_bytes: 8180
;; F - Silver Fox vs Monster

(defun solve (d a xh)
  (loop
    with accum = 0  ; 破壊済みの体力
    with head = xh  ; 尺取法の区間の先頭
    for pair in xh
    for (x . h) = pair  ; 最左モンスターのX座標と体力
     do (loop while (< (caar head) (- x d d))
           do (decf accum (* a (ceiling (cdar head) a)))
              (setf head (cdr head)))
        (decf h (min h accum))
        (setf (cdr pair) h)
        (incf accum (* a (ceiling h a)))
    sum (ceiling h a)))

(let* ((n (read))
       (d (read))
       (a (read))
       (xh (loop repeat n collect (cons (read) (read)))))
  (setf xh (sort xh #'< :key #'car))
  (princ (solve d a xh)))


Measured memory_bytes: 75364
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
 
int main()
{
  int a, b;
  cin >> a;
  cout << (a * 800) - (a / 15 * 200) << endl;
  return 0;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(LLI i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380




int main()
{
	cout << fixed << setprecision(10);
	LLI n;
	cin >> n;
	LLI sum = 0;
	FOR(i, 1, n + 1)
	{
		if (i % 3 == 0 || i % 5 == 0)continue;
		sum += i;
	}
	cout << sum;
	return 0;
}

// 9

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, d;
	scanf("%d%d", &n, &d);
	// (a + (b - 1)) / b 切り上げ
	int ans = (n + d * 2) / (2 * d + 1);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3792
#include<stdio.h>
main()
{
	int n,sum=0,temp,j,i,k,t[100000],m,p[100],x[100];
	scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    	scanf("%d",&t[i]);
	}
	scanf("%d",&m);
	for(i=0;i<m;i++)
    {
    	scanf("%d %d",&p[i],&x[i]);
	}
	for(j=0;j<m;j++)
	{
		for(i=0;i<n;i++)
    	{
    		k = p[j];
    		temp = t[k-1];
			t[k-1] = x[j];
			break ;
		}
		for(i=0;i<n;i++)
        {
        	sum = sum+t[i];
	    }
	    printf("%d\n",sum);
	    sum = 0;
	    t[k-1] = temp;  
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

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


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

struct edge{
    int cost, to;

    edge(int in_cost, int in_to){
        cost=in_cost;
        to=in_to;
    }
    bool operator<(const edge &a) const
    {
        return cost > a.cost;
    }
};

int main() {
    ll K;
    int N;
    string S;
    cin >> N;
    cin >> S;
    cin >> K;
    K--;

    char base=S[K];

    rep(i,N){
        if(S[i]==base)
            cout<< S[i];
        else
            cout << '*';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():

    X, Y = map(int, input().split())

    if Y % 2 == 0 and X * 2 <= Y and Y <= X * 4:
        ans = 'Yes'

    else:
        ans = 'No'

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9116
N = int(input())
S = input()
state = 0
ans = 0

def isABC(s):
    global state
    if state==0:
        if s=="A":
            state = 1
        return 0
    elif state==1:
        if s=="B":
            state = 2
        elif s=="A":
            state=1
        else:
            state=0
        return 0
    else:
        if s=="C":
            state=0
            return 1
        elif s=="A":
            state=1
            return 0
        else:
            state=0
            return 0

for i in S:
    ans += isABC(i)
print(ans)
    

Measured memory_bytes: 3064
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    cout << n * (n-1) / 2 + m * (m-1) / 2;
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    for (int i=0;i<s.size();++i){
        if (i%2==0){
            if (s[i]!='R' && s[i]!='U' && s[i]!='D'){
                cout<<"No";
                return 0;
            }
        }
        else{
            if (s[i]!='L' && s[i]!='U' && s[i]!='D'){
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
}

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

const ll mod = 1e9 + 7;

int main() {
    ll n, ans, l, r;
    string s;
    cin >> n >> s;
    if (s[0] == 'W') {
        cout << 0 << endl;
        return 0;
    }
    ans = 1;
    l = 1, r = 2 * n - 1;
    for (int i = 1; i < 2 * n; i++) {
        if (s[i] == 'B') {
            if (l % 2) {
                ans = (ans * l) % mod;
                l--;
            } else {
                l++;
            }
        } else {
            if (l % 2) {
                l++;
            } else {
                ans = (ans * l) % mod;
                l--;
            }
        }
        r--;
    }
    if (l != 0 || r != 0) {
        cout << 0 << endl;
        return 0;
    }
    for (ll i = n; i >= 1; i--) {
        ans = ans * i % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (9e18)
#define EPS (1e-6)
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
void INIT(){
	ios::sync_with_stdio(false); cin.tie(0);
}

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	ll n,k; cin>>n>>k;
	ll kk=(k*(k-1)/2)%MOD;
	vector<ll> v(n),inv(n,0),small(n,0);
	for(auto &i:v) cin>>i;
	For(i,0,n-1) For(j,0,n-1) if(i!=j){
		if(i<j && v[i]>v[j]) inv[i]++;
		if(v[i]>v[j]) small[i]++;
	}
	ll ans=0;
	For(i,0,n-1){
		ans=(ans+kk*small[i]%MOD+k*inv[i]%MOD)%MOD;
	}
	cout<<ans<<"\n";
	return 0;
}






















Measured memory_bytes: 384
#include "iostream"
#include "cstring"
#include "cstdlib"
#include "cstdio"
#define N 100000
using namespace std;




int main()
{
    int n;
	while(cin>>n)
    {
    	int sk[N],tp=0;
		while(n)
		{
	        int k=n%-2;
	        int t=n/-2;
	        if (k<0)
			{
	            k+=2;
	            t++;
	        }
	        n=t;
	        sk[++tp]=k;
    	}
    	for (int i=tp;i>=1;i--)
     	   cout<<sk[i];
     	cout<<endl;
    	if (tp==0) 
			cout<<0<<endl;

    	

	}
    
    return 0;

} 

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
#include<array>
#include<cstring>
#include<numeric>
#include<string>
#include<set>
#include<cstdio>
#include<cmath>
#include<unordered_map>
#include<bitset>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
   
    ll a,b,x;
    cin>>a>>b>>x;
    ll res;
    if(a==0) res = (b/x) + 1;
    else res = (b/x) - ((a-1)/x);
    cout<<res<<"\n";
    return 0;
}


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

for i in range(n):
    if a[i] % 2 == 0:
        if not ((a[i] % 3 == 0) | (a[i] % 5 == 0)):
            print('DENIED')
            break
else:
    print('APPROVED')

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

signed main() {
    int n, m;
    cin >> n >> m;
    for (int i = m - n + 1; i <= m + n - 1; i++)
        cout << i << ' ';

#ifdef LOCAL
    cout << endl;
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 256
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;
	cin >> N;
	ll L[N];
	for (ll i = 0; i < N; ++i) cin >> L[i];
 
	// 解法
	ll sum = 0;
	ll max = 0;
	REP(i,N){
		if (L[i]>max) max = L[i];
		sum += L[i];
	}
	ll ans = true;
	if (max>=sum-max) ans = false;
	
	//出力
	if (ans) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int n, m, p;
int main() {
    init();

    cin >> n >> m >> p;
    VI d(m);
    FOR(i, 0, m) {
        cin >> d[i];
        d[i] = (d[i] - p + n) % n;
    }

    SORT(d);
    int ans = min(n - d[0], d[m - 1]);
    FOR(i, 0, m - 1)chmin(ans, d[i] + n - d[i + 1] + min(d[i], n - d[i + 1]));
    cout << 100 * ans << "\n";
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
    int s;
    cin >> s;
    int m = s / 60;
    int h = m / 60;
    s %= 60, m %= 60;
    cout << h << ':' << m << ':' << s << endl;
}


Measured memory_bytes: 3084
import java.io.IOException;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		h = scanner.nextInt();
		w = scanner.nextInt();
		n = scanner.nextInt();
		num = new Point[n + 1];
		map = new boolean[h][w];
		for (int i = 0; i < h; i++) {
			char[] chs = scanner.next().toCharArray();
			for (int j = 0; j < w; j++) {
				if (chs[j] == '.')
					continue;
				else if (chs[j] == 'X')
					map[i][j] = true;
				else if (chs[j] == 'S')
					num[0] = new Point(i, j);
				else
					num[chs[j] - '0'] = new Point(i, j);
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += slove(num[i].y, num[i].x, num[i + 1].y, num[i + 1].x);
		}
		System.out.println(ans);
	}

	private int slove(int sy, int sx, int gy, int gx) {
		PriorityQueue<Point> pq = new PriorityQueue<Point>();
		int md = getMd(sy, sx, gy, gx);
		pq.offer(new Point(sy, sx, 0, md));
		boolean[][] tmpmap = new boolean[h][w];
		while (!pq.isEmpty()) {
			Point p = pq.poll();
			if (p.y == gy && p.x == gx) {
				return p.step;
			}
			if (tmpmap[p.y][p.x])
				continue;
			tmpmap[p.y][p.x] = true;
			for (int[] m : move) {
				int ny = p.y + m[0];
				int nx = p.x + m[1];
				if (!isOK(ny, nx))
					continue;
				if(map[ny][nx])
					continue;
				int nstep = p.step + 1;
				int nmd = getMd(ny, nx, gy, gx) + nstep;
				pq.offer(new Point(ny, nx, nstep, nmd));

			}
		}
		return -1;
	}

	private boolean isOK(int ny, int nx) {
		if (0 <= ny && ny < h && 0 <= nx && nx < w)
			return true;
		return false;
	}

	private int getMd(int y1, int x1, int y2, int x2) {
		return Math.abs(y1 - y2) + Math.abs(x1 - x2);
	}

	int h, w, n;
	Point[] num;
	boolean[][] map;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	class Point implements Comparable<Point> {
		int y, x, step, md;

		@Override
		public String toString() {
			return "Point [y=" + y + ", x=" + x + ", step=" + step + ", md="
					+ md + "]";
		}

		public Point(int y, int x, int step, int md) {
			super();
			this.y = y;
			this.x = x;
			this.step = step;
			this.md = md;
		}

		public Point(int y, int x) {
			super();
			this.y = y;
			this.x = x;
		}

		@Override
		public int compareTo(Point o) {
			if (md == o.md)
				return o.step - this.step;
			return this.md - o.md;
		}

	}
}

Measured memory_bytes: 93152
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();

		Stack<Integer> iStack = new Stack<Integer>();

		ArrayList<Integer[]> wStack = new ArrayList<Integer[]>();

		for (int i = 0; i < line.length(); i++) {
			String X = line.substring(i, i + 1);

			if (X.equals("\\")) {
				iStack.push(i);
			} else if (X.equals("/") && !iStack.empty()) {
				int Y = iStack.pop();
				Integer[] in = {Y, i - Y };
				
				for (int j = 0; j < wStack.size(); j++) {
					Integer[] kari = wStack.get(j);
					if (in[0] < kari[0]) {
						in[1] += kari[1];
						wStack.remove(j);
						j--;
					}
				}
				
				wStack.add(in);
			}

		}
		
		int bigsum = 0;

		for (int i = 0; i < wStack.size(); i++) {
			bigsum += wStack.get(i)[1];
		}
		System.out.println(bigsum);
		
		if (wStack.isEmpty()) {
			System.out.println(0);
		} else {
			System.out.print(wStack.size());
			System.out.print(" ");
			
			for (int i = 0; i < wStack.size() - 1; i++) {
				System.out.print(wStack.get(i)[1]);
				System.out.print(" ");
			}
			System.out.println(wStack.get(wStack.size() - 1)[1]);

		}
	}
}

Measured memory_bytes: 32812
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        //入力
        int[] dice = new int[6];
        for(int i = 0; i < dice.length; i++){
            dice[i] = sc.nextInt();
        }
        
        //初期化
        int[] saveDice = new int[dice.length];
        for(int i : saveDice){
            saveDice[i] = 0;
        }
        DiceRoll dr = new DiceRoll(dice, saveDice);
        
        //命令
        String orderWriting = sc.next();
        char[] cutOffOrder = orderWriting.toCharArray();
        for(int i = 0; i < cutOffOrder.length; i++){
            if(cutOffOrder[i] == 'N') dr.rollNorthDice();   //Nが入力されたとき
            if(cutOffOrder[i] == 'S') dr.rollSouthDice();   //Sが入力されたとき
            if(cutOffOrder[i] == 'E') dr.rollEastDice();    //Eが入力されたとき
            if(cutOffOrder[i] == 'W') dr.rollWestDice();    //Wが入力されたとき
        }
        System.out.println(dr.rollOutput());
    }
}

class DiceRoll{
    int[] dice;
    int[] saveDice;
    public DiceRoll(int[] dice, int[] saveDice){
        this.saveDice = saveDice;
        this.dice = dice;
    }
    
    public void rollNorthDice(){
        saveDice[0] = dice[1];
        saveDice[1] = dice[5];
        saveDice[2] = dice[2];
        saveDice[3] = dice[3];
        saveDice[4] = dice[0];
        saveDice[5] = dice[4];
        replaceIndex(saveDice, dice);
    }
    
    public void rollSouthDice(){
        saveDice[0] = dice[4];
        saveDice[1] = dice[0];
        saveDice[2] = dice[2];
        saveDice[3] = dice[3];
        saveDice[4] = dice[5];
        saveDice[5] = dice[1];
        replaceIndex(saveDice, dice);
    }
    
    public void rollEastDice(){
        saveDice[0] = dice[3];
        saveDice[1] = dice[1];
        saveDice[2] = dice[0];
        saveDice[3] = dice[5];
        saveDice[4] = dice[4];
        saveDice[5] = dice[2];
        replaceIndex(saveDice, dice);
    }
    
    public void rollWestDice(){
        saveDice[0] = dice[2];
        saveDice[1] = dice[1];
        saveDice[2] = dice[5];
        saveDice[3] = dice[0];
        saveDice[4] = dice[4];
        saveDice[5] = dice[3];
        replaceIndex(saveDice, dice);
    }
    
    public int rollOutput(){
        return dice[0];
    }
    
    private void replaceIndex(int[] saveDice, int[] dice){
        for(int i = 0; i < saveDice.length; i++){
            dice[i] = saveDice[i];
        }
    }
}


Measured memory_bytes: 26424
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using pint = pair<int, int>;

const int INF = 1e9;

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  pint ans = pint(INF, INF);
  rep(i, 102) {
    bool find = false;
    rep(j, n) {
      if (p[j] == i) {
        find = true;
        break;
      }
    }
    if (find) continue;
    int diff = abs(x - i);
    if (ans.second > diff) ans = pint(i, diff);
  }

  cout << ans.first << endl;

  return 0;
}


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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)

// a^k mod p
int modpow(int a, int k, int p){
    int ans = 1;
    while (k > 0){
        if (k % 2 == 1){
            ans *= a;
            ans %= p;
        }
        a = (a*a) % p;
        k = k / 2;
    }
    return ans;
}

void solve(){
    int N;
    cin >> N;
    string X;
    cin >> X;
    int p=0;
    rep(i,N) if(X[i]=='1') p++;
    
    // p+1になるケース：0->1に反転
    int rem_plus = 0;
    rep(i,N){
        if(X[i]=='1') rem_plus = (rem_plus*2+1)%(p+1);
        else rem_plus=(rem_plus*2)%(p+1);
    }
    // p-1
    int rem_minus = 0;
    if(p>1){
    rep(i,N){
        if(X[i]=='1') rem_minus = (rem_minus*2+1)%(p-1);
        else rem_minus=(rem_minus*2)%(p-1);
    }
    }
    
    rep(i,N){
        int n;
        int ans = 1;
        if(X[i]=='0'){ n = (rem_plus + modpow(2,N-i-1,p+1))%(p+1); }
        else{
            if(p==1){ cout << 0 << endl; continue;}
            else
                n=(rem_minus +(p-1 )- modpow(2,N-i-1,p-1))%(p-1);
        }
        while(n>0){
            n %= __builtin_popcountll(n);
            ans++;
        }
        cout << ans << endl;
    }

    
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S;
    cin >> N >> S;
    ll x = 0;
    ll ans = 0;
    rep(i,0,N){
        if(S[i] == 'I'){
            x++;
        }else{
            x--;
        }
        ans = max(ans,x);
    }
    print(ans);
}


Measured memory_bytes: 256
# coding:utf-8
# 調理時間の入力
cooking_time = [int(input()) for i in range(5)]
# 注文が10の倍数の時間にならないとできないので、料理ができてから注文可能になるまでの時間を出す
# 料理ができてから注文可能時間が早く来る順にする
cooking_time = sorted(cooking_time, key=lambda x: (x-1)%10, reverse=True)
#print(cooking_time)
ans = 0

for i , cooking_time in enumerate(cooking_time):
    # 1品目から4品目まで
    if i < 4:
        if cooking_time%10 != 0:
            #調理時間と注文待ち時間が加算される
            ans += cooking_time + (10-cooking_time%10)
        else:
            ans += cooking_time
    # 5品目
    else:
        ans += cooking_time

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n) {
        if(a[i] == cnt + 1) {
            cnt++;
        }
    }
    if(cnt == 0) {
        cout << -1 << endl;
    } else {
        cout << n - cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

int n, k;

int a[100010];

int main(){

  n = in();
  k = in();
  REP(i, n){
    a[i] = in();
  }

  int ans = (n-1 + (k-2)) / (k-1);

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


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

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

using namespace std;

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

    int n,sum=0,ans=0;
    cin >> n;
    string b[n],s;
    int a[n]={0};
    map<string, int> memo;

    rep(i,n){
        cin >> s;  
        memo[s] += 1;      
    }

    int max=0;
    for(auto p : memo){
        if(p.second > max) max = p.second;
    }
    for(auto p : memo){
        if(p.second == max){
            cout << p.first << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 26240
#include<stdio.h>

int main(){
	int a;
	bool b=false;
	scanf("%d",&a);
	for(int c=0;c*4<=a;c++){
		if((a-c*4)%7==0){
			b=true;
			break;
		}
	}
	if(b==true)
	printf("Yes");
	else
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
a,v=list(map(int,input().split()))
b,w=list(map(int,input().split()))
n=int(input())

if a<=b:
  if (a+v*n)>=(b+w*n):
    print("YES")
  else:
    print("NO")
if a>b:
  if (a-v*n)<=(b-w*n):
    print("YES")
  else:
    print("NO")
    

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }  
  vector<bool> vis(n);
  function<int(int)> dfs = [&](int source) {
    int res = 0;  
    vis[source] = true;
    for (int to : adj[source]) {
      if (!vis[to]) {
        res += dfs(to);
      }
    }
    return 1 + res;
  };
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      res = max(res, dfs(i));
    }
  }
  cout << res << '\n';
  return 0;
}

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

a.sort()

tmp_val = 0
pair_val = 0
for i in range(n-1, -1, -1):
  if tmp_val == a[i]:
    if pair_val != 0:
      print(pair_val * a[i])
      exit()
    else:
      pair_val = a[i]
      tmp_val = 0
  else:
    tmp_val = a[i]

print(0)

Measured memory_bytes: 14244
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int main () {
    int n;
    cin >> n;
    int ans = 0;

    for (int i = 1 ; i <= n ; ++ i) {
        int x;
        scanf("%d", &x);
        if (i % 2 && x % 2) ++ ans;
    }

    cout << ans;
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,a,b) for(auto (i)=(a);(i)<(b);(i)++)
#define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--)
#define num_check(x) '0'<=(x)&&(x)<='9'


struct Siki{
	int num;
	int depth;
	char type;
	int left, right;

};

int pri[10];//各演算子の計算順序
int min_pri[6];//各演算子のdepthごとの計算順序の最低値、これを破るとNG
Siki siki[12];
Siki temp[12];//作業用配列
int s_size;
string input;
map<int, int> data;

bool check_pri(){
	rep(i, 0, s_size){
		if (min_pri[siki[pri[i]].depth] > i)
			return(false);
	}
	return(true);
}

void init(){
	//初期化
	data.clear();
	rep(i, 0, 12)siki[i].num = 0;
	rep(i, 0, 6)min_pri[i] = 0;
	int d = 0; 
	s_size = 0;
	
	//入力を作業用に変換
	rep(i, 0u, input.length()){
		if (num_check(input[i])){
			siki[s_size].num *= 10;
			siki[s_size].num += input[i] - '0';
		}
		else if (input[i] == '(')d++;//()の中に入るので深さを増加
		else if (input[i] == ')')d--;//深さを減少
		else
		{
			siki[s_size].type = input[i];
			siki[s_size].depth = d;
			pri[s_size] = s_size;
			rep(j, d + 1, 6)
				min_pri[j]++;
			s_size++;
		}
	}
	siki[s_size].type = '\0';//終端記号
	rep(i, 0, s_size){
		//連結リスト構造の作成
		siki[i].right = i+1;
		siki[i + 1].left = i;
	}
	siki[0].left = siki[s_size].right = -1;//左端、右端の保護
	
}

//2項計算する関数
int calc(int l, char op, int r){
	switch (op){
	case '+':return(l + r);
	case '-':return(l - r);
	case '*':return(l * r);
	case '/':return(l / r);
	}
	return(0);
}


void parse(){
	Siki *p,*r,*l;
	rep(i, 0, s_size+1)temp[i] = siki[i];//作業用配列にコピー
	rev(i, 0, s_size){
		p = &temp[pri[i]];
		l = &temp[p->left];
		r = &temp[p->right];

		if (r->num == 0 && p->type == '/')return;//0除算を省く
		//printf("%d%c%d=", p->num, p->type, r->num);
		r->num = calc(p->num, p->type, r->num);
		//printf("%d\n", r->num);
		r->left = p->left;
		if (p->left >=0 )l->right = p->right;

	}
	//cout << temp[s_size].num << endl;
	data[temp[s_size].num]++;
}

//順列を効率的に列挙するための関数
void p(int d, int dm){
	if (d == dm){
		if (check_pri()){
			parse();
		}
	}
	rep(i, d, dm){
		swap(pri[d], pri[i]);
		p(d + 1, dm);
		swap(pri[d], pri[i]);
	}
}

int main(void){
	while (true){
		cin >> input;
		if (input[0] == '#')break;
		init();
		/*	
		rep(i, 0, siki_size)if (siki[i].type == 'c')printf("%d", siki[i].num); else printf("%c", siki[i].type); cout << endl;
		rep(i, 0, op_size)printf("%c", siki[index[i]].type); cout << endl;
		rep(i, 0, op_size)printf("%d", min_pri[siki[index[i]].num]); cout << endl;
		*/
		p(0, s_size);
		cout << data.size() << endl;
	}
	return(0);
}

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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if ( a * b % 2 == 0 ) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main(){
  LL A, B, C;
  cin >> A >> B >> C;
  LL l = A * B * 4;
  LL r = C - A - B;
  if(r > 0) {
    r = r * r;
  }
  cout << (l < r ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int lw = 0, rr = count(begin(s), end(s), 'R'), res = rr;
    for (int i = 0; i < n; ++i)
    {
        if (s[i] == 'R')
            --rr;
        else
            ++lw;
        res = min(res, max(lw, rr));
    }
    cout << res;
}

Measured memory_bytes: 3764
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

tx = 0
ty = 0
tt = 0

for i in range(n):
    dx = abs(ab[i][1] - tx)
    dy = abs(ab[i][2] - ty)
    dt = ab[i][0] -tt
    dd = dt- (dx+dy)
    if dd % 2 ==0 and dd>=0:
        tx = ab[i][1]
        ty = ab[i][2]
        tt = ab[i][0]

    else:
        print("No")
        exit()

print("Yes")    

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

using namespace std;
using ll = long long;

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

  int n, k;
  cin >> n >> k;

  vector<int> a(n, 0);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int aa;
      cin >> aa;
      aa--;
      a[aa]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
	int a[5];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	int k;
	cin >> k;
	bool ans=false;
	bool flag = false;
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			if (i > j)continue;
			if (a[j] - a[i] > k) {
				flag = true;
				break;
			}
		}

		if (flag)break;

		if (i == 4) {
			ans = true;
		}

	}

	if (ans == false) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}

	return 0;
}

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

vector<int> level(100001),comp(100001);

int getComp(int i){
  if(comp[i] != i) comp[i] = getComp(comp[i]);
  return comp[i];
}

void merge(int a,int b){
  a = getComp(a);
  b = getComp(b);
  if(level[a] > level[b]) swap(a,b);
  else if(level[a] == level[b]) ++level[b];
  comp[a] = b;
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m,x,y,z;
  cin >> n >> m;
  iota(begin(comp),end(comp),0);
  while(m--){
    cin >> x >> y >> z;
    merge(x,y);
  }
  set<int> st;
  for(int i = 1; i <= n; ++i) st.insert(getComp(i));
  cout << st.size();
  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
using namespace std;
int main(){
	int val[3];
	for(int i=0;i<3;i++)cin>>val[i];
	int ans=0;
    int max_val=0;
    int max_index;
    for(int i=0;i<3;i++){
    	if(val[i]>max_val){
    		max_val=val[i];
    		max_index=i;
    	}
    }
    for(int i=0;i<3;i++){
    	if(i==max_index)ans+=10*val[i];
    	else ans+=val[i];
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

#define ll long long
#define ld long double
#define v vector

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(x), x.begin()

#define endl '\n'
const string YES = "Yes";
const string NO = "No";

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

bool solve(string S, string T) {
    T.pop_back();
    if (S == T) return true;
    else return false;
}

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

    string S, T;
    cin >> S >> T;

    auto ans = solve(S, T);
    cout << (ans ? YES : NO) << endl;

    return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		for(int i = 0 ; i < n ; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		int start;
		int end;
		if(d.length % 2 == 0) {
			start = d[d.length / 2 - 1];
			end = d[d.length / 2];
		} else {
			start = d[d.length / 2];
			end = d[d.length / 2 + 1];
		}
		System.out.println(end - start);
		sc.close();

	}

}


Measured memory_bytes: 50840
n,m,k=map(int,input().split())
def root(x):
    while par[x]>=0:x=par[x]
    return x
def unite(x,y):
    x,y=root(x),root(y)
    if x!=y:
        if x>y:x,y=y,x
        par[x]+=par[y]
        par[y]=x
par=[-1]*n
def same(x,y):
    return root(x)==root(y)
def size(x):
  return-par[root(x)]
g=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    unite(a,b)
    g[a].append(b)
    g[b].append(a)
ss=[size(i)-len(g[i])-1 for i in range(n)]
for  i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if same(c,d):
        ss[c]-=1
        ss[d]-=1
print(*ss)

Measured memory_bytes: 84256
#include<bits/stdc++.h>
    using namespace std;
    int main(){

   int n,flag=0; cin >>n;

   for (int i = 1; i < 10; ++i)
   {
     int div = n/i;
     if (n%i==0&&div<=9&&div>=1)
     {
      cout << "Yes";
      flag = 1;
      break;
     }
   }
   if (flag == 0)
   {
    cout << "No";
   }
    return 0;
  }


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

int main() {
  string S;
  cin >> S;


    if (S == "AAA") {
      cout << "No" << endl;
    }
    else if(S == "BBB") {
      cout << "No" << endl;
    }

    else {
      cout << "Yes" << endl;
  }

}


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll INF = 1LL << 62;
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a,ll b){//最小公倍数
	return (a / gcd(a, b))*b;
}

int main() {

	int n, k;
	
	cin >> n >> k;

	int ans = 1;
	for (int i = 0; i < n; i++) {
		ans = min(ans * 2, ans + k);
	}
	cout << ans << endl;
	
	return 0;
}

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

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define AI(a,size,n) array<int,size> a;REP(i,n){assert(0<scanf("%d",&a[i]));}
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); INT(q);
  vector<int> ans(q, -1);
  vector<tuple<int, int, int>> vt;
  REP(n){
    INT(s); INT(t); INT(x);
    vt.EB(s, t, x);
  }
  VI(ds, q);
  set<tuple<int, int, int>> op;
  map<int, int> mp;
  REP(i, q){op.insert(MT(ds[i], 2, i));}
  for(auto tpl: vt){
    int s, t, x; tie(s, t, x) = tpl;
    op.insert(MT(s - x, 1, x));
    op.insert(MT(t - x, 0, x));
  }
  multiset<int> ms;
  for(auto tpl: op){
    int d, x, y; tie(d, x, y) = tpl;
    if (x == 0){
      ms.erase(ms.find(y));
    } else if (x == 1){
      ms.insert(y);
    } else if (!ms.empty()){
      ans[y] = *ms.begin();
    }
  }
  for (int d: ans){printf("%d\n", d);}
  return 0;
}

Measured memory_bytes: 52720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int m = (int)(Math.log(n)/Math.log(2));
		
		System.out.println((int)Math.pow(2, m));
		
		sc.close();
	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,ans; 

    cin>> n ;

    if(n%1000 ==0 )
    {
        ans =0 ; 
    }
    else 
    {
        ans = 1000 -n%1000;
    }

    cout<<ans ; 


}

Measured memory_bytes: 3620
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

struct bfsi{
  int x,y,z;
  bfsi(int a,int b,int c){ x=a; y=b; z=c;}
};
ll n,m;
vector<vector<int> >g(111111);
int vis[111111];
ll res1,res2;
bool iro(int x,int d){
  if(vis[x]!=0){
    if((vis[x]==1)&&(d%2==1)) return false;
    if((vis[x]==-1)&&(d%2==0)) return false;
    return true;
  }
  if(d%2==0) {res1++;  vis[x]=1;}
  else {res2++; vis[x]=-1;}

  for(int i=0;i<g[x].size();i++){
    if(!iro(g[x][i],d+1)) return false;
  }
  return true;
}

int main(void){
  cin>>n>>m;
  int a,b;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    g[a].pb(b);
    g[b].pb(a);
  }

  res1=res2=0;
  memset(vis,0,sizeof(vis));
  if(iro(1,0)) cout<<res1*res2-m<<endl;
  else cout<<n*(n-1)/2 -m<<endl;
  return 0;
}


Measured memory_bytes: 6784
import numpy as np

grid = [np.array(list(map(int, input().split()))) for _ in range(3)]

# check bi
aib1 = np.array([e[0] for e in grid])
aib2 = np.array([e[1] for e in grid])
aib3 = np.array([e[2] for e in grid])

if len(set(aib1 - aib2)) == 1 and len(set(aib2 - aib3)) and len(set(aib3 - aib1)) == 1:
    if len(set(grid[0] - grid[1])) == 1 and len(set(grid[1] - grid[2])) == 1 and len(set(grid[2]-grid[0])) == 1:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 13152