akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    long long a;cin>>a;
    long long k;
    double b;cin>>b;
    k=(long long)(100ll*b+0.5);
    //cout<<k<<endl;  
    cout <<  a*k/100ll<< endl;
}

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

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

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);

    int inp[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &inp[i]);
    sort(inp, inp + n);

    ii op[m];
    for (int i = 0; i < m; i++)
        scanf("%d %d", &op[i].second, &op[i].first);

    sort(op, op + m,
         [](const ii a, const ii b) -> bool { return a.first > b.first; });

    int idx = 0;
    for (int i = 0; idx < n && i < m; i++) {
        int val = op[i].first;
        for (int j = 0; idx < n && j < op[i].second; j++) {
            if (inp[idx] < val) {
                inp[idx] = val;
                idx++;
            } else {
                goto done;
            }
        }
    }

done:
    ll ans = 0;
    for (int i = 0; i < n; i++)
        ans += inp[i];
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

long long mod_pow(unsigned long long x,unsigned long long y,unsigned long long mod){
  unsigned long long ans = 1;
  while(y > 0){
    if(y & 1)ans = ans * x % mod;
    x = x * x  % mod;
    y >>= 1;
  }
  return ans;
}

int main(){
  cin >> n >> m;
  cout << mod_pow(n,m,INF) << endl;
  return 0;
}


Measured memory_bytes: 3136
main = getLine >> getLine >>= (\(_, y, _) -> print y) . foldr (ff . read) (0, 0, 0) . words
    where
        ff z (v, n, x)
            | z > x = (v, n, z)
            | v < d = (d, 1, x)
            | v == d = (v, n + 1, x)
            | otherwise = (v, n, x)
            where
                d = x - z


Measured memory_bytes: 58876
/* 
 * Project: AtCoder Beginners Contest 155 C - Poll
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/14
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

int n;
vector<string> vec;
map<string,int> s;
typedef pair<string, int> value_type;

struct second_order {
    bool operator()(const value_type& x, const value_type& y) const {
      return x.second > y.second;
    }
};

void solve() {

    for (string e : vec) {
        s[e]++;
    }
    int max_cnt = 0;
    for (const auto& x : s) {
        int cnt = x.second;
        if (cnt > max_cnt) {
            max_cnt = cnt;
        }
    }
    for (auto iter = s.begin(); iter != s.end(); iter++) {
        if (iter->second == max_cnt) {
            printf("%s\n", iter->first.c_str());
        }
    }
}

int main() {

    scanf("%d", &n);
    for (int i=0;i<n;i++) {
        string str;
        cin >> str;
        vec.push_back(str);
        s[str] = 0;
    }

    solve();
}

Measured memory_bytes: 23244
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

ll l;
int main() {
  while (scanf("%lld", &l), l) {
    int ans = -1;
    ll sum = 0;
    REP(i, 12) {
      ll m, n;
      scanf("%lld %lld", &m, &n);
      sum += m - n;
      if (sum >= l && ans == -1) { ans = i; }
    }
    if (ans == -1) {
      puts("NA");
    } else {
      printf("%d\n", ans + 1);
    }
  }
}

Measured memory_bytes: 0
n = input()
if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9' : 
    print("hon")
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print("pon")
else:
    print("bon")

Measured memory_bytes: 61708
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [i32; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: usize, b: usize, c: usize,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input!{
        a: usize, b: usize
    }
    if a <= 8 && b <= 8 {
        println!("{}", "Yay!");
    } else {
        println!("{}", ":(");
    }
}

Measured memory_bytes: 4352
#include<cstdio>
long long a[100005];
long long upper[100005], lower[100005];
long long power[100005];
long long count[100005]; // inner node

long long min(long long a,long long b){ return a>b?b:a; }

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i <= n; i++) scanf("%lld",&a[i]);
    upper[n] = 0;
    for(int i = n-1; i >= 0; i--){
        upper[i] = upper[i+1]+a[i+1];
    }
    count[0] = 1-a[0];
    int ok = 1; long long ans = 1;
    if(count[0]>upper[0] || a[0]>1) ok = 0; 
    for(int i = 1; i <= n; i++){
        if(2*count[i-1]<a[i]){
            ok = 0;
            break;
        }
        else{ 
            count[i] = min(upper[i],2*count[i-1]-a[i]);
            ans += count[i]+a[i];
        }
    }
    if(!ok) printf("-1\n");
    else printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4032
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main(){
    ll x,a,b;
    cin >> x >> a >> b;
    if(b<=a) cout << "delicious" << endl;
    else if(b-a<=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
} 


Measured memory_bytes: 3620
#include <stdio.h>
int min(int n, int m){
    if(n<m) return n;
    else return m;
}
int main(void){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    printf("%d\n",min(a,b)+min(c,d));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long n,m;
long long arr[100001];
long long gcd(long long a,long long b){
    if (a>b) swap(a,b);
    if (a==0) return b;
    return gcd(a,b%a);
}
long long lca(long long a,long long b){
    return a*b/(gcd(a,b));
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for (int i=1;i<=n;i++) cin>>arr[i];
    long long lcaa=arr[1];
    for (int i=2;i<=n;i++){
        if (lcaa/2>m){
            cout<<0;
            return 0;
        }
        lcaa=lca(lcaa,arr[i]);
        if (lcaa/2>m){
            cout<<0;
            return 0;
        }
    }
    for (int i=1;i<=n;i++){
        long long cur=lcaa/arr[i];
        if (cur%2==0){
            cout<<0;
            return 0;
        }
    }
    m-=lcaa/2;
    cout<<m/lcaa+1;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

using namespace std;

int n,m;
int l,r;
int vis[1000005];
int cf[1000005];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&l,&r);
		cf[l]++;
		cf[r+1]--;
	}
	for(int i=1;i<=n;i++) vis[i]=vis[i-1]+cf[i];
	int ans=0;
	for(int i=1;i<=n;i++)
		if(vis[i]==m) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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;
}
int main(){
    ll x,y,a,b,c;cin >> x >>y >>a >>b >>c;
    vl r(a),g(b),t(c);
    rep(i,a){
        cin >> r[i];
    }
    rep(i,b)cin >> g[i];
    rep(i,c)cin >> t[i];
    sort(all(r));
    sort(all(g));
    reverse(all(r));
    reverse(all(g));
    rep(i,x){
        t.pb(r[i]);
    }
    rep(i,y){
        t.pb(g[i]);
    }
    sort(all(t));
    reverse(all(t));
    ll ans=0;
    rep(i,x+y){
        ans+=t[i];
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 6384
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <cstring>
#include <ctime>
#include <cassert>


#define pb emplace_back
#define re return
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265359;

int n;
int a[10000];
map <int, int> m;
map <int, int> t[10000];
ll binarnaya_zhest(ll x, ll p)
{
    ll ans = 1;
    while (p)
    {
        if (p % 2)
            ans *= x;
        ans %= MOD;
        p /= 2;
        x = x * x % MOD;
    }
    re ans % MOD;
}
int main()
{
    //freopen("distance.in", "r", stdin);
    //freopen("distance.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        int x = a[i];
        for (int j = 2; j * j <= x; j++)
            while (x % j == 0)
            {
                x /= j;
                t[i][j]++;
            }
        if (x > 1)
            t[i][x]++;
        for (auto j : t[i])
            m[j.fi] = max(m[j.fi], j.se);
    }
    ll ans = 0;
    ll mmm = 1;
    for (auto j : m)
        for (int i = 0; i < j.se; i++)
            mmm = mmm * j.fi % MOD;
    for (int i = 0; i < n; i++)
    {
        ll x = mmm * binarnaya_zhest(a[i], MOD - 2) % MOD;
        ans = (ans + x) % MOD;
    }
    cout << ans;
}
/// ACTUAL CODE STARTS HERE:
//  I'm red in soul
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


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

int main()
{
	long long sum = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		sum += s[i] - '0';
	}
	if (sum % 9 == 0) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 3728
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int maxn=2e5+100;
int a[maxn],b[maxn];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(b,b+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]<=b[n/2-1]) printf("%d\n",b[n/2]);
        else printf("%d\n",b[n/2-1]);
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,q;
char s[125252];
int cnt[125252];

int main(){
  scanf("%d%d",&n,&q);
  scanf("%s",s);
  FOR(i,1,n){
    if(s[i-1]=='A' && s[i]=='C'){
      cnt[i+1]++;
    }
  }
  REP(i,n+1)cnt[i+1] += cnt[i];
  // REP(i,n+1)DEBUG(cnt[i]);
  while(q--){
    int l,r;
    scanf("%d%d",&l,&r);
    --l;
    printf("%d\n",cnt[r]-cnt[l+1]);
  }
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/11  Problem: ABC 091 D / Link: http://abc091.contest.atcoder.jp/tasks/abc091_d  ----- */


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

	LL A, B, C; cin >> A >> B >> C;
	
	LL ans = A+B>=C;
	
	
	cout << (ans?"Yes":"No") << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char S[20];
  scanf("%s",&S);
  if(S[5] == '0' && (S[6] == '1' ||S[6] == '2' ||S[6] == '3' ||S[6] == '4')){
    printf("Heisei");
  }else{
    printf("TBD");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;
#define MAX 25
#define NIL -1

struct node{
  int p,l,r;
};

node A[MAX];

void Preorder(int v){
  if(v==NIL) return;
  cout<<" "<<v;
  Preorder(A[v].l);
  Preorder(A[v].r);
}

void Inorder(int v){
  if(v==NIL) return;
  Inorder(A[v].l);
  cout<<" "<<v;
  Inorder(A[v].r);
}

void Postorder(int v){
  if(v==NIL) return;
  Postorder(A[v].l);
  Postorder(A[v].r);
  cout<<" "<<v;
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    A[i].p=A[i].l=A[i].r=NIL;
  }
  int v,r,l,root;
  for(int i=0;i<n;i++){
    cin>>v>>l>>r;
    if(l!=NIL){
      A[v].l=l;
      A[l].p=v;
   }
   if(r!=NIL){
     A[v].r=r;
     A[r].p=v;
   }
  }
  for(int i=0;i<n;i++){
    if(A[i].p==NIL) root=i;
  }
  cout<<"Preorder"<<endl;
  Preorder(root);
  cout<<endl;
  cout<<"Inorder"<<endl;
  Inorder(root);
  cout<<endl;
  cout<<"Postorder"<<endl;
  Postorder(root);
  cout<<endl;
}



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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); cout.tie(NULL);


  int n, q; cin >> n >> q;
  vector < long long > a(n), sum(n), sumodd(n, 0), sumeven(n, 0);

  for(long long &x : a) cin >> x;

  partial_sum(a.begin(), a.end(), sum.begin());

  sumeven[0] = a[0];
  for(int i = 1; i < n; ++i) {
    sumodd[i] = sumodd[i - 1];
    sumeven[i] = sumeven[i - 1];
    if(i % 2) sumodd[i] += a[i];
    else sumeven[i] += a[i];
  }


  auto f = [&](const int &l, const int &r) {
    return sum[r] - (l ? sum[l - 1] : 0);
  };

  auto inRange = [&](const int &l, const int &r) {
    int u = lower_bound(a.begin(), a.end(), l) - a.begin();
    int v = upper_bound(a.begin(), a.end(), r) - a.begin();
    return v - u;
  };

  while(q--) {
    int x; 
    cin >> x;

    if(x >= a.back()) {
      cout << (n % 2 ? sumeven[n - 1] : sumodd[n - 1]) << '\n';
      continue;
    }

    int low = 0, high = 1000000000, ans = -1;
    while(low <= high) {
      int mid = (low + high) >> 1;

      int pos = upper_bound(a.begin(), a.end(), x + mid) - a.begin();

      if(inRange(x - mid, x + mid) > n - pos) {
        high = mid - 1;
      }
      else{
        ans = mid;
        low = mid + 1;
      }
    }

    int got = inRange(x - ans, x + ans);
    int u = lower_bound(a.begin(), a.end(), x - ans) - a.begin();
    int v = upper_bound(a.begin(), a.end(), x + ans) - a.begin();

    if(n - v > v - u) {
      if(n - v > v - u + 1) {
        u--;
      }
      cout << f(v, n - 1) + (u ? (u % 2 ? sumodd[u - 1] : sumeven[u - 1]) : 0) << '\n';
    }    
    else{
      cout << f(v, n - 1) + (u ? (u % 2 ? sumeven[u - 1] : sumodd[u - 1]) : 0) << '\n';
    }

    /*long long ansx = f(ans, n - 1);
    int v = lower_bound(a.begin(), a.end(), x - abs(x - a[ans])) - a.begin();
    long long ansy = f(v, ans - 1);

    v--;

    if(v > 0) 
      if(v % 2 == 0) ansy += sumeven[v], ansx += sumodd[v];
      else ansy += sumodd[v], ansx += sumeven[v];

    cout << ansx << '\n';*/
  }
	
  return 0;
}

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

const long long MOD = 2;

long long divceil(long long a, long long b)
{
    return (a + b - 1) / b;
}

void solve(long long k, long long q, std::vector<long long> d, std::vector<long long> n, std::vector<long long> x, std::vector<long long> m)
{
    long long ans = 0LL;

    for (size_t i = 0; i < q; i++)
    {
        long long last = x[i], eq = 0;
        for (size_t j = 0; j < k; j++)
        {
            long long num = divceil(n[i] - 1 - j, k);
            last += (d[j] % m[i]) * num;
            if (d[j] % m[i] == 0)
            {
                eq += num;
            }
        }
        long long ans = (n[i] - 1) - (last / m[i] - x[i] / m[i]) - eq;
        cout << ans << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long k;
    scanf("%lld", &k);
    long long q;
    scanf("%lld", &q);
    std::vector<long long> d(k - 1 - 0 + 1);
    for (int i = 0; i < k - 1 - 0 + 1; i++)
    {
        scanf("%lld", &d[i]);
    }
    std::vector<long long> n(q);
    std::vector<long long> x(q);
    std::vector<long long> m(q);
    for (int i = 0; i < q; i++)
    {
        scanf("%lld", &n[i]);
        scanf("%lld", &x[i]);
        scanf("%lld", &m[i]);
    }
    solve(k, q, std::move(d), std::move(n), std::move(x), std::move(m));
    return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D,E,K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  ll nums[5];
  cin >> A >> B;
  ll max_abc = max(A+B, 2*A-1);
  cout << max(max_abc, 2*B-1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
   string S;
   cin>>S;
   bool ok=false;
   rep(i,3) if(S[i]=='7') ok=true;
   if(ok) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long ll;

ll md = 1000000007;

int main(int, char**)
{
	ll ans = 0;
	int n, m;
	cin >> n >> m;

	vector<pair<int, int>> d(n);
	priority_queue<int> r;
	for(int i = 0; i < n; ++i)
		cin >> d[i].first >> d[i].second;

	sort(d.begin(), d.end());
	//for (int i = 0; i < n; ++i)
	//	cerr << d[i].first << ":" << d[i].second << " ";
	//cerr << endl;
	int y = 0;
	for (int i = 1; i <= m; ++i) {
		if (y < n) {
			while( d[y].first <= i ) {
				r.push(d[y].second);	
				y++;
				if (y >= n)
					break;
			}
		}
		if ( ! r.empty()) {
			ans += r.top();
			r.pop();
		}
	}

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


Measured memory_bytes: 1660
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<map>

using namespace std;

int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int flag = 1,count =0;
	while (flag) {
		flag = 0;
		for (int i = n-1; i >0; i--) {
			if (a[i] < a[i - 1]) {
				swap(a[i], a[i - 1]);
				flag = 1;
				count++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (i != 0)cout << " ";
		cout << a[i];
	}
	cout << endl << count << endl;
	return 0;
}

Measured memory_bytes: 3088
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%s", $S);
$arrS = str_split($S);
$arrC = array_pad(array(), 3, 0);

for ($i = 0; $i < count($arrS); $i++) {
    $cd = ord($arrS[$i]) - ord('a');
    $arrC[$cd]++;
}

if (max($arrC) === 1) {
    echo "Yes\n";
} else {
    echo "No\n";
}


Measured memory_bytes: 4604
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-9;

void solve() {
    ll x;
    cin >> x;
    if(x % 2) x *= 2;
    cout << x << endl;
    return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define debug(var) std::cout << #var << ": " << var << "\n"
#define all(n) begin(n), end(n)
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;
using namespace std;

int main(){

  string str[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  string S; cin >> S;
  rep(i, 7){
    if(S == str[i]){
      cout << 7 - i << endl;
    }
  }

}


Measured memory_bytes: 256
p = 10**9+7
P = [1 for _ in range(1000)]
P[0]=0
P[1]=0
for i in range(2,35):
    for j in range(i**2,1000,i):
        P[j]=0
Q = []
for i in range(2,1000):
    if P[i]==1:
        Q.append(i)
N = int(input())
C = {q:0 for q in Q}
for i in range(2,N+1):
    x = i
    for q in Q:
        if x%q==0:
            while x%q==0:
                x = x//q
                C[q] += 1
cnt = 1
for q in Q:
    cnt = (cnt*(C[q]+1))%p
print(cnt)

Measured memory_bytes: 9128
/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;

int main() 
{
	int n;
	scanf("%d",&n);
	int ans=1;
	int odd=1;
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		ans*=3;
		if(a%2==0)
		{
			odd*=2;
		}
	}
	printf("%d\n",ans-odd);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int s,w;
int main(){
	ios::sync_with_stdio(0);
	cin>>s>>w;
	if(w>=s)
	cout<<"unsafe";
	else
	cout<<"safe";
	re 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

void insertionSort(int A[], int N);

int main(void)
{
	int n=0, i=0;
	
	scanf("%d", &n);
	
	int a[n];
	
	for(i=0; i<n; i++)
	{
		scanf("%d", &a[i]);
	}
	
	insertionSort(a, n);
	
	return 0;
}

void insertionSort(int A[], int N)
{
	int i=0, j=0, v=0, k=0;
	
	for(i=0; i<N; i++) //1行目
	{
		if(i<N-1)
		{
			printf("%d ", A[i]);
		}
		else
		{
			printf("%d", A[i]);
		}
	}
	
	printf("\n");
	
	for(i=1; i<=N-1; i++)
	{
		v = A[i];
		j = i-1;
		
		while(j>=0 && A[j]>v)
		{
			A[j+1] = A[j];
			j--;
		}
		
		A[j+1]=v;
		
		for(k=0; k<N; k++) //2～N行目
		{
			if(k<N-1)
			{
				printf("%d ", A[k]);
			}
			else
			{
				printf("%d", A[k]);
			}
		}
			printf("\n");

	}
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int leading[100002], total[100002], possible[100002];
int main() {
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  leading[1] = total[1] = 3;
  possible[1] = s[0] == '0' ? 1 : 3;
  for (int x = 2; x <= s.length(); x++) {
    possible[x] = s[x-1] == '0' ? possible[x-1] : (total[x-1] + 2LL*possible[x-1])%MOD;
    leading[x] = (leading[x-1]*1LL*3)%MOD;
    total[x] = (leading[x-1]*2LL+total[x-1])%MOD;
  }
  printf ("%d\n",possible[s.length()]);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int a,b;
  cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout<<"Possible";
  }else{
      cout<<"Impossible";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const ll mod = 998244353;
bool comp(const pair<int, int> &a, const pair<int, int> &b){
    if(a.ff == b.ff){
        return a.ss > b.ss;
    }
    else return a.ff > b.ff;
}
bool comp2(const pair<int, int> &a, const pair<int, int> &b){
    if((a.ss - a.ff) == (b.ss - b.ff))
        return a.ff < b.ff;
    else return  (a.ss - a.ff) > (b.ss - b.ff);
}

int main() {
    IO;
    int n;
    cin >> n;
    vector<string> a(n);
    for(string &x: a)
        cin >> x;
    vector<pair<int, int> > level_pos, level_neg;
    int level_0 = 0;
    for(int i = 0; i < n; i++){
        int mn = 0, val = 0;
        for(char x: a[i]){
            if(x == '(') val++;
            else val--;
            mn = min(mn, val);
        }
        if(mn == 0) level_0 += val;
        else if(val >= 0) level_pos.emplace_back(mn, val);
        else level_neg.emplace_back(mn, val);
    }
    sort(level_pos.begin(), level_pos.end(), comp);
    sort(level_neg.begin(), level_neg.end(), comp2);
    for(auto &x: level_pos){
        if(x.ff + level_0 < 0){
            cout << "No\n";
            return 0;
        }
        level_0 += x.ss;
    }
    for(auto &x: level_neg){
        if(x.ff + level_0 < 0){
            cout << "No\n";
            return 0;
        }
        level_0 += x.ss;
    }
    puts((level_0 == 0)? "Yes" : "No");
    return 0;
}
/*
3
(((((
))
))))(
 */


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

int main() {
  
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  
  else{
    cout << "consonant" << endl;
  }
  
}


Measured memory_bytes: 3624
// Sum of Consecutive Prime Numbers
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1257 

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int PRIME_MAX = 10010;

bool is_prime[PRIME_MAX];
vector<int> prime_list;

int main() {

    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i < PRIME_MAX; ++i) is_prime[i] = true;
    for (int i = 2; i < PRIME_MAX; ++i) {
        if (is_prime[i]) {
            for (int j = i+i; j < PRIME_MAX; j += i) {
                is_prime[j] = false;
            }
        }
    }
    
    for (int i = 2; i < PRIME_MAX; ++i) {
        if (is_prime[i]) prime_list.push_back(i);
    }

    int N;
    while (cin >> N) {
        if (N == 0) break;
        int ans = 0, head = 0;
        while (true) {
            int total = 0;
            for (int i = head; total <= N; ++i) {
                total += prime_list[i];
                if (total == N) ans++;
            }
            if (prime_list[head] > N) break;
            head++;
        }
        cout << ans << endl;
    }

	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
const int dx[7] = {0, 1, 1, 0, -1, -1, 0}, dy[2][7] = {{1, 0, -1, -1, -1, 0, 0}, {1, 1, 0, -1, 0, 1, 0}};
int sx, sy, gx, gy, ux, uy, lx, ly;
bool cant_in[201][201];
int dist[201][201][6];
struct Node{
    int x, y, tmod;
    int cost;//sx, sy?????????????????????????????§??\????????????
    Node(int x, int y, int tmod, int cost)
         :x(x), y(y), tmod(tmod), cost(cost) {}
    bool operator>(const Node& N) const {
        return cost > N.cost;
    }
};

int solve(){
    rep(i, 201) rep(j, 201) rep(k, 6) dist[i][j][k] = INF;
    priority_queue<Node, vector<Node>, greater<Node> > que;
    dist[sy][sx][0] = 0;
    que.push(Node(sx, sy, 0, 0));
    while(!que.empty()){
        Node now = que.top(); que.pop();
        if(dist[now.y][now.x][now.tmod] < now.cost) continue;
        int xmod = now.x % 2, nt = (now.tmod + 1) % 6;
        int cmdir = abs((now.x - 100) * (now.y - 100) * now.tmod) % 6;
        rep(i, 7){
            int nx = now.x + dx[i], ny = now.y + dy[xmod][i];
            if(nx < lx || ny < ly || ux < nx || uy < ny) continue;
            if(cant_in[ny][nx]) continue;
            int plus = 1;
            if(i == cmdir) plus = 0;
            if(dist[ny][nx][nt] > now.cost + plus){
                dist[ny][nx][nt] = now.cost + plus;
                que.push(Node(nx, ny, nt, dist[ny][nx][nt]));
            }
        }
    }
    int res = INF;
    rep(i, 6) res = min(dist[gy][gx][i], res);
    return res == INF ? -1 : res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(cant_in, 0, sizeof(cant_in));
    cin >> sx >> sy >> gx >> gy;
    sx += 100; sy += 100; gx += 100; gy += 100;
    int n, _x, _y; cin >> n;
    rep(i, n){
        cin >> _x >> _y;
        cant_in[_y + 100][_x + 100] = true;
    }
    cin >> _x >> _y;
    ux = 100 + _x; lx = 100 - _x; uy = 100 + _y; ly = 100 - _y;
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 2336
#include<iostream>

using namespace std;

const int MAX_N=1e5+1;

int data[MAX_N];

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>data[i];
	int ans=0;
	for(int i=1;i<=n;i++){
		if(i==data[data[i]])ans++;
	}
	cout<<ans/2<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		for(int i=0; i<3; i++) {
		String str = sc.next();
		char moji = str.charAt(0);
		System.out.print(moji);
		}

	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

#define N 100000

int main() {
	int n, i = 0;
	string s;

	cin >> n;

	cin >> s;

	while (s[i] != '\0') {
		if (s[i] + n <= 'Z') {
			s[i] = s[i] + n;
		}
		else {
			s[i] = s[i] + n - 26;
		}
		i++;
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

using namespace std;

typedef long long LL;

int n, m, k;

double p[2222], x[2222];



int main() {
    
    cin >> n;
    if (n&1) cout << (n + 1) / 2.0 / n << endl;
    else cout << 0.5 << endl;
}

Measured memory_bytes: 256
pap = [[0 for x in range(10)] for y in range(10)]

def brot(x,y,s):
    if s==1:
        for dx in range(-1,+1+1):
            for dy in range(-1,+1+1):
                px = x + dx    
                py = y + dy
                if abs(dx)+abs(dy)<2 and px in range(0,10) and py in range(0,10):
                    pap[py][px] += 1
    elif s==2:
        for dx in range(-1,+1+1):
            for dy in range(-1,+1+1):
                px = x + dx    
                py = y + dy
                if px in range(0,10) and py in range(0,10):
                    pap[py][px] += 1
    elif s==3:
        for dx in range(-2,+2+1):
            for dy in range(-2,+2+1):
                px = x + dx    
                py = y + dy
                if abs(dx)+abs(dy)<3 and px in range(0,10) and py in range(0,10):
                    pap[py][px] += 1
    else:
        raise(ValueError) 

def ans():
    bmax = 0
    wcount = 0
    for y in range(0,+9+1):
        for x in range(0,+9+1):
            b = pap[y][x]
            if b > bmax:
                bmax = b
            elif b == 0:
                wcount += 1
    return(wcount,bmax)

while True:
    try:
        x,y,s = list(map(int, input().split(',')))
        brot(x,y,s)
    except EOFError:
       break

print("%d\n%d" % ans())

Measured memory_bytes: 7624
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

void max_heapify(vector<int>& H, int i, int size)
{
    int left = i * 2;
    int right = i * 2 + 1;

    int max = i;
    if (left <= size && H[max] < H[left])
        max = left;
    if (right <= size && H[max] < H[right])
        max = right;

    if (max != i) {
        swap(H[max], H[i]);
        max_heapify(H, max, size);
    }
}

void build_max_heap(vector<int>& H, int size)
{
    for (int i = size / 2; i > 0; --i)
        max_heapify(H, i, size);
}

void insert(vector<int>& S, int key, int& last)
{
    ++last;
    S[last] = key;

    int child = last;
    int parent = child / 2;
    while (parent > 0 && child > 0 && S[parent] < S[child]) {
        swap(S[parent], S[child]);
        child = parent;
        parent = child / 2;
    }
}

int extract_max(vector<int>& S, int& last)
{
    if (last < 1)   // priority queue is empty
        return -1;

    int max = S[1]; // first elem is max value

    S[1] = S[last];
    --last;
    max_heapify(S, 1, last);

    return max;
}

int main()
{
    const int max_instruction = 2000000;
    vector<int> S(max_instruction + 1);
    int last = 0;

    while (true) {
        string instruction;
        cin >> instruction;

        if (instruction == "end") {
            break;
        } else if (instruction == "extract") {
            int max = extract_max(S, last);
            cout << max << '\n';
        } else {
            int k;
            cin >> k;
            insert(S, k, last);
        }
    }
}



Measured memory_bytes: 10560
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 100;

void trace( int A[], int N )
{
    for ( int i = 0; i < N; i++ )
    {
        if ( i > 0 ) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void bubbleSort( int A[], int N )
{
    int count = 0;

    bool flag = true;
    for ( int i = 0; flag; i++ )
    {
        flag = false;
        for ( int j = N-1; j > i; j-- )
        {
            if ( A[j] < A[j-1] )
            {
                swap( A[j], A[j-1] );
                flag = true;
                count++;
            }
        }
    }
    trace( A, N );
    cout << count << endl;
}

int main(void)
{
    int A[MAX], N;

    cin >> N;
    for ( int i = 0; i < N; i++ )
    {
        cin >> A[i];
    }


    bubbleSort( A, N );


    return 0;
}



Measured memory_bytes: 3076
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int k;
  cin>>k;
  string s;
  cin>>s;
  
  if(s.size()<=k){
    cout<<s<<endl;
  }
  
  else{
    rep(i,k){
      cout<<s[i];
    }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3632
class abc_158:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        if "BA" in S or "AB" in S:print("Yes")
        else:print("No")
    
    def B(self):
        NAB=list(map(int,input().split()))
        tail = NAB[0]%(NAB[1]+NAB[2]) if NAB[0]%(NAB[1]+NAB[2])<NAB[1] else NAB[1]
        ans=((NAB[0]/(NAB[1]+NAB[2]))*NAB[1])+tail
        print(int(ans))
            
    def C(self):
        AB=list(map(int,input().split()))
        ans=-1
        
        #A<B<100
        for i in range(1,1001):
            if AB[0]==int(i*0.08) and AB[1]==int(i*0.1):
                ans=i
                break
            else:continue
        print(ans)
            
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_158()
    obj.C()

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

int main() {
  int N; 
  cin >> N;
  vector<char> s(N);
  for(int i = 0; i < N; i++){
    cin >> s.at(i);
  }
  
  int ans = 0;
  for(int i = 0; i <= N - 3; i++){
    if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C'){
      ans++;
    }
  }
  cout << ans << endl;
  
}

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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

int main()
{
  uint64_t H, N;
  cin >> H >> N;
  
  vector<uint64_t> A(N), B(N);
  N_TIMES(n, N) {
    cin >> A[n] >> B[n];
  }
  
  vector<uint64_t> dp(H + 1, -1);
  dp[0] = 0;
  N_TIMES(h, H) {
    if (dp[h] == static_cast<uint64_t>(-1)) { continue; }
    N_TIMES(n, N) {
      uint64_t new_h = min(H, h + A[n]);
      dp[new_h] = min(dp[new_h], dp[h] + B[n]);
    }
  }
  cout << dp[H] << endl;

  return 0;
}

Measured memory_bytes: 384