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

int main(){

  vector<int> dat(10),work(0);
  char c;

  while(cin>>c){
    dat.resize(10);
    dat[0] = c-'0';
    for(int i=1; i<10; i++){
      cin >> c;
      dat[i] = c- '0';
    }
    
    
    while(dat.size() > 1){
      work.resize(0);

      for(int i=1; i<(int)dat.size(); i++){
	work.push_back( (dat[i]+dat[i-1])%10 );
	//cout << (dat[i]+dat[i-1])%10 << ' ';
      }
      // cout << endl;
      dat = work;
      
    }
    
    cout << dat[0] << endl;

  }


  return 0;
}

Measured memory_bytes: 1196
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

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

    cout << a + a * a + a * a * a << endl;

	return 0;
}


Measured memory_bytes: 3636
#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;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int X; cin >> X;
	if (X >= 30) {
		cout << "Yes";
	}
	else cout << "No";
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    if (n / 10 == 9 or n % 10 == 9) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli lcm(lli a,lli b){
    return ((a*b)/__gcd(a,b));
}

const lli N = 3005;
lli a[N], n, dp[N][N];

// fun(l,r) stores values of Max(X'-Y') or Max(Y'-X') depending on 
// who is going to pick first in that interval.
// Hence a[l] - fun(l+1,r) = a[r] - fun(l,r-1) = aX - (Y' - X') = (x'+aX) - (Y') = X - Y

lli fun(lli l, lli r){
    if(l==r) return a[l];
    if(dp[l][r]!=-1) return dp[l][r];
    lli ans = max(a[l]-fun(l+1,r),a[r]-fun(l,r-1));
    return dp[l][r] = ans;
}
void solve(){
    cin >> n;
    NA(i,0,n) cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << fun(0,n-1);
    return;
}

int main(){
    fastIO; 
    lli t = 1; 
    // cin>>t;
    NA(i,0,t) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int n, m;
    vector<Int> a;
    multimap<Int, Int, greater<Int>> bc;
    cin >> n >> m;
    for(Int i=0; i<n; i++){
        cin >> tmpi;
        a.push_back(tmpi);
    }

    Int tmpi2;
    for(Int i=0; i<m; i++){
        cin >> tmpi >> tmpi2;
        bc.insert(make_pair(tmpi2, tmpi));
    }
    sort(a.begin(), a.end());
    Int it = 0;
    Int sum = 0;
    Int cnt = 0;
    for(const auto& u : bc){
        Int num = u.first;
        Int len = u.second;
        bool flg = false;
        Int maxlen = it+len < n ? it+len : n;
        for(Int i=maxlen-1; i>=it; i--){
            cnt++;
            if(a[i] < num){
                sum += num*(i-it+1);
                it = i+1;
                if(cnt != bc.size()){
                    flg = true;
                }
                break;
            }
        }
        if(!flg){
            for(Int i=it; i<n; i++){
                sum += a[i];
            }
            break;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 7284
n = int(input())
a = list(map(int, input().split()))
sa = sum(a) # sum a
cs = 0 # cards sunuke
arr = []

for i in range(n-1):
  cs += a[i]
  ca = sa -cs #cards araiguma
  arr.append(abs(cs-ca))
 
print(min(arr))

Measured memory_bytes: 30748
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;



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

	vector<int> A(N);
	rep(i, N)
	{
		cin >> A[i];
	}


	int target = 1;
	int count = 0;

	int idx = 0;
	while (idx < N)
	{

		bool found = false;

		for (int i = idx; i < N; i++)
		{
			if (A[i] == target)
			{
				target++;
				count++;
				idx = i;
				found = true;
				break;
			}
		}

		if (!found) break;
	}

	if (count == 0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << N - count << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"


func main() {
        var input int64
        num := [11]int64{111,222,333,444,555,666,777,888,999,1111}
        fmt.Scan(&input)

        for i := 0 ; i < len(num); i++ {
                if input <= num[i] {
                        fmt.Println(num[i])
                        return 
                }

        }

}

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

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

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream> 
#include <algorithm>
#include <bits/stdc++.h>
 
using namespace std; 
typedef long long ll;
 
#define umap unordered_map
#define f first
#define s second
 
#define for0(i, a, b) for (int i = (a); i < (b); i++)
#define for1(i, a) for (int i = 0; i < (a); i++)
#define ford(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define fordd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define rep(i,a,b) for (int i = a; i < b; i++)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sstr substr
typedef vector<int> vi;
typedef vector<string> vis;
typedef unordered_map<string, int> umap; 

 
int main()
{   
    ll item;
    cin >> item;
    
    ll totalweight;
    cin >> totalweight;
    vector< pair <ll,ll> > vect; 
    ll temp1;
    ll temp2;
    
    for0(i, 0 , item){
        cin >> temp1;
        cin >> temp2;
        vect.push_back( make_pair( temp1, temp2) );
    }
    sort(vect.begin(), vect.end()); 
    // trav(x, vect){
    //     cout<<x.first << " "<<x.second<<endl;
    // }
    
    ll maxweight = totalweight + 1;
    
    ll dp[item][totalweight + 1] = {0};
    
    for0(i,0, item){
        for0(j,0, totalweight+1){
            dp[i][j] = 0 ;
        }
    }
    
    
    // trav( x, dp){
    //     trav( y , x){
    //         cout<< y<< " ";
    //     }
    //     cout<<endl;
    // }
    
    
    
    
    for0(i , 0 , item){
        ll currentweight = vect[i].first;
        ll currentvalue = vect[i].second;
        
        if ( i == 0 ){ 
            for0(j, currentweight, maxweight + 1){
                dp[0][j] = currentvalue;
                continue;
            }
            continue;
        }
        
        for0(j, 0, currentweight){
            dp[i][j] = dp[i-1][j];
        }
        
        for0(j, currentweight, maxweight + 1 ){
            dp[i][j] = max(dp[i-1][j], currentvalue + dp[i-1][j - currentweight]);
        }
        
    }
    
    // trav( x, dp){
    //     trav( y , x){
    //         cout<< y<< " ";
    //     }
    //     cout<<endl;
    // }
    
    cout<<dp[item-1][totalweight];
    
    return 0;
}

Measured memory_bytes: 78336
A, B, C, D = map(int, input().split())
M = [[A, B], [C, D]]
T, A, HP, AP = 0, 1, 0, 1
atkTtoA = (M[A][HP] + M[T][AP] - 1) // M[T][AP]
atkAtoT = (M[T][HP] + M[A][AP] - 1) // M[A][AP]
if atkAtoT < atkTtoA:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9204
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A = inputInt()
	T = input()

	ST = T.split()

	ans = ""
	for i in range(A):
		ans += ST[0][i]
		ans += ST[1][i]

	print(ans)



if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include<list>
#include<iomanip>
#include<cmath>
#include<queue>
#include <functional>
#include<stdio.h>
#include<assert.h>
#include <deque>
#include<stack>
#include<sstream>
#include <cstdlib>
#include<map>
#include<algorithm>
#include<iostream>
#include<set>
#include<utility>
#include<memory.h>
#include<string>
#include<vector>
#include<numeric>
using namespace std;
#define ll  long long
#define pb push_back
#define sz(v)               ((int)((v).size()))
#define all(x)          (x).begin(),(x).end()
#define REP(i, v)       for(int i=0;i<sz(v);i++)
using namespace std;
typedef pair<int,int> pii;
#define f first
#define s second
int main() {
	long long x,y;
	cin >> x >> y;
	int ans = 0;
	while (x <= y) {
		x <<= 1;
		++ans;
	}
	cout << ans << "\n";


}


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

int cmp(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int count = 0;
	int n;
	scanf("%d", &n);
	int *a = malloc(sizeof(int) * n);
	for(int i = 0; i < n; i++){
		scanf("%d", a + i);
		if(a[i] < 0){
			count++;
			a[i] *= -1;
		}
	}
	qsort(a, n, sizeof(int), cmp);
	long sum = 0;
	int i = 0;
	if(count % 2){
		sum -= a[i];
		i++;
	}
	for(; i < n; i++){
		sum += a[i];
	}
	printf("%ld\n", sum);
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define yes "POSSIBLE"
#define no "IMPOSSIBLE"
int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> start,goal;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    if(a==1) start.push_back(b);
    if(b==n) goal.push_back(a);
  }
  sort(start.begin(),start.end());
  sort(goal.begin(),goal.end());
  
  for(int s:start){
    if(binary_search(goal.begin(),goal.end(),s))
    {
      cout<<yes;
      return 0;
    }
  }
  cout<<no;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()

using namespace std;

int main() {
	int x, y, z;
	scanf ("%d%d%d", &x, &y, &z);
	swap(x, y);
	swap(x, z);
	printf ("%d %d %d\n", x, y, z);
	
    return 0;
}


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

int main(void){
    int n = 0; 

    scanf("%d", &n);

    if(n % 10 == 3){
        printf("bon\n");
    }else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
        printf("pon\n");
    }else{
        printf("hon\n");
    }

    return 0;

} 


Measured memory_bytes: 3764
N, Q = map(int, input().split())
S = input()

AC = [0] * N

flag = 0
for i, s in enumerate(S):
    if s == 'C':
        if flag == 1:
            AC[i] = AC[i - 1] + 1
            flag = 0
        else:
            AC[i] = AC[i - 1]
            flag = 0
    elif s == 'A':
        AC[i] = AC[i - 1]
        flag = 1
    else:
        AC[i] = AC[i - 1]
        flag = 0


ans = [0] * Q
for q in range(Q):
    l, r = map(lambda x: int(x) - 1, input().split())
    ans[q] = AC[r] - AC[l]

for q in range(Q):
    print(ans[q])


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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)
#define FORR(i,a,b) for (int i = a; i <= b; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

const int MX = 105;
int n, a, ant = -1, res = 0;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;

		if (a == ant) {
			res++;
			ant = -1;
		} else ant = a;
	}

	cout << res << endl;

	return 0;
}

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

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

    ll n, k;
    cin >> n >> k;
    ll ans =0;

    if (k == 0)
    {
        cout << n * n << endl;
        return 0;
    }

    forx(i, 1, n + 1)
    {
        if (i - 1 >= k)
        {
            ans += n / i * (i - k);
            ans += max(0LL, (n % i) - k + 1);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum K = 30;

long solve(long A, long B, long C, long D) {
  long ans = abs(A - C) + abs(B - D);
  foreach_reverse (k; 0 .. K) {
    // blocked by r * r
    const r = 3L^^k;
    const a = A / r;
    const b = B / r;
    const c = C / r;
    const d = D / r;
    if (a == c && a % 3 == 1) {
      long y = min(b, d) + 1;
      for (; y % 3 != 1; ++y) {}
      if (y < max(b, d)) {
        const x0 = a * r - 1;
        const x1 = a * r + r;
        ans = abs(B - D) + min(abs(A - x0) + abs(C - x0), abs(A - x1) + abs(C - x1));
        break;
      }
    }
    if (b == d && b % 3 == 1) {
      long x = min(a, c) + 1;
      for (; x % 3 != 1; ++x) {}
      if (x < max(a, c)) {
        const y0 = b * r - 1;
        const y1 = b * r + r;
        ans = abs(A - C) + min(abs(B - y0) + abs(D - y0), abs(B - y1) + abs(D - y1));
        break;
      }
    }
  }
  return ans;
}

void main() {
  try {
    for (; ; ) {
      const numCases = readInt();
      foreach (caseId; 0 .. numCases) {
        const A = readLong() - 1;
        const B = readLong() - 1;
        const C = readLong() - 1;
        const D = readLong() - 1;
        const ans = solve(A, B, C, D);
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 1404
const main = function(K) {
    var nums = [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]
    console.log(nums[K-1])
}

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


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//ll dp[100005];
int main()
{
	dhoom;
	int a, b;
	cin >> a >> b;
	cout << max(max(a + b , a - b) , a * b) << endl;
	return 0;
} 



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, h[101];

int main() {
	cin >> n;
	inc(i, n) { cin >> h[i]; }
	
	int ans = 0;
	inc(i, n) { ans += max(0, h[i] - h[i + 1]); }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main() {
    double r;
    cin >> r;
    double area = r * double (r) * M_PI;
    double circ = 2 * double (r) * M_PI;
    cout << fixed << area << " " << fixed << circ << endl;
    return 0;
}


Measured memory_bytes: 3284
#include <stdio.h>

int main(void){

	int i, j, n, a;
	int card[5][16] = {0};

	scanf("%d", &n);
		for(i = 1;i <= n;i++){
			char c;
		scanf(" %c %d", &c, &a);
			if(c == 'S') {
				card[0][a-1]=1;
			}

		else if(c == 'H'){
			card[1][a-1]=1;
		}

		else if(c == 'C'){
			card[2][a-1]=1;
		}

		else{
			card[3][a-1]=1;
		}
	}
	for(i = 0;i < 4;i++) {
		for(j = 0;j < 13;j++){
			char m;
			if(card[i][j] == 0){
				if(i == 0){
					m='S';
				}

				else if(i == 1){
					m='H';
				}

				else if(i == 2){
					m='C';
				}

				else{
					m='D';
				}
				printf("%c %d\n", m, j + 1);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)


int main()
{
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	int sum;
	int ans = 1000000;
	for (int i = 1; i <= 100; i++)
	{
		sum = 0;
		for (int t = 0; t < n; t++)
		{
			sum += pow(x[t] - i, 2);
		}
		if (sum < ans)
		{
			ans = sum;
		}
	}

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

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

int main() {
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (a < b) {
        if (a + t * v >= b + t * w) cout << "YES";
        else cout << "NO";
    } else {
        if (a + t * -1 * v <= b + t * -1 * w) cout << "YES";
        else cout << "NO";
    }

    return 0;
}


Measured memory_bytes: 3632
N=int(input())
A=[0 for j in range(N)]
B=[[] for j in range(N)]
for i in range(N):
 A[i]=int(input())
 for j in range(A[i]):
  x,y=map(int,input().split())
  B[i].append([x,y])
F=0
for i in range(2**N):
 E=0
 Sui=[0]*N
 for j in range(N):
  if ((i >> j) & 1):
   Sui[j]+=1
 E=0
 for k in range(N):
  if Sui[k]==0:
   E+=1
  else:
   D=0
   for l in range(A[k]):
    if (Sui[B[k][l][0]-1]+B[k][l][1])%2==0:
     D+=1
   if D==A[k]:
    E+=1
 if E==N:
  H=0
  for h in range(N):
   H+=Sui[h]
  F=max(F,H)
print(F)

Measured memory_bytes: 44268
// https://atcoder.jp/contests/dp/tasks/dp_b
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int func(vector<int> h , int n , int k){
     vector<int> dp(n+1 ,INT_MAX ); 
    dp[1] = 0;
    for(int i = 2; i <= n ;i++){
        for(int j = 1 ; j<=k;j++){
            if(i-j > 0){
                dp[i] = min( abs(h[i] - h[i-j]) + dp[i-j] , dp[i]);
            }
            else{
                break;
            }
        }
        
    }
    return dp[n];
}
int main(){
    int n , k;
    cin>>n>>k;
    vector<int>v(n+1);
    for(int i = 1;i <=n ; i++){
        cin>>v[i];
    }
    //cout<<dp_recursive(v ,1 ,n , 1)<<endl;
    cout<<func(v , n , k)<<endl;
    
}


Measured memory_bytes: 1408
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;

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

const ll MAX_N = 1e5 + 5;
ll n, ans;
ll Arr[MAX_N];
ll Brr[MAX_N];
ll rev[MAX_N];
ll lp[MAX_N];
ll pr[MAX_N];
ll ind;
bool OK;

unordered_map <ll, ll> cnt, mark;

void preProcess() {
	for (ll i = 2; i < MAX_N; i++) {
		if (lp[i] == 0) {
			lp[i] = i;
			pr[ind++] = i;
		}

		for (ll j = 0; j < ind && pr[j] <= lp[i] && i * pr[j] < MAX_N; j++)
			lp[i * pr[j]] = pr[j];
	}
}
pii calc (ll d) {
	ll res1 = 1, res2 = 1, tmp = 0;
	for (int i = 0; i < ind && pr[i] * pr[i] <= d; i++) {
		if (d % pr[i] == 0) {
			tmp = 0;
			int cnt = 0;
			while (d % pr[i] == 0) {
				cnt++;
				d /= pr[i];
			}

			cnt %= 3;
			if (cnt == 1) {
				res1 *= pr[i];
				res2 *= pr[i] * pr[i];
			}
			if (cnt == 2) {
				res1 *= pr[i] * pr[i];
				res2 *= pr[i];
			}
		}
		tmp++;
		if (tmp == 2000)
			break;
	}

	if (d != 1) {
		res1 *= d;
		res2 *= d * d;
	}
	return {res1, res2};
}


int main() {
	preProcess();
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> Arr[i];

		if ((ll)cbrt(Arr[i]) * (ll)cbrt(Arr[i]) * (ll)cbrt(Arr[i]) == Arr[i]) {
			i--;
			n--;
			OK = true;
		}
	}

	for (ll i = 0; i < n; i++) {
		pii p = calc(Arr[i]);

		Brr[i] = p.first;
		rev[i] = p.second;

		cnt[Brr[i]]++;
	}

	ans = n;
	for (int i = 0; i < n; i++)
		if (!mark[Brr[i]]) {
			mark[Brr[i]] = 1;
			mark[rev[i]] = 2;

			ans -= min(cnt[Brr[i]], cnt[rev[i]]);
		}

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

Measured memory_bytes: 26100
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<double> a(n);
    rep(i, n) cin >> a[i];
    double S = 1;
    rep(i, n) S *= a[i];
    double sum = 0;
    rep(i, n) sum += (S / a[i]);
    double ans = (double)S / (double)sum;
    printf("%.8lf\n", ans);
}

Measured memory_bytes: 256
class dice:
    def __init__(self, f0, f1, f2, f3, f4, f5):
        self.dice_num = [f0, f1, f2, f3, f4, f5]

    def roll_dice(self, command):
        for i in command:
            if i == 'N':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[1]
                self.dice_num[1] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[4]
                self.dice_num[4] = tmp

            if i == 'S':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[4]
                self.dice_num[4] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[1]
                self.dice_num[1] = tmp

            if i == 'E':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[3]
                self.dice_num[3] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[2]
                self.dice_num[2] = tmp

            if i == 'W':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[2]
                self.dice_num[2] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[3]
                self.dice_num[3] = tmp

    def print_topface(self):
        print(self.dice_num[0])


if __name__ == "__main__":
    num_list = list(map(int, input().split()))
    command_str = input()
    mydice = dice(*num_list)
    mydice.roll_dice(command_str)
    mydice.print_topface()



Measured memory_bytes: 5612
#include<iostream>
#include<deque>
#include<stack>
#include<string>
using namespace std;

int main() {
    int N;
    string S;
    deque<char> DQ;
    stack<char> ST;
    cin >> N >> S;
    for (int i = 0; i < N; i++) {
        if (S[i] == '(') {
            DQ.push_back('(');
            ST.push('(');
        }
        else {
            if (ST.empty()) {
                DQ.push_front('(');
                DQ.push_back(')');
            }
            else if (ST.top() == '(') {
                DQ.push_back(')');
                ST.pop();
            }
            else {
                DQ.push_front('(');
                DQ.push_back(')');
            }
        }
    }
    while (! ST.empty()) {
        DQ.push_back(')');
        ST.pop();
    }
    for (int i = 0; i != DQ.size(); i++) cout << DQ[i];
    cout << endl;
    return 0;
}

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

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

  string s, t;
  int ans = 0;
  cin >> s;

  t = s;
  reverse(t.begin(), t.end());

  for (int i = 0; i < s.size(); i++)
  {
    if(s[i] != t[i]) ans++;
  }
  
  cout << ans/2 << endl;
  
  return 0;
}

Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	S := sc.Next()

	if len(S)%2 == 1 {
		fmt.Println("No")
		return
	}
	for i := 0; i+1 < len(S); i += 2 {
		if S[i] == 'h' && S[i+1] == 'i' {

		} else {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	rep(i,n) cin >> a[i] >> b[i] >> c[i];
	vector<vector<int>> dp(n,vector<int> (3,-1));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];

	rep2(i,1,n){
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
	}

	int ans = -1;
	ans = max(ans,dp[n-1][0]);
	ans = max(ans,dp[n-1][1]);
	ans = max(ans,dp[n-1][2]);
	out(ans);
}



Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(void)
{
    string s;
    cin >> s;
    bool flag = true;
    rep(i, s.size() - 1) if(s[i] == s[i+1]) flag = false;
    flag?puts("Good"):puts("Bad");
    return 0;
}

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

typedef long long ll;

int main () {
    ll n;
    cin >> n;
    ll s[100];
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sum += s[i];
    }
    sort(s, s+n);
    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    else {
        for (int i = 0; i < n; i++) {
            if ((sum - s[i]) % 10 != 0) {
                cout << sum - s[i] << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
import sys

f_i = sys.stdin

V, E = map(int, f_i.readline().split())

# adjacency matrix
no_edge = 14001

adj = [[no_edge] * V for i in range(V)]

for i in range(V):
    adj[i][i] = 0

odd_b = 0 # bit DP to record odd vertex

ans = 0

# acceptance of input
for l_i in f_i:
    s, t, d = map(int, l_i.split())
    t_d = min(d, adj[s][t])
    adj[s][t] = t_d
    adj[t][s] = t_d
    odd_b ^= 1 << s
    odd_b ^= 1 << t
    ans += d

import math

if odd_b:
    # Warshall???Floyd Algorithm
    for k in range(V):
        for i in range(V):
            for j in range(V):
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j])
                
    # Minimum weighted matching
    mw = [no_edge] * (odd_b + 1)
    mw[0] = 0
    digits = int(math.log2(odd_b)) + 1

    for b in range(odd_b):
        for i in range(0, digits):
            if not (b & (1 << i)):
                for j in range(i + 1, digits):
                    if not (b & (1 << j)):
                        t_b = b + (1 << i) + (1 << j)
                        if t_b == t_b & odd_b:
                            t_w = mw[t_b]
                            mw[t_b] = min(t_w, mw[b] + adj[i][j])

    # Output
    ans += mw[odd_b]
    print(ans)
else:
    print(ans)

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

using namespace std;

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

Graph g;
ll a[100010];

ll dfs(int idx, int p) {
	if (g[idx].size() == 1) return a[idx];

	ll sum = 0;
	ll c_max = 0;
	for (int nex : g[idx]) {
		if (nex == p) continue;
		ll tmp = dfs(nex, idx);
		if (tmp == -1) return -1;
		sum += tmp;
		c_max = max(c_max, tmp);
	}

	ll res = 2 * a[idx] - sum;
	ll x = sum - a[idx];
	if (x < 0 || res < 0 || x > min(sum - c_max, sum / 2)) return -1;
	else return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	g = Graph(n);
	for (int i = 0; i < n - 1; i++) {
		int s, d;
		cin >> s >> d;
		s--;
		d--;
		g[s].push_back(d);
		g[d].push_back(s);
	}

	if (n == 2) {
		cout << (a[0] == a[1] ? "YES" : "NO") << endl;
		return 0;
	}

	int root;
	for (root = 0; root < n; root++) {
		if (g[root].size() != 1) break;
	}
	cout << (dfs(root, -1) == 0 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define SQ 320
//#define N 1000005
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,r,timer,mx;
ll a[100500], b[100500];
vector<ll> possibles;
int main() {
    //freopen("input.txt","r",stdin);
    ll ans = 0;
    cin >> n >> k;
    for (i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    possibles.push_back(k);
    for (i = 0; i < 30; i++)
        if ((k&(1<<i)) != 0)
        {
            ll x = (k&((1LL<<31)-(1<<i)));
            possibles.push_back(x-1);
        }
    for (i = 0; i < possibles.size(); i++)
    {
        ll val = possibles[i];
        ll cur_ans = 0;
        for (j = 0; j < n; j++)
            if ((val|a[j]) == val)
                cur_ans += b[j];
        ans = max(ans, cur_ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
<?php
  list($n, $k) = explode(" ", trim(fgets(STDIN)));
  
  $ans = 0;
  for ($i=1; $i<=$n; $i++) {
    $x = intdiv($k+$i-1, $i);
    $p = ceil(log($x, 2));
//    echo $p.PHP_EOL;
    $ans += (1 / $n) * pow(1/2, $p);
  }

  echo $ans;

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

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

int n, m, k;
ll ans;

ll power(ll x, ll y, ll z) {
  if (!y) return 1 % z;
  ll t = power(x, y >> 1, z);
  (t *= t) %= z;
  if (y & 1) (t *= x) %= z;
  return t;
}

ll f(int x) {
  if (x < 2) return 1;
  return f(x - 1) * x % MOD;
}

ll nCr(int n, int r) {
  ll ret = f(n);
  ll denom1 = power(f(r), MOD - 2, MOD);
  ll denom2 = power(f(n - r), MOD - 2, MOD);
  (ret *= denom1 * denom2 % MOD) %= MOD;
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      ll tmp = (ll)m * (1 + n - i) * (n - i) / 2 % MOD;
      (tmp += (ll)(i - 1) * j * (j - 1) / 2) %= MOD;
      (tmp += (ll)i * (1 + m - j) * (m - j) / 2) %= MOD;
      (ans += tmp) %= MOD;
    }
  (ans *= nCr(n * m - 2, k - 2)) %= MOD;
  cout << ans << "\n";
  return 0;
}

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

vector<int> p(200000);
vector<int> sz(200000, 1);

int find(int x) {
    while (p[x] != x) {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

void merge(int x, int y) {
    int a = find(x);
    int b = find(y);
    if (a == b) return;
    if (sz[a] < sz[b]) {
        p[a] = b;
        sz[b] += sz[a];
    } else {
        p[b] = a;
        sz[a] += sz[b];
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    rep(i, n) p[i] = i;
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        merge(x, y);
    }
    int ans = 0;
    rep (i, n) ans = max(ans, sz[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4660
n,p,i,a[51];main(){for(;~scanf("%d",&n),n;){for(a[n]=p=i=0;i<n;i++)scanf("%d",a+i);for(i=1;i<=n;i++)if(a[i-1]-a[i]+1)printf(i-p-1?n-i?"%d-%d ":"%d-%d\n":n-i?"%d ":"%d\n",a[p],a[i-1]),p=i;}exit(0);}

Measured memory_bytes: 600
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;
fn main() {
    input! {
        n:usize,
        a:[i32;n]
    }
    for i in 0..n {
        if a[i] % 2 != 0 {
            continue;
        };
        if a[i] % 3 != 0 && a[i] % 5 != 0 {
            println!("DENIED");
            return;
        }
    }
    println!("APPROVED");
}


Measured memory_bytes: 2088
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  ll n;
  cin >> n;
  const ll m = 753;
  ll ans = 1e9;
  while (n){
    ll x = n % 1000ll;
    setmin(ans, abs(x-m));
    n/=10ll;
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

6
1 1
7 1
2 2
6 2
1 3
7 3

 */

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, i, x=0;
    char op;
    
    for (i=0; ; i++){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='+'){
            x=a+b;
        }else if(op=='-'){
            x=a-b;
        }else if(op=='*'){
            x=a*b;
        }else if(op=='/'){
            x=a/b;
        }else{
            break;
        }
        printf("%d\n", x);
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,mod=1e9+7;
int n;
ll a[N],f[N];
int main()
{
    f[0]=1;
    for(int i=1;i<N;i++)
        f[i]=f[i-1]*4%mod;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    sort(a+1,a+1+n);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=(ans+a[i]*2*f[n-1]%mod)%mod;
        if(n-i-1>=0)
            ans=(ans+a[i]*4%mod*(n-i)%mod*f[n-i-1]%mod*f[i-1]%mod)%mod;
    }
    printf("%lld\n",ans);
}


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

using namespace std;
#define ll long long
#define r(i, n) for(int i=0;i<n;i++)

int main() {
    multimap<string, int> MAP;
    multimap<string, int>::iterator b, e;
    int num_query;
    cin >> num_query;
    int command, x;
    for (int loop = 0; loop < num_query; loop++) {
        string tmp;
        cin >> command;
        if (command == 0) {
            cin >> tmp >> x;
            MAP.insert(make_pair(tmp,x));
        } else if (command == 1) {
            cin >> tmp;
            multimap <string,int>::iterator i;
            //for (i = MAP.equal_range(tmp).first;i!=MAP.equal_range(tmp).second;i++)cout<<(*i).second<<endl;
            for (i = MAP.lower_bound(tmp);i!=MAP.upper_bound(tmp);i++)cout<<(*i).second<<endl;
        } else if (command == 2) {
            cin >> tmp;
            MAP.erase(tmp);
        } else {
            string l, r;
            cin >> l >> r;
            b=MAP.lower_bound(l);
            e=MAP.upper_bound(r);
            for(;b!=e;b++) {
                cout << b->first << " " << b->second << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 24768
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>

using namespace std;

#define NMAX 200001

int a[NMAX];
int imos[NMAX];

void reset(int n) {
    for(int i = 0; i < n; i++) imos[i] = 0;
}

int max(int a, int b) {
    if(a > b) return a;
    else return b;
}

int min(int a, int b) {
    if(a > b) return b;
    else return a;
}

int get_int() {
    int res = 0;
    char c = getchar();
    while(c != EOF && c != ' ' && c != '\n') {
        res *= 10;
        res += c - '0';
        c = getchar();
    }
    return res;
}

void put_int(int n) {
    char c[30];
    int sz = 0;
    c[sz++] = (n % 10) + '0';
    n /= 10;
    while(n > 0) {
        c[sz++] = (n % 10) + '0';
        n /= 10;
    }
    for(int i = sz-1; i >= 0; i--) {
        putchar(c[i]);
    }
    putchar('\n');
}

int main(){

    int n, k;
    n = get_int();
    k = get_int();
    for(int i = 0; i < n; i++) a[i] = get_int();

    for(int itr = 0; itr < k; itr++) {
        reset(n+1);
        for(int i = 0; i < n; i++){
            imos[max(0, i - a[i])]++;
            imos[min(n, i + a[i] + 1)]--;
        }
        int acc = 0;
        for(int i = 0; i < n; i++){
            acc += imos[i];
            a[i] = acc;
        }
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum == n * n) break;
    }

    for(int i = 0; i < n; i++) put_int(a[i]);
    return 0;
}


Measured memory_bytes: 5168
#include <iostream>
#include <string>
#include <vector>
#define lli long long int
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c){
		cout << "Yes";
	}
  else{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
import bisect
s=input()
t=input()
s_set=set([i for i in s])
t_set=set([i for i in t])
if t_set-s_set&t_set:
  print(-1)
  exit()
a={}
for i in t_set:
  a[i]=[]
  for k,j in enumerate(s):
    if j==i:
      a[i].append(k)
  a[i].sort()
ans=0
j=0
for i in t:
  if a[i][-1]<j:
    ans+=len(s)
    j=0
  k=bisect.bisect_left(a[i],j)
  j=a[i][k]+1
print(ans+j)
      

Measured memory_bytes: 55472
(*
 * forall l r (p : forall n, l < n <= r -> bool),
 *   ( exists m,
 *     l < m <= r /\ forall n H, p n H = true <-> m <= n ) ->
 *   { m |
 *     l < m <= r /\ forall n H, p n H = true <-> m <= n }
 *)
let rec lower_bound l r p =
  if r <= 1 + l
  then r
  else let m = (l + r) / 2 in
       if p m
       then lower_bound l m p
       else lower_bound m r p

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ ->
    Scanf.scanf "%d " @@ fun a -> a in
  let sadness b =
    Array.fold_left ( + ) 0 @@
    Array.mapi (fun i a -> abs (a - b - i - 1)) as_
  in
  Printf.printf "%d\n" @@ sadness @@ lower_bound (-10000000000) 10000000000 @@ fun i ->
      0 <= sadness (i + 1) - sadness i


Measured memory_bytes: 22528
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < 3; ++i){
        if(s[i] != t[i]) ans++;
    }
    cout << 3 - ans << endl;
	return 0;
}


Measured memory_bytes: 256