akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

template <typename T>
struct segtree{
    int n;
    T UNIT;
    vector<T> dat;
    segtree(int n_, T unit){
        UNIT = unit;
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(2*n);
        for(int i = 0; i < 2*n; i++) dat[i] = UNIT;
    }

    T calc(T a, T b){
        T ans;
        ans = max(a, b);
        return ans;
    }
    void insert(int k, T a){
        dat[k+n-1] = a;
    }
    void update_all(){
        for(int i = n-2; i >= 0; i--){
            dat[i] = calc(dat[i*2+1], dat[i*2+2]);
        }
    }
    //k番目の値(0-indexed)をaに変更
    void update(int k, T a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = calc(dat[k*2+1], dat[k*2+2]);
        }
    }

    //[a, b)
    //区間[a, b]へのクエリに対してはquery(a, b+1)と呼ぶ
    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;
        if(r <= a || b <= l) return UNIT;
        if(a <= l && r <= b) return dat[k];
        else{
            T vl = query(a, b, k*2+1, l, (l+r)/2);
            T vr = query(a, b, k*2+2, (l+r)/2, r);
            return calc(vl, vr);
        }
    }
};
typedef long long ll;
typedef pair<ll, ll> P;
int N;
ll X[200005], D[200005];
P p[200005];

const ll MOD = 998244353;

ll dp1[200005], dp2[200005];
int rem[200001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> X[i] >> D[i];
        p[i] = P(X[i], D[i]);
    }
    sort(p, p+N);
    int cur = p[0].first+p[0].second;
    for(int i = 0; i < N; i++){
        X[i] = p[i].first;
        D[i] = p[i].second;
    }
    X[N] = 2e+9;
    // rem[N-1] = N;
    segtree<ll> sgt(N+1, 0);
    for(int i = N-1; i >= 0; i--){
        auto ptr = lower_bound(X, X+N, X[i]+D[i]);
        ptr--;
        int k = ptr-X;
        if(k == i) rem[i] = i+1;
        else{
            rem[i] = sgt.query(i+1, k+1);
        }
        sgt.update(i, rem[i]);
        // cout << rem[i] << ' ';
    }
    // cout << endl;
    dp1[N] = 0;
    dp2[N] = 1;
    for(int i = N-1; i >= 0; i--){
        dp1[i] = dp1[i+1]+dp2[i+1];
        dp2[i] = dp1[rem[i]]+dp2[rem[i]];
        dp1[i] %= MOD;
        dp2[i] %= MOD;
    }
    cout << (dp1[0]+dp2[0])%MOD << endl;
}

Measured memory_bytes: 14464
K = int(input())
A = [int(a) for a in input().split()]
    
if A[K-1] == 2:
    l = 2
    r = 2
    flag = True
    for i in range(K-2, -1, -1):
        r += A[i+1]-1
        if l%A[i] > 0:
            l += A[i]-(l%A[i])
        r -= r%A[i]
        if r < l:
            flag = False
            break
    if flag:
        r += A[0]-1
        ans = str(l) + " " + str(r)
    else:
        ans = -1
else:
    ans = -1

print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

const ll mod=1e9+7;

void Eratos(vector<bool> &IsPrime,ll n){
    rep(i,n) IsPrime[i]=1;
    IsPrime[0]=IsPrime[1]=0;
    for(ll i=2;i*i<n;i++){
        if(IsPrime[i]){
            for(ll j=i;i*j<n;j++){
                IsPrime[i*j]=0;
            }
        }
    }
}

int main(){
    ll n;
    cin>>n;
    vector<bool> IsPrime(n+1);
    Eratos(IsPrime,n+1);
    vector<ll> cnt(n+1,0);
    for(ll i=2;i<=n;i++){
        if(IsPrime[i]){
            for(ll j=i;j<=n;j*=i){
                cnt[i]+=n/j;
            }
        }
    }
    ll ans=1;
    rep(i,n+1){
        if(cnt[i]!=0){
            ans*=cnt[i]+1;
            ans%=mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, long long M, vector<long long> a, vector<long long> b){
	
}

int main(){	
	long long N;
	long long M;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> b(M-1+1);
	vector<long long> a(M-1+1);
	map<ll, ll> m;
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&a[i]);
		m[a[i]]++;
		scanf("%lld",&b[i]);
		m[b[i]]++;
	}
	bool f = true;
	for (auto x : m) {
		if (x.second%2 == 1) f = false;
	}
	if (f) cout << "YES" << endl; else cout << "NO" << endl;
	return 0;
}



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

#define cMaxLimit 250

typedef struct {
	int key;
	int parent;
	int leftChild;
	int rightChild;
}Node;

void print(Node node[], int maxNum) {
	for (int i = 1; i <= maxNum; i++) {
		cout << "node " << i << ": ";
		cout << "key = " << node[i].key << ", ";
		if (node[i].parent != -1) {
			cout << "parent key = " << node[i].parent << ", ";
		}
		if (node[i].leftChild != -1) {
			cout << "left key = " << node[i].leftChild << ", ";
		}
		if (node[i].rightChild != -1) {
			cout << "right key = " << node[i].rightChild << ", ";
		}
		cout << endl;
	}
}

int main() {
	int nodeMaxNum;
	Node node[cMaxLimit+5];//????????????????????????1-???????????????????????????
	cin >> nodeMaxNum;

	for (int i = 1; i <= nodeMaxNum; i++) {
		int key; cin >> key;
		node[i].key = key;
		node[i].leftChild = -1;
		node[i].rightChild = -1;
		node[i].parent = -1;
	}
	for (int i = 1; i <= nodeMaxNum; i++) {
		cout << "node " << i << ": ";
		cout << "key = " << node[i].key << ", ";
		if (i/2 >= 1) {
			cout << "parent key = " << node[i/2].key << ", ";
		}
		if (i*2 <= nodeMaxNum) {
			cout << "left key = " << node[i * 2].key << ", ";
		}
		if (i*2+1 <= nodeMaxNum) {
			cout << "right key = " << node[i * 2 + 1].key << ", ";
		}
		cout << endl;
	}
	//for (int i = 1; i <= nodeMaxNum; i++) {
	//	if (i / 2 >= 1) {
	//		node[i].parent = node[i / 2].key;
	//	}
	//	if (i * 2 <= nodeMaxNum) {
	//		node[i].leftChild = node[i * 2].key;
	//	}
	//	if (i * 2 + 1 <= nodeMaxNum) {
	//		node[i].rightChild = node[i * 2 + 1].key;
	//	}
	//}

//	print(node, nodeMaxNum);

	return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
void max(int *x,int *y)
{
	if(*x>*y)
	{
		int t=*x;
		*x=*y;
		*y=t;
	}
}
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	max(&a,&b);
	max(&a,&c);
	max(&b,&c);
	printf("%d %d %d\n",a,b,c);
	return 0;
}



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

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    while(A[N-2] != 0)
    { 
        ll not0i;
        for(int i = 0; i < N; i++)
        {
            if(A[i] == 0)continue;
            not0i = i;
            break;
        }
        
        for(int i = not0i+1; i < N; i++)
        {
            A[i] %= A[not0i];
        }
        sort(A.begin(),A.end());
    }

    cout << A[N-1] << endl;
    return 0;

    


}

Measured memory_bytes: 1024
A, B, C , X, Y = map(int, input().split())

if (A + B <= C * 2):
  print(A * X + B * Y)
else:
  #Aに合わせる
  price1 = C * 2 * X + B * max(Y - X, 0)
  #Bに合わせる
  price2 = C * 2 * Y + A * max(X - Y, 0)
  print(min(price1, price2))

Measured memory_bytes: 3060
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

ans = 0

# (i+1)回目に下に移動した場合のアメの獲得数
for i in range(N):
    tmp = sum(A1[:i+1]) + sum(A2[i:])
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const ll inf = (1LL<<31)-1;
const long long MOD = 1000000007;

struct SegmentTree {
    int n;
    vector<ll> node;

public:
    // 元配列 v をセグメント木で表現する
    SegmentTree(vector<ll> v) {
        // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
        int sz = v.size();
        n = 1; while (n < sz) n *= 2;
        node.assign(2 * n - 1, inf);

        // 最下段に値を入れたあとに、下の段から順番に値を入れる
        // 値を入れるには、自分の子の 2 値を参照すれば良い
        for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(ll x, ll val) {
        // 最下段のノードにアクセスする
        x += (n - 1);

        // 最下段のノードを更新したら、あとは親に上って更新していく
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2 * x + 1], node[2 * x + 2]);
        }
    }

    // 要求区間 [a, b) 中の要素の最小値を答える
// k := 自分がいるノードのインデックス
// 対象区間は [l, r) にあたる

    int getmin(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
        // 最初に呼び出されたときの対象区間は [0, n)
        if (r < 0) r = n;

        // 要求区間と対象区間が交わらない -> 適当に返す
        if (r <= a || b <= l) return inf;

        // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
        if (a <= l && r <= b) return node[k];

        // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
        // 左側の子を vl ・ 右側の子を vr としている
        // 新しい対象区間は、現在の対象区間を半分に割ったもの
        ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};

int main() {
    ll n, x;
    cin >> n >> x;
    vector<ll> v(n*2);
    rep(i, n) {
        cin >> v[i];
        v[i + n] = v[i];
    }
    SegmentTree tree(v);
    ll ans = INF;
    vector<ll> V = v;
    rep(i, n ) {
        ll A = 0;
        repd(j, n, n * 2) {
            V[j] = min(V[j], v[j - i]);
            A += V[j];
        }
        A += i * x;
        ans= min(ans, A);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
int dp[1 << 18][55];
pii a[N];
int n;

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> a[i].first;
    for (int i = 1; i <= n; i++)cin >> a[i].second;
    for (int i = 0; i < 1 << n; i++) {
        for (int j = 0; j <= 50; j++)dp[i][j] = 0x3f3f3f3f;
    }
    dp[0][1] = 0;
    for (int i = 1; i < 1 << n; i++) {
        int t = __builtin_popcount(i);
        for (int p = 1; p <= n; p++) {
            if ((i >> (p - 1)) & 1) {
                int j = (abs(t - p) & 1) ? a[p].second : a[p].first, num = 0;
                for (int k = p + 1; k <= n; k++)if ((i >> (k - 1)) & 1)num++;
                for (int k = 1; k <= j; k++)dp[i][j] = min(dp[i][j], dp[i ^ (1 << (p - 1))][k] + num);
            }
        }
    }
    int ans = 0x3f3f3f3f;
    for (int i = 1; i <= 50; i++)ans = min(ans, dp[(1 << n) - 1][i]);
    cout << (ans == 0x3f3f3f3f ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 59960
# Matsuzaki Number
# ??????: http://d.hatena.ne.jp/sndr/20120110/1326189971

require 'prime'
require 'scanf'

def prime?(v)
  Prime.prime?(v, Prime::EratosthenesGenerator.new)
end

def next_prime(n)
  while true
    n += 1
    return n if prime?(n)
  end
end

def matsuzaki(n, p)
  primes = []
  totals = []

  (n+1 .. Float::INFINITY).each do |i|
    if prime?(i)
      primes << i
    end 

    break if primes.size >= p
  end

  (0 ... p).each do |i|
    (i ... p).each do |j|
      totals << primes[i] + primes[j]
    end
  end

  totals.sort[p - 1]
end

while true
  line = gets
  break unless line

  n, p = line.scanf('%d %d')
  break if n == -1 && p == -1

  puts matsuzaki(n, p)
end

Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

template<typename T>
class CumulativeSum {
private:
    vector<T> data;

public:
    explicit CumulativeSum(size_t size) : data(size, 0) {}

    void update(size_t index, T value) {
        data[index] += value;
    }

    virtual void build() {
        for (size_t index = 0; index + 1 < data.size(); index++) data[index + 1] += data[index];
    }

    T sum(size_t index) {
        if (index < 0) return 0;
        return data[index];
    }

    T sum_all() {
        return sum(data.size() - 1);
    }

    /// [left, right)
    T query(size_t left_index, size_t right_index) {
        return sum(right_index - 1) - sum(left_index - 1);
    }
};

template<typename T>
class CountingCharacterIntervalNumericMultiples : public CumulativeSum<T> {
private:
    string huge_number;
    long long int radix, mod, remainder;
    vector<T> data;

    int char_convert(const char &input) {
        int now = input - '0';
        if (now >= 10) now = (input - 'A') + 10;
        return now;
    }

public:
    explicit CountingCharacterIntervalNumericMultiples(string number, long long int radix, long long int mod, long long int remainder) : huge_number(number), radix(radix), mod(mod), remainder(remainder), data(number.length()), CumulativeSum<T>(number.length()) {}

    void build() override {
        ll now = 0, base = 1;
        data[0] = 1;
        for (size_t index = 0; index < huge_number.length(); index++) {
            now = (now + char_convert(huge_number[index]) * base) % mod;
            CumulativeSum<T>::update(index, data[(now + remainder) % mod]);
            base = (base * radix) % mod;
            data[now]++;
        }
        CumulativeSum<T>::build();
    }

    // C++17 or later
    bool is_viable() {
        return (gcd(radix, mod) == 1);
    }
};

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    auto sum = CountingCharacterIntervalNumericMultiples<ll>(S, 10, 2019, 0);
    sum.build();
    cout << sum.sum_all() << endl;
}

Measured memory_bytes: 6956
N = int(input())
A = [int(x) for x in input().split()]
B = list()
cut = 0
trend = ""

for i in range(N):
	B.append(A[i])
	if len(B) == 2 or trend == "neutral":
		if min(B) == max(B):
			trend = "neutral"
		elif A[i] == max(B):
			trend = "up"
		elif A[i] == min(B):
			trend = "down"
	elif len(B) > 2:
		if trend == "up" and A[i] < B[-2]:
			cut += 1
			B = [A[i]]
		elif trend == "down" and A[i] > B[-2]:
			cut += 1
			B = [A[i]]
print(cut + 1)


Measured memory_bytes: 14480
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define mod 1000000007

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};

int main(){

  unsigned long long n,k,ans;

  //入力を受け取る
  cin >> n;
  n--;

  //ans = 0.5 * n * (n+1) (1,...,n-1の和） 
  //桁あふれしないように、変数kで途中計算を受け取る
  if(n%2==0){
    k=n/2;
    ans = k*(n+1);
  }else{
    k=(n+1)/2;
    ans = n*k;
  }
 
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
package main

import "fmt"

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return nums
}

func main() {
	matrixNum := scanNums(2)
	nums := scanNums(2)

	black := matrixNum[0]*matrixNum[1] - nums[0]*matrixNum[1] - nums[1]*matrixNum[0] + nums[0]*nums[1]
	fmt.Println(black)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

struct Dish {
    int i;
    ll a;
    ll b;
    bool operator<( const Dish& right ) const {
            return (a+b) < (right.a + right.b);
    }
};

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N;
    cin >> N;
    priority_queue<Dish> que;
    rep(i, N) {
        int A, B;
        cin >> A >> B;

        Dish d;
        d.i = i;
        d.a = A;
        d.b = B;
        que.push(d);
    }

    //while (!que.empty()) {
    //    DEBUG(que.top().i);
    //    DEBUG(que.top().a);
    //    DEBUG(que.top().b);
    //    que.pop();
    //}
    // cout << "------------" << endl;
    // while (!queB.empty()) {
    //     DEBUG(queB.top().i);
    //     DEBUG(queB.top().a);
    //     DEBUG(queB.top().b);
    //     DEBUG(queB.top().diff);
    //     queB.pop();
    // }

    bool isA = true;
    ll sumA = 0;
    ll sumB = 0;
    while (!que.empty()) {
        if (isA) {
    //        DEBUG(que.top().a);
            sumA += que.top().a;
            isA = false;
        } else {
    //       DEBUG(que.top().b);
            sumB += que.top().b;
            isA = true;
        }
        que.pop();
    }
   // DEBUG(sumA);
   // DEBUG(sumB);
    cout << (sumA - sumB) << endl;

}

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

int main() {
	int n, c, b = 2000000000, a = -1000000001;
	cin >> n;
	for (int i = 0; i < n; i++) {
	    cin >> c;
	    a = max(c - b, a);
	    b = min(c, b);
	}
	cout << a << endl;
}



Measured memory_bytes: 3116
#include <deque>
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;

typedef struct point {
  int x, y;
} point;

int red_black(point size, point sp, vector<vector<char>> &room) {
  deque<point> queue(0);
  queue.push_front(sp);
  int sum = 0;

  while (queue.size() > 0) {
    auto p = queue.front();
    queue.pop_front();

    auto x = p.x;
    auto y = p.y;
    if (x < 0 || y < 0 || x == size.x || y == size.y) {
      continue;
    }

    auto &tile = room[y][x];
    if (tile == '#') {
      continue;
    }

    sum += 1;
    tile = '#';
    queue.push_front(point{x + 1, y});
    queue.push_front(point{x - 1, y});
    queue.push_front(point{x, y + 1});
    queue.push_front(point{x, y - 1});
  }

  return sum;
}

int main() {
  int w, h, sx, sy;
  char c;
  while (true) {
    cin >> w >> h;
    if (w == 0) {
      break;
    }

    vector<vector<char>> room(h, vector<char>(w));
    rep(y, h) {
      rep(x, w) {
        cin >> c;
        if (c == '@') {
          sx = x;
          sy = y;
        }
        room[y][x] = c;
      }
    }

    auto result = red_black(point{w, h}, point{sx, sy}, room);
    cout << result << endl;
  }
}



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

int main()
{
    int a,b,c,d,e,k;
    scanf("%d\n%d\n%d\n%d\n%d\n%d",&a,&b,&c,&d,&e,&k);
    if (b-a<=k&&c-a<=k&&d-a<=k&&e-a<=k&&c-b<=k&&d-b<=k&&e-b<=k&&d-c<=k&&e-c<=k&&e-d<=k)
        printf("Yay!");
    else
        printf(":(");
    return 0;
}

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

ll n;
int ans = 0;
void dfs(ll x, int a, int b, int c){
    if(x>n) return;
    if(a&b&c) ans++;
    dfs(10*x+3,1,b,c);
    dfs(10*x+5,a,1,c);
    dfs(10*x+7,a,b,1);
}

int main(){
    cin>>n;
    dfs(0,0,0,0);
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)

using namespace std;

int main()
{
  char keitai[10][6] = {{'*', '*', '*', '*', '*', '*'},
                        {'.', ',', '!', '?', ' ', '*'},
                        {'a', 'b', 'c', '*', '*', '*'},
                        {'d', 'e', 'f', '*', '*', '*'},
                        {'g', 'h', 'i', '*', '*', '*'},
                        {'j', 'k', 'l', '*', '*', '*'},
                        {'m', 'n', 'o', '*', '*', '*'},
                        {'p', 'q', 'r', 's', '*', '*'},
                        {'t', 'u', 'v', '*', '*', '*'},
                        {'w', 'x', 'y', 'z', '*', '*'},
  };
  string s;
  int x , c;
  char p;
  int n;
  cin >> n;
  cin.ignore();
  REP(k, n){
    getline(cin, s);
    x = c = 0;
    p = '\0';
    REP(i, s.size()){
      int j;
      j = s[i] - '0';
      if(j){
        if(x == j){
          if(keitai[j][c + 1] == '*'){
            c = 0;
            p = keitai[j][c];
          }else{
            c++;
            p = keitai[j][c];
          }
        }else{
          c = 0;
          p = keitai[j][c];
        }
      }else{
        if(p != '\0')
          cout << p;
        p = '\0';
      }
      x = j;
    }
    cout << endl;
  }
}

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

string name(ll n){
    string s = "";
    if(n<=26){
        return s+char(96+n);
    }
    else if(n%26 == 0){
        s += char(96+26);
        return s+name(n/26-1);
    }
    else{
        s += char(96+n%26);
        return s+name(n/26);
    }
}

int main(){
    ll n;
    cin >> n;
    
    string ans = name(n);
    reverse(ans.begin(), ans.end());
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
import Control.Applicative

import Control.Monad
    (replicateM)
    
import Data.List
    (intercalate)

data Operator
    = Replace Int Int String
    | Reverse Int Int
    | Print Int Int

type Environment
    = (String, [String])

type Problem
    = (String, [Operator])

type Result
    = [String]

operate :: Environment -> Operator -> Environment

operate (text, outputs) (Replace from to sub)
    = (before ++ sub ++ after, outputs) where
        before = take from text
        after = drop (to + 1) text
        
operate (text, outputs) (Reverse from to)
    = (before ++ sub ++ after, outputs) where
        before = take from text
        sub = reverse $ drop from $ take (to + 1) text
        after = drop (to + 1) text
        
operate (text, outputs) (Print from to)
    = (text, outputs ++ [picked]) where
        picked = drop from $ take (to + 1) text

solve :: Problem -> Result

solve (text, operators)
    = snd $ foldl operate (text, []) operators

output :: Result -> String

output result
    = intercalate "\n" result
    
input :: IO Problem

input
    = do
        text <- getLine
        n <- read <$> getLine
        operators <- replicateM n inputOperator
        return (text, operators)
        
inputOperator :: IO Operator

inputOperator
    = parseOperator <$> words <$> getLine
            
parseOperator :: [String] -> Operator

parseOperator ["replace", from, to, sub]
    = Replace (read from) (read to) sub
    
parseOperator ["reverse", from, to]
    = Reverse (read from) (read to)
    
parseOperator ["print", from, to]
    = Print (read from) (read to)

main :: IO ()

main
    = putStrLn <$> output =<< solve <$> input

Measured memory_bytes: 5652
#include<stdio.h>

int main(void){
  long long int N,C,ans,work;
  scanf("%lld%lld",&N,&C);
  long long int x[N],v[N],value[N],dist[N],value2[N],dist2[N];
  scanf("%lld%lld",&x[0],&v[0]);
  value[0] = 0;
  dist[0] = 0;
  if(v[0]-x[0] > 0){
    value[0] = v[0]-x[0];
    dist[0] = x[0];
  }
  value2[0] = 0;
  dist2[0] = 0;
  if(v[0]-2*x[0] > 0){
    value2[0] = v[0]-2*x[0];
    dist2[0] = 2*x[0];
  }
  work = v[0];
  for(int i=1;i<N;i++){
    scanf("%lld%lld",&x[i],&v[i]);
    work += v[i];
    if(work-x[i] > value[i-1]){
      value[i] = work-x[i];
      dist[i] = x[i];
    }
    else{
      value[i] = value[i-1];
      dist[i] = dist[i-1];
    }
    if(work-2*x[i] > value2[i-1]){
      value2[i] = work-2*x[i];
      dist2[i] = 2*x[i];
    }
    else{
      value2[i] = value2[i-1];
      dist2[i] = dist2[i-1];
    }
  }
  ans = value[N-1];
  work = 0;
  for(int i=N-1;i>0;i--){
    work += v[i];
    long long int temp = work-(C-x[i]),temp1;
    temp1 = temp+value[i-1]-(C-x[i]);
    temp = temp+value2[i-1];
    if(temp1 > temp)
      temp = temp1;
    if(ans < temp)
      ans = temp;
  }
  work += v[0];
  if(ans < work-(C-x[0]))
    ans = work-(C-x[0]);

  printf("%lld\n",ans);
  return 0;

}


Measured memory_bytes: 4864
//gcc -std=gnu11 -O2 -o a.out Main.c -lm
//http://abc044.contest.atcoder.jp/tasks/abc044_b
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
#include <math.h>
#include <string.h>

int main(void)
{
#define N_MAX	100

	int ret;
	int i,j;
	char strBuf[N_MAX+1];
	int flag = 0; //0は正常
	int len;
	struct {
		
	}checkText;
	
	//-------------------------------------
	//Input process
	//-------------------------------------
	ret = scanf("%s", (char *)&strBuf);
	len = strlen(strBuf);

	//-------------------------------------
	//Calc process
	//-------------------------------------
	for(i=0;i<24;i++){
		int cnt = 0;
		for(j=0;j<len;j++){
			if( strBuf[j] == (0x61 + i)){
				cnt++;
			}
		}
		if(cnt%2){
			flag =1;
			break;
		}
	}

	//-------------------------------------
	//Output process
	//-------------------------------------
	printf("%s\n", ((!flag)?("Yes"):("No")));

	return(0);
}







Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

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

  vector<int> x(N + 1), y(N + 1), t(N + 1);
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; ++i) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 1; i <= N; ++i) {
    int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    int td = t[i] - t[i - 1];
    if ((td < dist) || ((td - dist) & 1)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

int main()
{
    long long int N, M, i, A, B, A_top, B_top;
    cin >> N >> M;
    vector<long long int> group(N + 1); //1 kara N, minus is next
    for (i = 1; i <= N; i++)
    {
        group[i] = 1;
    }
    for (i = 0; i < M; i++)
    {
        cin >> A >> B;
        A_top = A;
        B_top = B;
        while (group[A_top] < 0)
        {
            A_top = group[A_top] * (-1);
        }
        while (group[B_top] < 0)
        {
            B_top = group[B_top] * (-1);
        }
        if (A_top != B_top)
        {
            if (group[A_top] < group[B_top])
            {
                group[B_top] += group[A_top];
                group[A_top] = B_top * (-1);
            }
            else
            {
                group[A_top] += group[B_top];
                group[B_top] = A_top * (-1);
            }
        }
    }
    long long int result = 1;
    for (i = 1; i <= N; i++)
    {
        if (group[i] > result)
        {
            result = group[i];
        }
    }
    cout << result << endl;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    string str;
    cin>>str;
    int n=str.size();
    if(n<=k)
    {
        cout<<str<<"\n";
    }
    else
    {
        string str1=str.substr(0,k);
        str1+="...";
        cout<<str1<<"\n";
    }

}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <set>
#include <queue>
using namespace std;

int main(void) 
{
    long long N, M;
    std::vector<int> A,B;
    cin >> N >> M;
    A.resize(M);
    B.resize(M);
    std::vector<std::set<int>> connected(200001);
    for (int i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i];
        connected[A[i]].insert(B[i]);
        connected[B[i]].insert(A[i]);
    }

    std::queue<int> q;
    std::vector<int> v(200001,-1);
    q.push(1);
    v[1] = 1;
    while (false == q.empty())
    {
        int current = q.front();
        q.pop();
        for (auto child : connected[current]) 
        {
            if (-1 == v[child])
            {
                v[child] = current;
                q.push(child);
            }
        }
    }

    for (int i = 2; i <= N; i++)
    {
        if (-1 == v[i])
        {
            std::cout << "No" << std::endl;
            break;
        }
        else
        {
            if (2 == i)
            {
                std::cout << "Yes" << std::endl;
            }
            std::cout << v[i] << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 34064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); ++i)
#define rrep(i, n) for (int(i) = (n)-1; (i) >= 0; --i)
#define rep1(i, n) for (int(i) = 1; (i) <= (n); ++i)
#define rrep1(i, n) for (int(i) = (n); (i) >= 1; --i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> LP;
typedef double db;
using namespace std;

ll r;

int main()
{
    cin >> r;
    cout << r * r << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    int a, b, x ;
    
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &x);
    
    if (a <= x){
        
        if(x-a <= b){
            printf("YES");
        }else{
            printf("NO");
        }
    }else{
        printf("NO");
    }
    
    return 0 ;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    }else{
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
    if (!hasNext()) throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while(isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }
  public long nextLong() {
    if (!hasNext()) throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while(true){
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      }else if(b == -1 || !isPrintableChar(b)){
        return minus ? -n : n;
      }else{
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
    return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

public class Main {
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();

    int x = fs.nextInt();
    int a = fs.nextInt();
    int b = fs.nextInt();

    x -= a;
    while (x - b >= 0) {
      x-= b;
    }
    out.println(x);
  }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int cost = 0;
  if(2*c<(a+b)){
    rep(i,min(x,y)*2){
      cost+=c;
    }
    int d = abs(x-y);
    if(x<y){
      if(2*c>b)cost+=b*d;
      else cost+=2*c*d;
    }
    else {
      if(2*c>a)cost+=a*d;
      else cost+=2*c*d;
    }
  }
  else{
    cost = a*x+b*y;
  }
  cout<<cost<<endl;
  return 0;
}

Measured memory_bytes: 256
// Danielxlr
// https://atcoder.jp/contests/abc174/tasks/abc174_c
// math

#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int k , kkk=7, steps=1;
    cin>>k;

while(kkk%k!=0){
    if(steps>=(pow(10,6)+5)){
        steps=-1;
        break;
    }
    steps++;
    kkk=kkk*10+7;
    kkk%=k;
    }
    cout<<steps;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    map<string, int> m;
    REP(i, N){
        string s;
        cin >> s;
        m[s]++;
    }
    int M;
    cin >> M;
    REP(i, M){
        string s;
        cin >> s;
        m[s]--;
    }
    int a = 0;
    string s;
    for(auto&& i : m){
        if(a < i.se){
            a = i.se;
            s = i.fi;
        }
    }
    pr(a);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
#define int long long

template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string&);

string to_string(const char* s);

string to_string(bool b);

template <typename A>
string to_string(A v);

template <typename A, typename B>
string to_string(pair<A, B> p);

void debug_out(); 

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T);

vector<string> vec_splitter(string s);
void debug_var(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 

template <typename Head, typename... Tail>
void debug_var(vector<string>, int, int, Head, Tail...);

#ifndef ONLINE_JUDGE
#define var(...) debug_var(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#define stl(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define var(x...)
#define stl(...) 
#endif

const int mod = 1e9 + 7;
const int N = 1e6 + 5; 

void solve() {
  long double r;
  cin >> r;
  long double d = 7;
  long double pi = 22 / d;
  cout << fixed << setprecision(5);
  cout << (2 * pi * r) << '\n';
  
}

signed main() {
  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  // int T = 1; cin >> T; for (int i = 1; i <= T; ++i)
  solve();
  return 0;
}

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "T" : "F");
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename Head, typename... Tail>
void debug_var(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << "): ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_var(args, idx + 1, LINE_NUM, T...);
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}

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

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

   vector<vector<bool>> m(H + 2, vector<bool>(W + 2, false));

   rep(i, 1, H + 1) {
     rep(j, 1, W + 1) {
       char tmp;
       cin >> tmp;
       if (tmp == '.') m.at(i).at(j) = true;
     }
   }

   int ans = 0;

   rep(i, 1, H + 1) {
     rep(j, 1, W + 1) {
       if (m.at(i).at(j)) {
         vector<vector<int>> cnt(H + 2, vector<int>(W + 2, -1));
         queue<pair<int, int>> q;
         cnt.at(i).at(j) = 0;
         q.push({i, j});
         pair<int, int> tmp_p;
         while (!q.empty()) {
           tmp_p = q.front();
           q.pop();
           if (m.at(tmp_p.first + 1).at(tmp_p.second) && cnt.at(tmp_p.first + 1).at(tmp_p.second) == -1) {
             q.push({tmp_p.first + 1, tmp_p.second});
             cnt.at(tmp_p.first + 1).at(tmp_p.second) = cnt.at(tmp_p.first).at(tmp_p.second) + 1;
             ans = max(ans, cnt.at(tmp_p.first + 1).at(tmp_p.second));
           }
           if (m.at(tmp_p.first - 1).at(tmp_p.second) && cnt.at(tmp_p.first - 1).at(tmp_p.second) == -1) {
             q.push({tmp_p.first - 1, tmp_p.second});
             cnt.at(tmp_p.first - 1).at(tmp_p.second) = cnt.at(tmp_p.first).at(tmp_p.second) + 1;
             ans = max(ans, cnt.at(tmp_p.first - 1).at(tmp_p.second));
           }
           if (m.at(tmp_p.first).at(tmp_p.second + 1) && cnt.at(tmp_p.first).at(tmp_p.second + 1) == -1) {
             q.push({tmp_p.first, tmp_p.second + 1});
             cnt.at(tmp_p.first).at(tmp_p.second + 1) = cnt.at(tmp_p.first).at(tmp_p.second) + 1;
             ans = max(ans, cnt.at(tmp_p.first).at(tmp_p.second + 1));
           }
           if (m.at(tmp_p.first).at(tmp_p.second - 1) && cnt.at(tmp_p.first).at(tmp_p.second - 1) == -1) {
             q.push({tmp_p.first, tmp_p.second - 1});
             cnt.at(tmp_p.first).at(tmp_p.second - 1) = cnt.at(tmp_p.first).at(tmp_p.second) + 1;
             ans = max(ans, cnt.at(tmp_p.first).at(tmp_p.second - 1));
           }
          }
        }
      }
    }
    cout << ans << endl;
 }


Measured memory_bytes: 256
a = input()
if a[len(a)-1] == "3":
  print("bon")
elif a[len(a)-1] == "0" or a[len(a)-1] == "1" or a[len(a)-1] == "6" or a[len(a)-1] == "8":
  print("pon")
else:
  print("hon")

Measured memory_bytes: 9020
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

ll poww(ll t,ll n)
{
    if(n==0)return 1;
    return t*poww(t,n-1)%mod;
}

main()
{
    int n; cin>>n;
    vi p(n),q(n);
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>q[i];

    int x=0,y=0;

    do
    {
        x++;
    }while(prev_permutation(all(p)));
    do
    {
        y++;
    }while(prev_permutation(all(q)));

    cout<<abs(x-y)<<endl;
}

Measured memory_bytes: 256
n = int(input())
p = [list(map(int, input().split()))for _ in range(n)]
ax, ay, ah = list(filter(lambda x: x[2], p))[0]
for x in range(101):
    for y in range(101):
        H = ah+abs(ax-x)+abs(ay-y)
        if all(max(H-abs(t[0]-x)-abs(t[1]-y), 0) == t[2]for t in p):
            print(x, y, H)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int x = Integer.parseInt(str[2]);
    String[] a = in.readLine().split(" ");
    int count = 0;
    for(int i=0; i<m; i++) {
      if(x<Integer.parseInt(a[i]))
        count++;
    }
    System.out.println(Math.min(count,m-count));
  }
}

Measured memory_bytes: 32856
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	ll N, A, B;
	cin >> N >> A >> B;
	ll ans = 0;
	if ((B-A)%2 == 0)
		ans = (B-A)/2;
	else
	{
		if (B-1 <  N-A)
		{
			B -= A-1+1;
			ans += A-1+1;
			ans += (B-1)/2;
		}
		else
		{
			A += N-B+1;
			ans +=	N-B+1;
			ans += (N-A)/2;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int main() {
  int a,b;
  int i = 0;
  int res, ma = 0;
  while(cin>>a>>b,a+b) {
    if (ma < a + b) {
      ma = a + b;
      res = i;
    }
    ++i;
    if (i==5) {
      i = 0;
      printf("%c %d\n", 'A' + res, ma);
      ma = 0;
    }
  }
}

Measured memory_bytes: 0
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e3 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, dp[N][N];
string s;

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   if (a < 0) a += mod;
   return a;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> s;
   dp[1][1] = 1;
   for (int i = 2; i <= n; i ++) {
      for (int j = 1; j < i; j ++) dp[i - 1][j] = add (dp[i - 1][j], dp[i - 1][j - 1]);
      for (int j = 1; j <= i; j ++) {
         dp[i][j] = (s[i - 2] == '<' ? dp[i - 1][j - 1] : add (dp[i - 1][i - 1], -dp[i - 1][j - 1]));
      }
   }
   for (int i = 1; i <= n; i ++) dp[n][i] = add (dp[n][i], dp[n][i - 1]);
   cout << dp[n][n];
}

int main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 35840
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut V = Vec::<i64>::new();
    let mut A: i64 = 0;
    let mut B: i64 = 0;

    for index in 0..N {
        let c: i64 = read();
        V.push(c);
    }

    V.sort_by(|x, y| y.cmp(x));

    for (i, &v) in V.iter().enumerate() {
        if i % 2 == 0 {
            A += v;
        } else {
            B += v;
        }
    }

    println!("{}", A - B);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    int m, d;
    cin >> m >> d;
    int ans = 0;
    rep(i, 1, m) {
        rep(j, 2, 9) {
            if(i%j == 0 && j*10+i/j <= d && i/j > 1 && i/j <= 9) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256