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

using namespace std;

int main()
{
    char s[15];
    while(cin>>s)
    {
        int l=strlen(s);
        int flag=0,con=0,sum=0;
        if(s[0]=='A')
        {
            for(int i=1;i<l;i++)
            {
                if(i>=2&&i<=l-2&&s[i]=='C')
                    flag=1;
                if(s[i]=='C')
                    con++;
                if((s[i]<'a'||s[i]>'z')&&s[i]!='C')
                    sum++;
                if(sum>0)
                {
                    flag=0;break;
                }
            }
        }
        if(con>1)
            flag=0;
        printf(flag?"AC\n":"WA\n");
    }
    return 0;
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll x;
    cin>>x;
    map<ll,ll> mp;
    mp[0]=0;
    ll b=1;
    while(true){
        ll b5=pow(b,5);
        mp[b5]=b;
        mp[-b5]=-b;
        b++;
        if(mp.find(b5-x)==mp.end()) continue;
        cout<< b-1 << " " << mp[b5-x]<<en;
        return;
    }
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 4076
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int N, K;
  ll a[100001];
  ll sum[100001] = {0}, p_sum[100001] = {0};
  ll ans = 0, zero = 0; 

  cin >> N >> K;
  Rep(i, N) cin >> a[i];

  //累積和計算
  //sum[]は普通の累積和　p_sum[]は正の数のみの累積和
  sum[0] = a[0];
  p_sum[0] = max(zero, a[0]);
  for(int i=1; i<N; i++) {
    sum[i] = sum[i-1] + a[i];
    p_sum[i] = p_sum[i-1] + max(zero, a[i]);
  }

  ans = sum[K-1] + p_sum[N-1] - p_sum[K-1];
  Rep(i, N-K+1) {
    ans = max(ans, p_sum[i-1] + sum[i+K-1] - sum[i-1] + p_sum[N-1] - p_sum[i+K-1]);
    ans = max(ans, p_sum[i-1] + p_sum[N-1] - p_sum[i+K-1]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 2560
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 120000;

int n;

ll a[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	int fl = 0;
	for (int i = 0; i < n; ++i)
		cin >> a[i], fl |= (a[i] % 2);
	if (fl)
		cout << "first\n";
	else
		cout << "second\n";
	return 0;
}




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

typedef struct d{
  int p;    // parent
  int s;    // sibling
  int deg;  // degree
  int dep;  // depth
  int h;    // height
  int left;
  int right;
}data;

data *tree;

void dataprinter(data out){
  puts("-----data-----");
  printf("p=%d s=%d deg=%d dep=%d h=%d left=%d right=%d\n"
  ,out.p, out.s, out.deg, out.dep, out.h, out.left, out.right);
  puts("=====data=====");
}

void init(int n){
  int i;
  tree = (data *)malloc(sizeof(data) * n);
  for(i=0; i<n; i++){
    tree[i].p = -1;
    tree[i].s = -1;
    tree[i].deg = 0;
    tree[i].dep = 0;
    tree[i].h = -1;
    tree[i].left = -1;
    tree[i].right = -1;
  }
}

void maketree(void){
  int id;

  scanf("%d ",&id);
  scanf("%d %d ",&tree[id].left, &tree[id].right);
  if(tree[id].left != -1){
    tree[tree[id].left].p = id;
    tree[tree[id].left].s = tree[id].right;
    tree[id].deg += 1;
  }
  if(tree[id].right != -1){
    tree[tree[id].right].p = id;
    tree[tree[id].right].s = tree[id].left;
    tree[id].deg += 1;
  }
}

int isParent(int i){
  if(tree[i].p == -1) return 0;
  else return (isParent(tree[i].p)) + 1;
}

void getHeight(int i, int h){
  if(tree[i].deg == 0) {
    tree[i].h = h;
  }

  if(tree[i].h < h){
    tree[i].h = h;
  }

  if(tree[i].p != -1){
    getHeight(tree[i].p, h+1);
  }
}

void printer(int n){
  int i;

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
    , i, tree[i].p, tree[i].s, tree[i].deg, tree[i].dep, tree[i].h);
    if(tree[i].p == -1){
      puts("root");
    }
    else if(tree[i].deg == 0){
      puts("leaf");
    }
    else{
      puts("internal node");
    }
  }
}

int main(){
  int i, n;

  scanf("%d",&n);
  init(n);
  for(i=0; i<n; i++){
    maketree();
  }
  for(i=0; i<n; i++){
    tree[i].dep = isParent(i);

    getHeight(i, 0);

  }

  printer(n);

  return 0;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll Sn;
char S[1010101];
ll dp[1010101][3];
ll i, j, k;
ll aaa(ll i,ll a){
    if(i<0){
        return a;
    }
    if(dp[i][a]>0){
        return dp[i][a] - 1;
    }
    ll sn = S[i] - '0' + a;
    dp[i][a] = 1 + min(sn + aaa(i - 1, 0), 10 - sn + aaa(i - 1, 1));
    return dp[i][a] - 1;
}
int main(){
    scanf("%s", S);
    Sn = strlen(S);
    printf("%lld", aaa(Sn - 1, 0));
    return 0;
}

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

const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; ll W; cin >> n >> W;
    vector<pair<ll, ll>> p(n);
    for (int i = 0; i < n; i++) cin >> p[i].second >> p[i].first;
    ll w0 = p.front().second;

    sort(p.begin(), p.end(), greater<pair<ll, ll>>());

    vector<vector<ll>> vs(4, vector<ll>(1, 0));
    for (auto &e: p) {
        ll v = e.first, w = e.second;
        vs[w - w0].emplace_back(v);
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j < (int)vs[i].size(); j++) {
            vs[i][j] += vs[i][j - 1];
        }
    }

    ll ans = 0;
    for (int i = 0; i < (int)vs[0].size(); i++) {
        for (int j = 0; j < (int)vs[1].size(); j++) {
            for (int k = 0; k < (int)vs[2].size(); k++) {
                for (int l = 0; l < (int)vs[3].size(); l++) {
                    ll weight = 0;
                    weight += i * w0;
                    weight += j * (w0 + 1);
                    weight += k * (w0 + 2);
                    weight += l * (w0 + 3);
                    if (weight <= W) {
                        ans = max(ans, vs[0][i] + vs[1][j] + vs[2][k] + vs[3][l]);
                    }
                }
            }
        }
    }

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

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
const int MAX=1e6+7;
const int mod=1e9+7;
//map<int,map<int,map<int,int> > >mp;
ll vis[105][105][105];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
  ll n,ans=0;cin>>n;
  vector<ll>a(n,0);
  for(ll i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  for(ll i=0;i<n;i++){
  		for(ll j=i+1;j<n;j++){
  			for(ll k=j+1;k<n;k++){
  				if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&vis[i][j][k]==0){
  					vis[i][j][k]=1;
  					ans++;	
				}	
			}	
		}
  }
  cout<<ans; 
   return 0;
} 

Measured memory_bytes: 7964
n = int(input())
ans = [0] * (n + 1)

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            val = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if val <= n:
                ans[val] += 1

print(*ans[1:], sep="\n")


Measured memory_bytes: 68716
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
const lint MOD = 1e9+7;
int main() {
    lint n,k; cin >> n >> k;
    lint a[2000];
    rep(i,n) cin >> a[i];
    lint an1 = 0;
    lint an2 = 0;
    rep(i,n) {
        rep(j,n) {
            if (i == j) continue;
            if (i < j && a[i] > a[j]) an2 ++;
            if (a[i] > a[j]) an1 ++;
        }
    }
    lint ans = (k*an2)%MOD;
    ans += an1*(((k*(k-1))/2)%MOD);
    ans = ans % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3640
//#include <bits/stdc++.h>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cmath>

#define X first
#define Y second
#define ls rt<<1
#define rs rt<<1|1
#define getmid ((l+r)>>1)
#define PB push_back
#define EP emplace_back
#define MP make_pair
#define lowbit(x) ((x)&-(x))
#define ALL(x) x.begin(),x.end()
#define mst(x,a) memset(x, a, sizeof(x))
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#ifdef LOCAL
    #define dbg(a) cout << #a": " << a << endl;
#else
    #define dbg(a)
#endif // LOCAL

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;

const int N = 2200 + 10;
const int M = 1e5 + 10;
const int mod = 998244353;
const double eps = 1e-10;
const double pi = acos(-1.0);

int n;
ll a[M];
int prime[N+1],tot;
vector<ll> ve;
gp_hash_table<ll,int> cnt;
gp_hash_table<ll,ll> mp;

void getPrime(){
    for(int i=2; i<=N; i++){
        if(!prime[i]) prime[++tot] = i;
        for(int j=1; j<=tot && prime[j]<=N/i; j++){
            prime[i*prime[j]] = 1;
            if(i%prime[j]==0) break;
        }
    }
}

inline bool check(ll n){
    ll m = sqrt(n+0.5);
    return n==m*m;
}

int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    getPrime();
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];
    int ans = 0;
    bool one = false;
    for(int i=1; i<=n; i++){
        ll t = a[i];
        ll x = 1, y = 1;
        for(int j=1; j<=tot; j++){
            if(t%prime[j]==0){
                int num = 0;
                while(t%prime[j]==0) {
                    t /= prime[j];
                    num++;
                }
                num %= 3;
                for(int k=1; k<=num; k++) x *= prime[j];
                for(int k=(3-num)%3; k; k--) y *= prime[j];
            }
            if(t==1) break;
        }
        if(t!=1) {
            if(check(t)) {
                x *= t;
                y *= (int)sqrt(t+0.5);
            } else {
                if((double)t*t*y<=1e10) {
                    x *= t;
                    y *= t*t;
                } else {
                    ans++;
                    continue;
                }
            }
        }
        if(x==1) {
            if(!one) {
                one = true;
                ans++;
            }
            continue;
        }
        mp[x] = y;
        if(++cnt[x]==1) ve.PB(x);
    }
    for(ll val: ve) {
        if(!cnt[val]) continue;
        int x = cnt[val];
        int y = cnt[mp[val]];
        ans += max(x, y);
        cnt[mp[val]] = 0;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 27256
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n-k;i++){
		if(a[i]>=a[i+k]) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  bool isRotated = false;
  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  } else {
    for (int i = 0; i < N / 2; i++) {
      if (S.at(i) != S.at(N / 2 + i)) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3640
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

s = read()
if s == "ARC":
    print("ABC")
else:
    print("ARC")

Measured memory_bytes: 10572
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);
int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int num_AB=max(x,y)*2;
    int money=a*x+b*y;
    for(int i=0;i<=num_AB;i+=2){
        int num_A=max(0,x-i/2);
        int num_B=max(0,y-i/2);
        money=min(money,a*num_A+b*num_B+c*i);
    }
    cout << money << endl;
}

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

int main()
{
int a;
int b;
int maxx=-101;
cin>> a>>b;
int s=a+b;
int s2=a-b;
int p=a*b;
int ar[3]={s,s2,p};
for(int i=0;i<3;i++)
{
    if(ar[i]>maxx)
    maxx=ar[i];
}
cout<<maxx<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;
int main(){
  ll n;cin>>n;
  bool found=false;
  ll a, b;long double c;
  for(a=1;a<=3500;a++){
    for(b=a;b<=3500;b++){
      c = (long double)(n*a*b)/(long double)(4*a*b-n*b-n*a);
      if(c<0)continue;
      if(fabs(c-round(c))<1e-14){found=true;break;}
    }
    if(found)break;
  }
  cout<<a<<" "<<b<<" "<<(ll)round(c)<<endl;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 998244353;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class Combination {
    int powmod(int a, int p) {
        int ans = 1;
        int mul = a;

        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    int mod;
    vector<int> fact;
    vector<int> revFact;

    Combination(int n, int m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    int get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

signed main() {
    int N, A, B, K;
    cin >> N >> A >> B >> K;

    vector<P> ps;
    for (int x = 0; x <= N; x++) {
        if (K - x*A >= 0 && (K - x*A) % B == 0) {
            int y = (K - x*A) / B;
            ps.emplace_back(P(x, y));
        }
    }

    Combination comb = Combination(N, MOD);
    int ret = 0;
    for (P p : ps) {
        int tmp = comb.get(N, p.first) * comb.get(N, p.second);
        tmp %= MOD;
        ret += tmp;
        ret %= MOD;
    }

    cout << ret << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      if (i * 4 + j * 7 == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import decimal
 
 
def main():
    N, K = map(int, input().split())
    ans = 0
    for n in range(1, N + 1):
        s = 0
        s += n
        c = 0
        while K > s:
            s *= 2
            c += 1
        ans += decimal.Decimal((1 / N) * (1 / 2) ** c)
    print(ans)
 
 
main()

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

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  ll res = b;
  if (c > b) {
    res += b;
    c -= b;
    if (c > a) {
      res += a;
      res += 1;
    } else {
      res += c;
    }
  } else {
    res += c;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
// =================================
//   author: memset0
//   date: 2018.12.25 22:11:27
//   website: https://memset0.cn/
// =================================
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
namespace ringo {
typedef long long ll;
typedef unsigned long long ull;
template <class T> inline void read(T &x) {
	x = 0; register char c = getchar(); register bool f = 0;
	while (!isdigit(c)) f ^= c == '-', c = getchar();
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
	if (f) x = -x;
}
template <class T> inline void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar('0' + x % 10);
}
template <class T> inline void maxd(T &a, T b) { if (b > a) a = b; }
template <class T> inline void mind(T &a, T b) { if (b < a) a = b; }
template <class T> inline void print(T x, char c) { print(x), putchar(c); }
template <class T> inline T abs(const T &a) { if (a < 0) return -a; return a; }

const int N = 1e5 + 10;
int n, m, a[N], b[N];
char s[N];

void main() {
	scanf("%s", s + 1), n = strlen(s + 1);
	for (int i = 1; i <= n; i++)
		switch (s[i]) {
			case 'b': a[i] = 0; break;
			case 'p': a[i] = 1; break;
			case 'd': a[i] = 2; break;
			case 'q': a[i] = 3; break;
		}
	for (int i = 1; i <= n; i++) b[i] = a[i];
	std::reverse(b + 1, b + n + 1);
	for (int i = 1; i <= n; i++) b[i] = (b[i] + 2) % 4;
	for (int i = 1; i <= n; i++)
		if (a[i] != b[i]) {
			puts("No");
			return;
		}
	puts("Yes");
}

} signed main() { return ringo::main(), 0; }

Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;
const i64 mod = (i64)1e9 + 7;


int add_range(vector<pair<int,int>>& balls, pair<int,int> range)
{
	int x = range.first, y = range.second;

	if(balls.empty()) {
		int diff = max(1 - x, 0);
		int count = (diff + 1) / 2;
		balls.push_back({x + count * 2, y});
		return count;
	}

	pair<int, int> last = balls[balls.size() - 1];
	int p = last.first, q = last.second;

	if(x - q >= 3) {
		balls.push_back({x, y});
		return 0;
	}

	if(x - q == 2) {
		balls.pop_back();
		balls.push_back({p, y});
		return 0;
	}

	assert(q + 1 == x);
	balls.pop_back();
	int np = p - 1, nq = y;
	return add_range(balls, {np, nq});
}

int add_ball(vector<pair<int,int>>& balls, int pos)
{
	return add_range(balls, {pos, pos});
}


int main()
{
	int n;
	vector<int> xs;
	vector<int> ranks;

	scanf("%d", &n);
	xs.resize(n); ranks.resize(n);
	for(int i = 0; i < n; ++i)
		scanf("%d", &xs[i]);

	vector<pair<int,int>> balls;
	ranks[0] = 0;
	ranks[1] = 0;
	add_ball(balls, xs[0]);

	for(int i = 2; i < n; ++i) {

		int prev_x = xs[i - 1];
		int rem = add_ball(balls, prev_x);
		int prev_rank = ranks[i - 1];

		ranks[i] = prev_rank + rem;
		//printf("ranks[%d] = %d\n", i, ranks[i]);
	}

	vector<int> counts(n, 0);

	for(int i = 0; i < n; ++i)
		counts[ranks[i]] += 1;
	for(int i = 1; i < n; ++i)
		counts[i] += counts[i - 1];

	i64 ans = 1;
	for(int i = 0; i < n; ++i) {
		i64 t = counts[i] - i;
		ans = ans * t % mod;
	}

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

	return 0;
}

/* waffle */


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code here!
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    
    if ( S == U ){
        A--;
    }
    if ( T == U ){
        B--;
    }
    
cout << A << " " << B << endl;
}

Measured memory_bytes: 768
def main():
    q = int(input())
    d = {}
    for i in range(q):
        query = input()
        cmd = int(query[0])
        if cmd == 0:
            _, k, v = query.split(' ')
            v = int(v)
            d[k] = v
        elif cmd == 1:
            _, k = query.split(' ')
            print(d.get(k, 0))
        elif cmd == 2:
            _, k = query.split(' ')
            if k in d:
                del d[k]


if __name__ == '__main__':
    main()



Measured memory_bytes: 37508
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	vector<int> A;
	cin>>N;
	int i;
	int x;
	for (i=0;i<N;i++){
		cin>>x;
		A.push_back(x);
	}
	int s=0;
	int aw=0;
	for (i=0;i<N;i++){
		aw+=abs(A[i]-s);
		s=A[i];
	}
	aw+=abs(s);
	A.push_back(0);
	for (i=0;i<N;i++){
		int Sum=aw;
		if (i==0){
			if (abs(A[i]-0)+abs(A[i+1]-A[i])==abs(A[i+1])){
			}else{
				Sum=aw-(abs(A[i]-0)+abs(A[i+1]-A[i]))+abs(A[i+1]);
			}
		}else{
			if (abs(A[i]-A[i-1])+abs(A[i+1]-A[i])==abs(A[i+1]-A[i-1])){
			}else{
				Sum=aw-(abs(A[i]-A[i-1])+abs(A[i+1]-A[i]))+abs(A[i+1]-A[i-1]);
			}
		}
		cout<<Sum<<endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, X;
  cin >> N >> M >> X;
  int lcnt = 0, rcnt = 0;
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    if (a < X)
      lcnt++;
    else
      rcnt++;
  }
  cout << min(lcnt, rcnt) << '\n';
  return 0;
}


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

int main(){
 long long S,b,c,d,p,ans,ans2,k;
cin>>k>>S;
ans=0;
  for(int i=0;i<k+1;i++){
    for(int j=0;j<k+1;j++){
      if(S-j-i<=k&&S-j-i>=0){
        ans++;
      }
    }
  }
    cout<<ans<<endl;
}


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

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

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a, 0, sizeof(a))

#define RAD(d) (PI * (d) / 180)
#define DEG(r) (180.0 * (r) / PI)

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

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> T accumulate(const vector<T> &v)
{
	T sum = 0;
	REP(i, SZ(v)){ sum += v[i]; }
	return sum;
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

string &to_upper(string &s)
{
	REP(i, s.length()){
		if('a' <= s[i] && s[i] <= 'z'){
			s[i] -= 32;
		}
	}

	return s;
}

string &to_lower(string &s)
{
	REP(i, s.length()){
		if('A' <= s[i] && s[i] <= 'Z'){
			s[i] += 32;
		}
	}

	return s;
}

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

	vector<double> x(n);
	vector<double> y(n);

	REP(i, n){ cin >> x[i]; }
	REP(i, n){ cin >> y[i]; }

	// P=1
	double d1 = 0;
	REP(i, n){
		d1 += abs(x[i] - y[i]);
	}

	// P=2
	double d2 = 0;
	REP(i, n){
		d2 += pow(x[i] - y[i], 2);
	}
	d2 = sqrt(d2);

	// P=3
	double d3 = 0;
	REP(i, n){
		d3 += pow(abs(x[i] - y[i]), 3);
	}
	d3 = pow(d3, 1.0/3);

	// P=infinity
	double dmax = 0;
	REP(i, n){
		chmax(dmax, abs(x[i] - y[i]));
	}

	printf("%.6f\n", d1);
	printf("%.6f\n", d2);
	printf("%.6f\n", d3);
	printf("%.6f\n", dmax);

	return 0;
}



Measured memory_bytes: 3408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, K);
  VEC(int, A, N);
  print(ceil((double)(N - 1) / (K - 1)));
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Set(a,b) memset(a,b,sizeof(a))
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
template <typename T> inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}
typedef long long ll;
typedef unsigned long long ull;
typedef __uint128_t uLL;
typedef double db;
typedef long double ldb;
template <typename T>inline void Inc(T&x,int y){x+=y;if(x>=mod) x-=mod;return;}
template <typename T>inline void Dec(T&x,int y){x-=y;if(x <  0) x+=mod;return;}
template <typename T>inline int fpow(int x,T k){int ret=1;for(;k;k>>=1,x=(ll)x*x%mod) if(k&1) ret=(ll)ret*x%mod;return ret;}
int n,k;
int main()
{
	init(n),init(k);
	if((n+1)/2>=k) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc137/tasks/abc137_e
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

type Edge = (usize, i64);

const INF: i64 = 1e12 as i64;

fn iterate(dp: &mut Vec<i64>, graph: &Vec<Vec<Edge>>, up: bool) {
    let n = graph.len();
    for i in 0..n {
        if dp[i] == -INF {
            continue;
        }
        for &(to, cost) in &graph[i] {
            if dp[to] < dp[i] + cost {
                dp[to] = if up { INF } else { dp[i]+cost }
            }
        }
    }
}

fn solve(graph: Vec<Vec<Edge>>) -> i64 {
    let n = graph.len();
    let mut dp = vec![-INF; n];
    dp[0] = 0;

    for _ in 0..2*n {
        iterate(&mut dp, &graph, false);
    }

    let base = dp[n-1];
    for _ in 0..2*n {
        iterate(&mut dp, &graph, true);
    }
    if dp[n-1] >= INF {
        return -1;
    }
    max(0, dp[n-1])
}

fn main() {
    input! {
        n: usize, m: usize, p: i64,
        edges: [(usize1, usize1, i64); m]
    };
    let mut graph = vec![vec![]; n];
    for (u, v, c) in edges {
        graph[u].push((v, c-p));
    }
    println!("{}", solve(graph));
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>

using namespace std;

typedef long long ll;

struct cum_sum {
	vector<ll> ar;
	vector<ll> sum;
	int N;
	cum_sum(int _N) {
		N = _N;
		ar.resize(N), sum.resize(N + 1);
	}
	cum_sum(vector<ll>& _ar) {
		ar = _ar;
	}

	ll& operator[](int _idx) {
		return ar[_idx];
	}

	void setup() {
		for (int i = 0; i < N; i++) {
			sum[i + 1] = sum[i] + ar[i];
		}
	}
	ll getval(int l, int r) {
		//[l, r)
		ll ret = sum[r] - sum[l];
		return ret;
	}
};

bool hurui[100000 + 20];//false -> prime

int main() {
	hurui[0] = true, hurui[1] = true;
	for (int i = 2; i <= 100000; i++) {
		if (hurui[i])continue;
		for (int j = i * 2; j <= 100000; j += i) {
			hurui[j] = true;
		}
	}
	
	cum_sum cs(100000 + 20);
	for (int i = 1; i <= 100000; i += 2) {
		if (!hurui[i] && !hurui[(i + 1) / 2])cs[i]++;
	}
	cs.setup();

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		cout << cs.getval(l, r + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
using vi = vector<int>;
using vvi = vector<vi>;
 
int main()
{
    int h, w; cin >> h >> w;
 
    int n; cin >> n;
 
    vi v(n + 1);
 
    for(int i = 1; i <= n; i++) cin >> v[i];
 
    vvi g(h, vi(w));
 
    for(int i = 0, cur = 1; i < h; i++)
    for(int j = 0; j < w; j++)
    {
        if(!v[cur]) cur++;
 
        assert(cur <= n);

        int k = i % 2 ? w - 1 - j : j;
 
        g[i][k] = cur, v[cur]--;
    }
 
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
            cout << g[i][j] << ' ';
 
        cout << endl;
    }
 
    return 0;
}

Measured memory_bytes: 384
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = lin()
	
	ai = max(al)
	c = al.index(ai)
	pa(c)
	al.pop(c)
	pa(al)
	aj = min(al, key = lambda v : abs((ai/2)-v))
	
	print(ai, aj)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 84880
S = input()
left = S[:2]
right = S[2:]

if "01" <= left <= "12" and "01" <= right <= "12":
    print("AMBIGUOUS")
elif "01" <= left <= "12":
    if "00" <= right <= "99":
        print("MMYY")
    else:
        print("NA")
elif "01" <= right <= "12":
    if "00" <= left <= "99":
        print("YYMM")
    else:
        print("NA")
else:
    print("NA")


Measured memory_bytes: 38384
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, D: int, A: "List[List[int]]", Q: int, L: "List[int]", R: "List[int]"):
    pos = [None for i in range(H * W)]
    for h in range(H):
        for w in range(W):
            pos[A[h][w]] = (h, w)
    
    mp = [0 for i in range(H * W)]
    for d in range(D):
        for i in range(d, H*W-D, D):
            hp, wp = pos[i]
            hn, wn = pos[i+D]
            mp[i+D] = mp[i] + abs(hn-hp) + abs(wn-wp)

    for q in range(Q):
        print(mp[R[q]] - mp[L[q]])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    A = [ [ int(next(tokens))-1 for _ in range(W) ] for _ in range(H) ]  # type: "List[List[int]]"
    Q = int(next(tokens))  # type: int
    L = [int()] * (Q)  # type: "List[int]" 
    R = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        L[i] = int(next(tokens))-1
        R[i] = int(next(tokens))-1
    solve(H, W, D, A, Q, L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25924
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=(1<<19);
int a[M];
int dp[M][2];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<(1<<n);i++)
	{
		cin>>a[i];
		dp[i][0]=a[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int mask=0;mask<(1<<n);mask++)
		{
			if((mask&(1<<i)))
			{
				vector<int> vt;
				vt.pb(dp[mask][0]);
				vt.pb(dp[mask][1]);
				vt.pb(dp[(mask^(1<<i))][0]);
				vt.pb(dp[(mask^(1<<i))][1]);
				sort(all(vt));
				reverse(all(vt));
				dp[mask][0]=vt[0];
				dp[mask][1]=vt[1];
			}
		}
	}
	for(int i=1;i<(1<<n);i++)
	{
		int res=0;
		int mask=0;
		for(int j=n-1;j>=0;j--)
		{
			if((i&(1<<j))==0)
				continue;
			int nm = (mask^((1<<j)-1));
			res=max(res,dp[nm][0]+dp[nm][1]);
			mask = (mask^(1<<j));
		}
		res=max(res,dp[mask][0]+dp[mask][1]);
		cout<<res<<"\n";
	}
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int n; cin>>n;
	if(n<1000) cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>

using namespace std;

typedef long long ll;
//typedef pair<ll, ll> P;
typedef  double LD;


const ll MOD = 10e9 + 7;
const LD INF = 999999999999999;
const ll MAX_V = 10e3;
const LD EPS = 10e-12;
const LD PI = 3.14159265359;

struct edge { int to; double cost; };
typedef pair<double, int> P; //firstは最短距離,secondは頂点の番号

int V;
vector<edge> G[MAX_V];
LD dmin[MAX_V];

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que; //小さいものから取り出す
	fill(dmin, dmin + V+2, INF);
	dmin[s] = 0;
	que.push(P(0, s));


	while (!que.empty()) {
		P p = que.top(); que.pop();
		ll v = p.second;
		if (dmin[v] + EPS < p.first)continue;
		for (int i = 0; i<G[v].size(); i++) {
			edge e = G[v][i];
			if (dmin[e.to] > dmin[v] + e.cost + EPS) {
				dmin[e.to] = dmin[v] + e.cost;
				que.push(P(dmin[e.to], e.to));
			}
		}
	}
}

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

ll sx, sy, gx, gy,x[1010],y[1010],r[1010];

int main() {
	cin >> sx >> sy >> gx >> gy >> V;
	x[0] = sx; y[0] = sy; r[0] = 0;
	x[V + 1] = gx; y[V + 1] = gy; r[V + 1] = 0;
	for (int i = 1; i <= V; i++) {
		cin >> x[i] >> y[i] >> r[i];
	}
	for (int i = 0; i <= V + 1; i++) {
		for (int j = i + 1; j <= V + 1; j++) {
			LD dist = (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]);
			LD co;
			if (dist <= (r[i] + r[j])*(r[i] + r[j])) {
				co = 0;
			}
			else {
				co = sqrt(dist) - LD(r[i] + r[j]);
			}
			G[i].push_back({ j,co });
			G[j].push_back({ i,co });

		}
	}
	V += 2;
	dijkstra(0);
	printf("%.12lf", dmin[V-1]);
	return 0;
}

Measured memory_bytes: 22548
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int N;
    string S;
    int ans=0;
    cin>>N>>S;
    for(int i=0;i<N-2;i++){
        if(S.substr(i,3)=="ABC")ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int main(void) {

	int A, B;
	int K;
    scanf("%d %d %d", &A, &B, &K);

    int k = 0;
    int x = min(A, B) + 1;
    while ( k < K ) {
    	x--;
    	if ( A % x == 0 && B % x == 0 ) k++;

    }
    
    printf("%d\n", x);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.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;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  int n;
  cin>>n;
  vector<int>c(n-1);
  vector<int>s(n-1);
  vector<int>f(n-1);
  rep(i,n)cin>>c[i]>>s[i]>>f[i];

  vector<ll>ans(n);
  rep(i,n-1){
    ans[i]=s[i]+c[i];
    
    Rep(j,i+1,n-1){
      if(ans[i]<=s[j])ans[i]=s[j];
      else{
	ll tmp=(ans[i]-s[j])/f[j];
	if((ans[i]-s[j])%f[j]==0)ans[i]=s[j]+tmp*f[j];
	else ans[i]=s[j]+(tmp+1)*f[j];
      }
      ans[i]=ans[i]+c[j];
    }

  }
  rep(i,n)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  ll res = 0;
  if (N >= 2) {
    res += min(D, min(S * 2, min(H * 4, Q * 8))) * (int)(N / 2);
    N %= 2;
  }
  if (N >= 1) {
    res += min(S, min(H * 2, Q * 4));
  }
  printf("%lld\n", res);
}

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

int main(void)
{
    char a, b;
    cin >> a >> b;
    if(a=='H' and b=='H')
        cout << "H" << endl;
    else if(a=='H' and b=='D')
        cout << "D" << endl;
    else if(a=='D' and b=='H')
        cout << "D" << endl;
    else if(a=='D' and b=='D')
        cout << "H" << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    ll n, m;
    cin >> n >> m;
    if(n == 2 or m == 2) cout << 0 << endl;
    else if(n == 1 and m == 1) cout << 1 << endl;
    else if (n == 1 or m == 1) cout << max(n, m) - 2 << endl;
    else cout << (ll)((n-2) * (m-2)) << endl;
}


Measured memory_bytes: 256
a={}
n=io.read()
temp=0
now_max= 0  --最高ジャンプ回数
count=0 --カウント
for i=1, n,1 do
  temp=io.read("*n")
  a[i]=temp
end    

now=a[1] --現在の高さ

for k=2,#a,1 do
  if now >= a[k] then
    now=a[k]
    count=count + 1
  else
    now=a[k]
    count=0
  end
  
  if now_max < count then
    now_max=count
  end
end

if n== 1 then
print(0)
else
print(now_max)
end

Measured memory_bytes: 2424
k,a,b=map(int,input().split())
if b-a<=2:
  print(1+k)
else:
  ans=1
  move=0
  if k<=a-1:
    print(ans+k)
  else:
    ans=a
    move=a-1
    k-=move
    if k%2==1:
      ans+=1
      k-=1
    ans+=(b-a)*(k//2)
    print(ans)

Measured memory_bytes: 3064
# S = gets.chomp

# V = gets.split.map(:to_i)

N = gets.to_i
A = gets.to_i
B = gets.to_i
C = gets.to_i
D = gets.to_i
E = gets.to_i

m = [A, B, C, D, E].min

puts (1.0*N/m).ceil + 4



Measured memory_bytes: 3836
//a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

vector<int> w, k;

int main(){
	
	int a, ws=0, ks=0;
	
	for(int i=0; i<10; ++i){
		cin>>a;
		w.push_back(a);
	}
	
	for(int i=0; i<10; ++i){
		cin>>a;
		k.push_back(a);
	}
	
	sort(RALL(w));sort(RALL(k));
	
	cout << w[0]+w[1]+w[2] << " " << k[0]+k[1]+k[2] << endl;
	
	return 0;	
}

Measured memory_bytes: 1216
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

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

	int A, B, C;
	cin >> A >> B >> C;
	if (A >= B && A >= C) cout << 10 * A + B + C;
	else if (B >= A && B >= C) cout << 10 * B + A + C;
	else if (C >= A && B >= B) cout << 10 * C + A + B;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

Measured memory_bytes: 504
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll X;
    cin >> X;
    ll T;
    cin >> T;
    ll kai=(N+X-1)/X;
    prt(T*kai);

    return 0;
}



Measured memory_bytes: 3628
import java.util.Scanner

object Main{
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit ={
    val n = sc.nextInt
    val l = List.fill(n)(sc.nextInt)
    val sum = l.sum

    val res = l.forall{ i =>i * 2 < sum}

    println(if(res) "Yes" else "No")
  }
}

Measured memory_bytes: 27216