akhauriyash/Code-Regression huggingface dataset:
j = []
m = gets.to_i
m.times{|i|
    a,b,c = gets.split.map(&:to_i).sort!
    if a**2 + b**2 == c**2
        h = "YES"
        j << h
    else
        d = "NO"
        j << d
    end
}
m.times{|i|
   puts j[i] 
}


Measured memory_bytes: 6876
from math import sqrt
N, D = map(int,input().split())

def keisan(l1,l2):
    ret = 0
    for k in range(len(l1)):
        ret += (l1[k]-l2[k])**2
    return sqrt(ret)

P = [list(map(int,input().split())) for k in range(N)]
ans = 0
for k in range(N-1):
    for l in range(k+1,N):
        if keisan(P[k],P[l]) == int(keisan(P[k],P[l])):
            ans += 1
print(ans)


Measured memory_bytes: 38256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int N;
int L[100010], R[100010];

int solve(set< pair<int, int> > sa, set< pair<int, int> > sb, int oa, int ob) {
    int x = 0, ret = 0;
    for(int i=0; i<N; i++) {
        set< pair<int, int> > &S = (i % 2 == 0 ? sa : sb);
        set< pair<int, int> > &T = (i % 2 == 0 ? sb : sa);
        int op = (i % 2 == 0 ? oa : ob);

        pair<int, int> elem = *S.begin();
        S.erase(elem);

        // 今注目していない方を消す
        // op が 1 なら L に注目なので R になるみたいな
        // L になったら符号を変えないと消せない
        int y = (op ? R : L)[elem.second] * (op ? 1 : -1);
        // int y = (op ? R : L)[elem.second];
        T.erase(make_pair(y, elem.second));

        // 区間かぶっていたら何もしない
        if(L[elem.second] <= x && x <= R[elem.second]) continue;

        int nxt = elem.first * (op ? -1 : 1);
        ret += abs(x - nxt);

        fprintf(stderr, "x = %lld, elem = %lld (%lld)\n", x, nxt, elem.second);
        x = nxt;
    }

    fprintf(stderr, "return %lld\n", ret + abs(x));
    return ret + abs(x);
}

signed main() {
    cin >> N;
    set< pair<int, int> > seg_right, seg_left;
    for(int i=0; i<N; i++) {
        cin >> L[i] >> R[i];

        // 符号そのまま
        seg_right.insert(make_pair(R[i], i));

        // 符号反転
        seg_left.insert(make_pair(-L[i], i));
    }

    int ans = 0;
    chmax(ans, solve(seg_right, seg_left, 0, 1));
    chmax(ans, solve(seg_left, seg_right, 1, 0));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 28800
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
A_acc = list(accumulate([0]+A))
r = 0
s = 0
ans = 0
for l in range(N):
	while r < N and s^A[r] == A_acc[r+1]-A_acc[l]:
		s ^= A[r]
		r += 1
	ans += r-l
	if r == l+1:
		s = 0
	else:
		s ^= A[l]

print(ans)


Measured memory_bytes: 27144
n = int(input())
s = input()
A = ord("A")
B = ord("Z")
l = []
#print(ord("["))
#print(ord("A"))
#print(ord("Z"))

for i in range(len(s)):
    if ord(s[i])+n <= B:
        l.append(chr(ord(s[i])+n))
    else:
        l.append(chr(ord(s[i])+n-26))

print("".join(l))

#ord() 文字列を数値化
#chr()　数値化した文字を再度文字化


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  double v;
  
  while(cin>>v){
    cout<<ceil(v*v/98+1)<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3284
n = int(input())
w = list(map(int, input().split()))
b = w[:]
w.sort()
s = w[0]

class Solve():
    def __init__(self, w, b, s):
        self.w = w
        self.b = b
        self.s = s
        self.ans = 0
        self.v = [0] * n
    
    def sort(self):
        T = [0] * 10001
        for i in range(n):
            T[self.w[i]] = i
        for i in range(n):
            if self.v[i]:
                continue
            cur = i
            S = 0
            m = 10001
            an = 0
            while 1:
                self.v[cur] = 1
                an += 1
                l = self.b[cur]
                m = min(m, l)
                S += l
                cur = T[l]
                if self.v[cur]:
                    break
            self.ans += min(S + (an - 2) * m, S + m +(an + 1) * self.s)
        return self

cost = Solve(w, b, s).sort()
print(cost.ans)


Measured memory_bytes: 5776
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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


int main() {
	int n = 7;
	ll A[n];
	for (int i = 0; i < n; ++i) cin >> A[i];
	ll sol = (A[0]/2LL)*2LL + A[1] + (A[3]/2LL)*2 + (A[4]/2LL)*2;
	ll sol2 = 0;
	if (A[0] > 0 && A[3] > 0 && A[4] > 0) {
		sol2 = 3;
		--A[0]; --A[3]; --A[4];
		sol2 += (A[0]/2LL)*2LL + A[1] + (A[3]/2LL)*2 + (A[4]/2LL)*2;
	}
	cout << max(sol, sol2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;

pii input(string t1,string t2) {
	int ret1,ret2;

	ret1 = stoi(t1.substr(6,2)) + 60 * stoi(t1.substr(3,2)) + 60 * 60 * stoi(t1.substr(0,2));
	ret2 = stoi(t2.substr(6,2)) + 60 * stoi(t2.substr(3,2)) + 60 * 60 * stoi(t2.substr(0,2));
	return make_pair(ret1,ret2);
}

signed main() {

	while(1) {
		cin1(n);
		if (n == 0) break;

		vpii table(n,make_pair(0,0));
		rep(i,0,n) {
			string time1,time2;
			cin2(time1,time2);
			table[i] = input(time1,time2);	
			//cout << table[i].fr << " " << table[i].sc << endl;
		}

		sort(table.begin(),table.end());
		
		int idx = 0;
		vector<pair<bool,int>> train;
		train.pb(make_pair(true,0));
		rep(i,0,60*60*24) {
			//std::cout << "table.fr " << table[idx].fr <<  std::endl;
			rep(j,0,train.size()) {
				if (train[j].sc == i) {
					//cout << "j = " << j << endl;
					//cout << "i = " << i << endl;
					train[j].fr = true;
					train[j].sc = 0;
				}
			}
			if (table[idx].fr == i) {
				//cout << "idx = " << idx << endl;
				//cout << "i = " << i << endl;
				//cout(table[idx].fr);
				bool flag = false;
				rep(j,0,train.size()) {
					if (train[j].fr) {
						train[j].fr = false;
						train[j].sc = table[idx].sc;
						flag = true;
						break;
					}
				}
				if (!flag) {
					train.pb(make_pair(false,table[idx].sc));
				}
				idx++;
				i--;
			}
		}
		cout(train.size());
	}

	return 0;
}

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

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

  cout << 800 * N - 200 * (N / 15) << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

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

    if (n == 3) {
        cout << "2 5 63" << endl;
        return 0;
    } else if (n == 4) {
        cout << "2 5 20 63" << endl;
        return 0;
    }

    int a;
    for (a = min(10000, n-1); a > 0; --a) {
        int b = n-a;
        if (a*(a+1)/2 % 2 == 0 && b % 2 == 0) break;
    }

    for (int i = 1; i <= a; ++i) {
        cout << i*3 << " ";
    }
    for (int i = 1, cnt = 0; cnt < n-a; ++i) {
        if (i % 3 == 0) continue;
        cout << i*2 << " ";
        ++cnt;
    }
    cout << endl;

    return 0;
}


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

const int MAX_N = (int)1e5 + 5;
int C[MAX_N];
vector<int> G[MAX_N];

bool dfs(int s, int cur){
    bool res = true;
    C[s] = cur + 1;
    for(auto u : G[s]){
        if(C[u]){
            if(C[s]==C[u]) res = false;
            continue;
        }
        res &= dfs(u, (cur^1));
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, M; cin >> N >> M;
    for(int i=0;i<M;i++){
        int a, b; cin >> a >> b;
        G[a].push_back(b); G[b].push_back(a);
    }

    bool bi = dfs(1, 0);

    if(bi){
        lint cnt = 0;
        for(int i=1;i<=N;i++) if(C[i]==1) cnt++;
        cout << 1LL * N * (N-1) / 2 - cnt * (cnt-1) / 2 - (N-cnt) * (N-cnt-1) / 2 - M << endl;
    }
    else cout << 1LL * N * (N-1) / 2 - M << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#define MOD 1000000007
#define int long long
#define INF 1e+18
using namespace std;

signed main(){
	string s;
	int n,cnt = 0,a;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a;
		if(a % 2 == 1) cnt++;
	}
	if(cnt % 2 == 1) cout << "NO" << endl;
	else cout << "YES" << 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 rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 207
using namespace std;
int main() {
  fastio;
  ll a = 0, b = 0, c = 0, d = 0;
  cin >> a >> b >> c >> d;
  set<ll>s;
  s.insert(a * c);
  s.insert(a * d);
  s.insert(b * c);
  s.insert(b * d);
  cout << *s.rbegin();
}

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

using namespace std;

int main()
{
    string str1;

    string str2;

    cin>>str1>>str2;

    int n, m;

    n = str1.size();

    m = str2.size();

    int LCS[n + 1][m + 1];

    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            if(i == 0 || j == 0)
            {
                LCS[i][j] = 0;
            }
            else if(str1[i-1] == str2[j-1])
            {
                LCS[i][j] = LCS[i-1][j-1] + 1;
            }
            else
            {
                LCS[i][j] = max(LCS[i-1][j], LCS[i][j-1]);
            }
            
        }
    }

    int index = LCS[n][m];

    char lcs[index + 1];

    lcs[index] = '\0';

    int i = n;

    int j = m;

    while(i > 0 && j > 0)
    {   
        if(str1[i - 1] == str2[j - 1])
        {
            lcs[index - 1] = str1[i - 1];
            i--;
            j--;
            index--;
        }
        else if(LCS[i - 1][j] > LCS[i][j - 1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }

    cout<<lcs;

    return 0;
}

Measured memory_bytes: 38756
check_alf = [chr(ord('a') + i) for i in range(26)]

n=int(input())

check_num = 0

keta = 0

while check_num+26**(keta+1) < n:
    keta += 1
    check_num += 26**keta
sa = n - check_num

ans = []

index = keta

while keta > 0:
    if sa%(26**keta) == 0:
        ans.append(check_alf[sa//(26**keta)-1])
    else:
        ans.append(check_alf[sa//(26**keta)])
    sa -= (sa//(26**keta))*(26**keta)
    keta -= 1

ans.append(check_alf[sa-1])

print(''.join(map(str,ans)))

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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 2e5 );
const int MOD  = int( 1e9 )+7;
const int oo   = INT_MAX;

int a, b;

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( ".in", "r", stdin );
    //freopen( ".out", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while( cin >> a >> b ) {
    if( a <= 0 && 0 <= b ) {
      cout << "Zero\n";
    } else {
      int sgn = 1;
      if( b < 0 && ( b-a+1 )%2 == 1 ) {
        sgn = -1;
      }
      cout << ( sgn == 1 ? "Positive" : "Negative" ) << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll m, n;

int main(){
	while (cin >> m&&m){
		vector<P> mm(1010), nn(1010);
		set<P> sp;
		REP(i, m){
			int a, b;
			cin >> a >> b;
			mm[i] = P(a, b);
		}
		cin >> n;
		REP(i, n){
			int a, b;
			cin >> a >> b;
			sp.insert(P(a, b));
			nn[i] = P(a, b);
		}
		bool f = 0;
		REP(i, n){
			P p = P(nn[i].first - mm[0].first, nn[i].second - mm[0].second);
			REP(j, m){
				if (sp.find(P(mm[j].first + p.first, mm[j].second + p.second)) == sp.end())break;
				if (j == m - 1){
					f = 1;
				}
			}
			if (f){
				cout << p.first << " " << p.second << endl;
				break;
			}
		}
	}
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    string s;
    cin >> s;

    deque<char> str;
    rep(i,s.size()) str.push_back(s[i]);
    i32 cnt = 0;
    while(1 < str.size()) {
        char lch = str.front();
        char rch = str.back();
        if(lch == rch) {
            str.pop_front();
            str.pop_back();
        }
        else if(lch == 'x') {
            str.pop_front();
            ++cnt;
        }
        else if(rch == 'x') {
            str.pop_back();
            ++cnt;
        }
        else {
            cout << -1 << '\n';
            return 0;
        }
    }

    cout << cnt << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	for (int i = 1; i <= min(9LL, N); i++)M++;
	for (int i = 100; i <= min(999LL, N); i++)M++;
	for (int i = 10000; i <= min(99999LL, N); i++)M++;
	cout << M << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
x=list(map(int,input().split()))
a=[]
for i in range(n-k+1):
 if x[i]>=0:
  a.append(x[i+k-1])
 elif x[i+k-1]<0:
  a.append(abs(x[i]))
 else:
  a.append(max(abs(x[i]),x[i+k-1])+min(abs(x[i]),x[i+k-1])*2)
print(min(a))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    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 <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using ll = long long int;

int main(int argc,char *argv[])
{
	ll s,w;
	std::cin >> s >> w;

	if (w >= s) { std::cout << "unsafe" << std::endl; }
	else { std::cout << "safe" << std::endl; }

	return 0;
}

Measured memory_bytes: 3636
use std::io;

fn main() {
    let line = parse_line::<String>();
    println!("{}", solve(line));
}

fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn solve(s: String) -> i32 {
    let cs = s.chars();
    let cs_list = cs.collect::<Vec<char>>();
    let mut counter = 0;
    for i in 0..cs_list.len() / 2 {
        if cs_list[i] != cs_list[cs_list.len() - i - 1] {
            counter += 1;
        }
    }
    counter
}

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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}
/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*ここから*/
int main() {
    ull A,B;
    ll C,D;
    ull divC1,divC2,divD1,divD2,divC,divD;
    cin >> A >> B >> C >> D;
    if(A%C==0){
        divC1 = A/C-1;
        divC2 = B/C;
        divC = divC2-divC1;
    }else{
        divC1 = A/C;
        divC2 = B/C;
        divC = divC2-divC1;
    }
    if(A%D==0){
        divD1 = A/D-1;
        divD2 = B/D;
        divD = divD2 - divD1;
    }else{
        divD1 = A/D;
        divD2 = B/D;
        divD = divD2-divD1;
    }
    ull times,divT;
    times = LCM(C,D);
    if(A%times==0){
        divT= B/times-A/times+1;
    }else{
        divT =  B/times-A/times;
    }
    //cout << divC << " " << divD << " " << divT << endl;
    ull BA = B-A+1;
    ull ans;
    ans = BA-divC-divD+divT;
    cout << ans << endl;
}

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

int main(){
  int N;
  long long ans=0;
  cin>>N;
  vector<int> r(0),g(0),b(0);
  vector<char> c(N);
  
  for(int i=0;i<N;i++){
    cin>>c.at(i);
    if(c.at(i)=='R'){
      r.push_back(i+1);
    }else if(c.at(i)=='G'){
      g.push_back(i+1);
    }else{
      b.push_back(i+1);
    }
  }
  
  vector<int> a(2);
  sort(b.begin(),b.end());
  ans=r.size()*g.size()*b.size();
  int temp;
  
  for(int i=0;i<r.size();i++){
    if(b.size()==0){break;}
    for(int j=0;j<g.size();j++){
    a.at(0)=r.at(i);	a.at(1)=g.at(j);
    sort(a.begin(),a.end());
    
    temp=2*a.at(1)-a.at(0);
    if(temp>b.at((b.size()-1)/2)&&temp<=b.at(b.size()-1)){
      for(int k=(b.size()-1)/2;k<b.size();k++){
        if(b.at(k)==temp){ans--;break;}
      }
    }else if(temp<=b.at((b.size()-1)/2)&&temp>=b.at(0)){
      for(int k=(b.size()-1)/2;k>-1;k--){
        if(b.at(k)==temp){ans--;break;}
      }
    }
    
    temp=a.at(1)+a.at(0);
    if(temp>2*b.at((b.size()-1)/2)&&temp<=2*b.at(b.size()-1)){
      for(int k=(b.size()-1)/2;k<b.size();k++){
        if(2*b.at(k)==temp){ans--;break;}
      }
    }else if(temp<=2*b.at((b.size()-1)/2)&&temp>=2*b.at(0)){
      for(int k=(b.size()-1)/2;k>-1;k--){
        if(2*b.at(k)==temp){ans--;break;}
      }
    }
    
    temp=2*a.at(0)-a.at(1);
    if(temp>b.at((b.size()-1)/2)&&temp<=b.at(b.size()-1)){
      for(int k=(b.size()-1)/2;k<b.size();k++){
        if(b.at(k)==temp){ans--;break;}
      }
    }else if(temp<=b.at((b.size()-1)/2)&&temp>=b.at(0)){
      for(int k=(b.size()-1)/2;k>-1;k--){
        if(b.at(k)==temp){ans--;break;}
      }
    }
  }}
  cout<<ans;
}

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

int main(void){
   long long N;
   cin>>N;
   long long now=26;
   long long len=1;
   while(N>now){
      N-=now;
      now=now*26;
      len++;
   }
   vector<char> ans(len);
   N--;
   for(int i=len-1;i>=0;i--){
      ans[i]=(N%26)+'a';
      N=N/26;
   }
   for(int i=0;i<len;i++){
      cout<<ans[i];
   }
   cout<<"\n";
   return 0;
}


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

int main(){
    int a, b, c, k; // a:red b:green c:blue
    cin >> a >> b >> c;
    cin >> k;
    string ans = "No";
    rep(i, k){
        if(a < b){
            if(b < c) c*=2;
            else if(b >= c) c*=2;
        }else b*=2;
    }
    if(a < b && b < c) ans = "Yes";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
def main():
    a,b,c,k = map(int,input().split())
    ans = 0
    if a >= k:
        print(k)
        return
    else:
        ans += a
        k -= a
        if b>= k:
            print(ans)
            return
        else:
            k -= b
            ans -= k
            print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 9176
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int query(int i){
    cout << i << endl;
    string s;
    cin >> s;
    if(s == "Male") return 1;
    else if(s == "Female") return 2;
    else return 0;
}

void Main() {
    int n; cin >> n;
    vi s(n, -1);
    
    int l = 0;
    int r = n-1;

    s[l] = query(l);
    if(s[l] == 0) return;
    
    s[r] = query(r);
    if(s[r] == 0) return;
    
    int mid;

    // 常に next > now で, 
    // s[now] != s[next] && (next - now) % 2 == 0
    // s[now] == s[next] && (next - now) % 2 == 1
    // のどちらかが成立    

    while(1){
        mid = (l + r) / 2;

        s[mid] = query(mid);
        if(s[mid] == 0) return;

        if(s[l] != s[mid] && (mid - l) % 2 == 0) {
            r = mid;    
        }
        else if(s[l] == s[mid] && (mid - l) % 2 == 1){
            r = mid;
        }
        else{
            l = mid;
        }
    }
    return;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

const int maxn = 2e5 + 5;
ll num[maxn];
ll a[maxn];
ll k;
ll flag[maxn];
ll sum;

map<ll , ll>cnt;

ll f(ll x){
	ll sign = x - 1;
	ll u = 1;
	for(ll i = x; i >= sign; i--) u *= i;
	return u / 2;
}

int main(){
	ll n; cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> num[i];
		if(cnt[num[i]] == 0) a[++k] = num[i];
		cnt[num[i]]++;
	}

	ll flag = 0;
	for(ll i = 1; i <= k; i++){
		sum += f(cnt[a[i]]);
	}



	for(int i = 1; i <= n; i++){
		cout << f(cnt[num[i]] - 1) + (sum - f(cnt[num[i]])) << endl;
	}
}


Measured memory_bytes: 12672
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <sstream>
using namespace std;

#define namefile ""
#define inifile freopen(namefile".inp","r",stdin); freopen(namefile".out","w",stdout)
#define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef unsigned int uint;
typedef unsigned long ulong;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<string> VS;
typedef vector< VI > VVI;
typedef vector< VL > VVL;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;
typedef set<int> SETI;
typedef set<long> SETL;
typedef map<int,int> MII;
typedef map<long,long> MLL;

const long long MOD = 1e9+7;
const long long INFMAX = 1e9;
const long long INFMIN = -1e9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const double epsilon = 1e-9;
const double PI = acos(-1.00);

int a;
string s;

int main()
{
    cin >> a;
    cin >> s;

    if (a >= 3200) cout << s; else cout << "red";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define abs(X) ((X) < 0 ? (X) * -1 : (X))
#define RIGHT 1
#define LEFT  2

typedef long long ll;

int main()
{
    ll n, t, q;
    ll tmp;
    static ll   pp[100005];
    static char f[100005] = {};
    static ll   points[100005];
    static char vect[100005];
    ll imp[1005];
    ll i, j;

    scanf("%lld %lld %lld", &n, &t, &q);
    for (i = 0; i < n; i++) {
        scanf("%lld %lld", &points[i], &tmp);

        if (tmp == LEFT) {
            vect[i] = LEFT;
        } else {
            vect[i] = RIGHT;
        }
    }
    for (i = 0; i < q; i++) {
        scanf("%lld", &imp[i]);
        imp[i]--;
    }

    //事前計算
    for (i = 0; i < n - 1; i++) {
        if (vect[i] == RIGHT && vect[i + 1] == LEFT) {
            f[i] = f[i + 1] = 1;
            
            pp[i] = pp[i + 1] = (points[i] + points[i + 1]) / 2;

            j = i - 1;
            while (j >= 0 && vect[j] == RIGHT && f[j] == 0) {
                f[j] = 1;
                pp[j] = pp[i];
                j--;
            }
        }

        if (vect[i] == LEFT && vect[i + 1] == LEFT) {
            f[i + 1] = 1;
            pp[i + 1] = pp[i];
        }
    }
    /*
    for (i = 0; i < n; i++) {
        printf("%lld:", i);
        if (f[i]) {
            printf("%lld\n", pp[i]);
        } else {
            printf("not\n");
        }
    }        
    */
    //出力
    for (i = 0; i < q; i++) {
        ll id = imp[i];
        
        if (f[id] == 0 || abs(points[id] - pp[id]) > t) {
            if (vect[id] == RIGHT) {
                printf("%lld\n", points[id] + t);
            } else if (vect[id] == LEFT) {
                printf("%lld\n", points[id] - t);
            }
        } else {
            printf("%lld\n", pp[id]);
        }
    }
    
    return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int maxN = (1 << 15);

void add(vector< vector<int> >& g, int s, int a, int b, int t=0, int l=0, int r=maxN){
	if(b <= l || r <= a) return;
	if(a <= l && r <= b){
		g[2*(s+maxN-1)].push_back(2*t+1);
		return;
	}
	add(g, s, a, b, 2*t+1, l, (l+r)/2);
	add(g, s, a, b, 2*t+2, (l+r)/2, r);
}

void search(const vector< vector<int> >& g, int pos, int k, vector<int>& key, vector<int>& order, bool first){
	if(key[pos] != -1) return;
	key[pos] = k;
	for(int i=0;i<g[pos].size();i++){
		search(g, g[pos][i], k, key, order, first);
	}
	if(first) order.push_back(pos);
}

bool solve2sat(const vector< vector<int> >& g){
	int n = g.size();
	vector< vector<int> > h(n);
	for(int i=0;i<g.size();++i){
		for(int j=0;j<g[i].size();j++){
			h[g[i][j]].push_back(i);
		}
	}
	vector<int> key(n, -1), order;
	for(int i=0;i<n;i++) search(g, i, i, key, order, true);
	fill(key.begin(), key.end(), -1);
	for(int i=0;i<n;i++) search(h, order[n-1-i], i, key, order, false);
	for(int i=0;i<n;i+=2) if(key[i] == key[i+1]) return false;
	return true;
}

bool check(const vector< pair<int,int> >& vp, const vector< vector<int> >& idx, int thr){
	vector< vector<int> > g(2*(2*maxN-1));
	for(int i=0;i<maxN-1;i++){
		g[2*i+1].push_back(2*(2*i+1)+1);
		g[2*i+1].push_back(2*(2*i+2)+1);
	}
	for(int i=0;i<idx.size();i++){
		int a = idx[i][0]+maxN-1;
		int b = idx[i][1]+maxN-1;
		g[2*a+1].push_back(2*b);
		g[2*b].push_back(2*a+1);
		g[2*a].push_back(2*b+1);
		g[2*b+1].push_back(2*a);
	}
	for(int i=0;i<vp.size();i++){
		int l=-1, r=i;
		while(r-l>1){
			int m = (l+r)/2;
			if(vp[i].first - vp[m].first < thr){
				r = m;
			} else {
				l = m;
			}
		}
		if(0 <= r && r < i) add(g, i, r, i);
		l=i, r=vp.size();
		while(r-l>1){
			int m = (l+r)/2;
			if(vp[m].first - vp[i].first < thr){
				l = m;
			} else {
				r = m;
			}
		}
		if(i < l) add(g, i, i+1, l+1);
	}
	return solve2sat(g);
}

int main(){
	int N;
	while(cin >> N){
		vector< pair<int,int> > vp;
		for(int i=0;i<2*N;i++){
			int x; cin >> x;
			vp.push_back(make_pair(x, i/2));
		}
		sort(vp.begin(), vp.end());
		vector< vector<int> > idx(N);
		for(int i=0;i<vp.size();i++) idx[vp[i].second].push_back(i);
		int L = 0, R = 1000000007;
		while(R - L > 1){
			int mid = (L+R)/2;
			if(check(vp, idx, mid)){
				L = mid;
			} else {
				R = mid;
			}
		}
		cout << L << endl;
	}
}



Measured memory_bytes: 24788
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
	char s[100005];
	int i, j, n;
	int a, b;
	int ans = 0;
	scanf("%d %d", &a, &b);
	for(i = 1 ; i <= a ; i++)
	{
		if(i != a)
		{
			for(j = 1 ; j <= 31 ; j++)
			{
				if(i == j) ans++;
			}
		}
		else
		{
			for(j = 1 ; j <= b ; j++)
			{
				if(i == j) ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
use std::io::*;

fn main() {
    let stdin = stdin();
    let mut handle = stdin.lock();
    let k: u32 = read(&mut handle);
    let list: [u32; 32] = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4,
        1, 51,
    ];

    println!("{}", list[k as usize - 1]);
}

fn read(handle: &mut StdinLock) -> u32 {
    handle
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |acc, x| (x as u8 - b'0') as u32 + acc * 10)
}


Measured memory_bytes: 4352
la = [1,3,5,7,8,10,12]
lb = [4,6,9,11]
lc = [2]
x,y = map(int,input().split())

if x in la and y in la or x in lb and y in lb or x in lc and y in lc:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long llong;

static const int NMAX = 100001;
// static const int MMAX = 100000;
// static const int KMAX = 100000;
static const int NIL = -1;
// static const int WHITE = 0;
// static const int GRAY = 1;
// static const int BLACK = 2;

int N, Idx;
int Color[NMAX];
llong Cnt[NMAX], Adj[NMAX];
vector<llong> F[NMAX], B[NMAX];

void dfs(int u, int c){
    Color[u] = c;
    for(int i=0; i<F[u].size(); i++){
        if(Color[F[u].at(i)] == NIL){
            dfs(F[u].at(i), c);
        }
   }
}


// void bfs(int u, int c){
//     queue<int> Q;
//     Q.push(u);
//     Color[u] = c;
//     while(!Q.empty()){
//         u = Q.front(); Q.pop();
//         for(int i=0; i<F[u].size(); i++){
//             if(Color[F[u].at(i)] == NIL){
//                 Q.push(F[u].at(i));
//                 Color[F[u].at(i)] = c;
//             }
//         }
//     }
// }


void assign(){
    Idx=1;
    for(int i=1; i<=N; i++) Color[i] = NIL;
    for(int i=1; i<=N; i++){
        if(Color[i] == NIL){
            dfs(i, Idx);
            Idx++;
        }
    }
}

int main(){
    int m, k;
    cin >> N >> m >> k;
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        F[a].push_back(b);
        F[b].push_back(a);
    }

    assign();
    
    for(int i=1; i<=N; i++) {
        Adj[i] = 0;
    }

    for(int i=0; i<k; i++){
        int c, d;
        cin >> c >> d;
        B[c].push_back(d);
        B[d].push_back(c);
        if(Color[c] != Color[d]){
            Adj[c] += 1;
            Adj[d] += 1;
        }
    }

    for(int i=1; i<=N; i++) Cnt[i] = 0;
    for(int i=1; i<=N; i++){
        Cnt[Color[i]]++;
    }

    for(int i=1; i<=N; i++){
        if(i != 1) cout << " ";
        llong ans = Cnt[Color[i]] - 1 - F[i].size() - B[i].size() + Adj[i];
        cout << ans;
    }
    cout << endl;

}


Measured memory_bytes: 15488
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    s = gets.chomp

    ans = s[0] + (s.length - 2).to_s + s[-1]
    puts ans
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 4092
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	static List <Integer>[]L;
	static int []p;
	static int mod = 1000000007;
	static Deque <Integer> que;
	static boolean []visit;
	static long ans;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		L = new ArrayList [n];
		
		for(int i = 0 ; i < n ;i++) {
			L[i] = new ArrayList<Integer>();
		}
		
		for(int i = 0 ; i < n-1 ;i++) {
			int a = Integer.parseInt(sc.next())-1;
			int b = Integer.parseInt(sc.next())-1;
			L[a].add(b);
			L[b].add(a);
		}
		
		p = new int [k+1];
		p[0] = k;
		
		for(int i = 0 ;i < k; i++) {
			p[i+1] =(p[i] * (k-i))%mod;
		}
		
		que = new ArrayDeque<Integer>();
		visit = new boolean [n];
		visit[0] = true;
		ans = k;
		
		bfs(n,k,0);
		System.out.println(ans);
		

	}
	
	static void bfs(int n ,int k ,int st) {
		if(L[st].size() == 0) {
			return;
		}
		int x = 1;
		for(int num : L[st]) {
			if(!visit[num] ) {
			que.addLast(num);
			visit[num] = true;
			
			if(st == 0) {
				ans = (ans * (k - x))%mod;
			}
			else {
				ans = (ans * (k - x - 1))%mod;
			}
			x++;
			
		}
	}
		
		if(que.isEmpty()) {
			return;
		}
		
		bfs(n,k,que.poll());
	}

}


Measured memory_bytes: 89012
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
int main(){
    int N;
    R(N);
    VI A(N+1);
    VL s(N+1);
    FOR(i,0,N)R(A[i]);
    s[N]=A[N];
    for(int i=N-1;i>0;i--)s[i]=s[i+1]+A[i];
    if(!N){
        if(A[0]==1)W(1);
        else W(-1);
    }
    else{
        if(A[0])W(-1);
        else{
            LL an=1;
            LL now=1;
            FOR(i,1,N){
                now=min(now*2,s[i]);
                if(now<A[i]){
                    W(-1);
                    return 0;
                }
                an+=now;
                now-=A[i];
            }
            W(an);
        }
    }
    return 0;
}


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

int main () {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector <int> point(N);
  vector <int> correct(Q);
  for (int i = 0; i < Q; i++) cin >> correct.at(i);
  for (int i = 0; i < Q; i++){
      int a = correct.at(i)-1;
      point.at(a)++;
  }
  for (int i = 0; i < N; i++){
    if (K-Q+point.at(i) <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1408
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll l,r;
    ll maxn=2020;
    cin>>l>>r;
    if(r-l+1>=2019)
    {
        cout<<0;
        return 0;
    }
    else
    {
        for(ll i=l;i<r;i++)
        {
            for(ll j=l+1;j<=r;j++)
            {
                if(i*j%2019<maxn)
                {
                    maxn=i*j%2019;
                }
            }
        }
    }
    cout<<maxn;
    return 0;
}

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

int main()
{
    int x = 0;
    int y = 0;
    scanf("%d",&x);
    scanf("%d",&y);
    int result = 0 ;
    result = 100*(10-x)+y;
    if (x <= 10)
    {
        printf("%d",100*(10-x)+y);
    }
    else
    {
        printf("%d",y);
    }
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

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

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

#define long long long // for codeforces

int main(){
  int n,d;
  string org;
  cin>>n>>org>>d;
  string ans(org);

  int p = 0;
  while(p < n && d > 0) {
    if (ans[p] == '0'){
      ans[p] = '1';
      d--;
    }
    p++;
  }

  while(p>=0 && d > 0) {
    if(org[p] == '1'){
      ans[p] = '0';
      d--;
    }
    p--;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

void printVector( vector<int> &vec ){
    // cout << "size = " << vec.size() << endl;
    for(int i = 0; i < (int)vec.size(); ++i){
        cout << vec[i] << ", ";
    }
    cout << endl << endl;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }

    bool flag = true;
    int target = 1;
    int ans = 0;
    for(int i=0; i<n; i++){
        if(a.at(i)==target){
            // cout << "ok" << endl;
            target += 1;
            flag = false;
        }
        else{
            // cout << "break" << endl;
            ans += 1;
        }
    }

    // cout << ans << "," << target << endl;
    if(flag){
        cout << -1 << endl;
        return 0;
    }
    if(ans+target-1==n){
        cout << ans << endl;
    } else {
        cout << -1  << endl;
    }

    // printVector(a); 
    
    return 0;
        
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            out.println((n + 1) / 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <cmath>

int main()
{
	int length;
	std::cin >> length;
	int min = 10000000000;
	int max = -1;
	for (int i = 0; i < length; i++)
	{
		int temp;
		std::cin >> temp;
		if (temp > max)max = temp;
		if (temp < min)min = temp;
	}
	std::cout << (max - min);

	return 0;
}

Measured memory_bytes: 256