akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int p[10];
 int c[10];
 int D,G;
 int bit=0;
 int ans=100000000;
 int cnt=0;
 int check=0;
 long long int sum=0;
 cin>>D>>G;

 for(int i=0; i<D; i++){
  cin>>p[i]>>c[i];
 }

 for(int bit=0;bit<(1<<D); bit++){
  vector<int> A;
  cnt=0;
  sum=0;
  check=0;
  for(int i=0; i<D; i++){
   if(bit & (1<<i))A.push_back(i);
  }
  
  for(int i=0; i<A.size();i++){
   sum+=100*(A[i]+1)*p[A[i]]+c[A[i]]; 
   cnt+=p[A[i]];
  }
  if(sum>=G){
   check=1;
   ans=min(ans,cnt);
  }
  else{
   for(int i=D-1; i>=0; i--){
    if((bit & (1<<i))==0){
	 for(int j=0; j<p[i]-1;j++){
	  sum+=100*(i+1);
	  cnt++;
	  if(sum>=G){
	   check=1;
	   ans=min(ans,cnt);
	   break;
	  }
     }
    }
    if(check==1)break;
   }
  }
 }
 std::cout<<ans<<std::endl;
}

Measured memory_bytes: 256
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]
A = list(map(int, input().split()))

days_for_work = 0

for i in A:
    days_for_work += i

if N - days_for_work >= 0:
    print(N - days_for_work)
else:
    print('-1')

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

int main(void)
{
    int n,k,s;
    int wa[100001];
    int a[100000];

    scanf("%d %d %d",&n,&k,&s);
    wa[0]=0;
    if(s!=1000000000){
        for(int i=0;i<n;i++){
            a[i]=1000000000;
        }
    }else{
        for(int i=0;i<n;i++){
            a[i]=1000000000-1;
        }
    }

    if(n>=k){
        for(int i=0;i<k;i++){
            a[i]=s;
        }
    }

    for(int i=0;i<n;i++){
        i<n-1?printf("%d ",a[i]):printf("%d",a[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1664
n,p=map(int,input().split())
a=list(map(int,input().split()))
even=0
for aa in a:
  if aa%2==0:
    even+=1
if even==n:
  if p==0:
    print(2**n)
    exit(0)
  else:
    print(0)
    exit(0)
print(2**(n-1))






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

int N;
vector<int> A;

int main()
{
    cin >> N;
    A.resize(N);
    for (auto &a : A) cin >> a;
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    vector<int> tmp(2);
    int num = 0;
    for (int i=0; i<N-1; i++)
    {
        if (A[i] == A[i+1])
        {
            tmp[num] = A[i];
            num++;
            i++;
        }
        if (num == 2) break;
    }
    if (num == 2)
    {
        cout << (long long)tmp[0]*(long long)tmp[1] << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define w cout
#define e '\n'
#define sz(x) int(x.size())
using namespace std;
const int N = 1e6 + 10;

vector<int> v[N];
int mm[N][5];

int main() {
	ios::sync_with_stdio(0) , cin.tie(0);
	int n , m ; cin >> n >> m;
	for(int i = 1; i <= m ; i ++ ) {
		int u , vv ; cin >> u >> vv;
		v[u].push_back(vv);
	}
	
	for(int i = 0 ; i < N ; i ++ ) {
		for(int j = 0 ; j < 5 ; j ++ ) {
			mm[i][j] = 0;
		}
	}
	int x , y; cin >> x >> y;
	queue<pair <int , int > > q;
	q.push({x , 0});
	int ans = 1e9;
	while(!q.empty()) {
		auto u = q.front();
		q.pop();
		if(mm[u.first][(u.second % 3)] != 0) {
			continue;
		}
		mm[u.first][(u.second % 3)] = 1;
		if(u.first == y && u.second % 3 ==  0) {
			ans = min(ans , u.second / 3);
			break;
		} 
		
		for(auto i : v[u.first]) {
			q.push({i , u.second + 1});
		}
	}
	
	if(ans == 1e9) w << -1;
	else
	w << ans;
}


Measured memory_bytes: 46336
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int n,m ;
    cin >> n >> m;
    vector <int> ar(n + 1,0);
    bool f = 0;
    bool ans = 0;
    map <int,int> mp;
    for(int i = 0; i < m; ++i){
        int s,c;
        cin >> s >> c;
        if(s == 1)
            f = 1;
        ar[s] = c;
        if(mp.find(s) == mp.end()){
            mp[s] = c;
        }
        else if(mp[s] != c)
            ans = 1 ;
    }
    if(ans ){
        cout << -1 << '\n';
        return 0;
    }
    if(n == 1){
        cout << ar[1] << '\n'; 
        return 0;
    }
    else{
        if(ar[1] == 0){
            if(f){
                cout << -1 << '\n';
                return 0;
            }
            else
                ar[1] = 1; 
        }
    }
    for(int i = 1; i <= n; ++i)
        cout << ar[i];
    cout << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> P(N), Q(N);
	rep(i, N) cin >> P[i];
	rep(i, N) cin >> Q[i];

	vector<int> init;
	for (int i = 0; i < N; i++) {
		init.push_back(i + 1);
	}

	int a = 0;
	int b = 0;
	int count = 0;
	do {
		count++;
		if (init == P) {
			a = count;
		}
		if (init == Q) {
			b = count;
		}
	} while (next_permutation(init.begin(), init.end()));

	int ans = abs(a - b);
	cout << ans << endl;

}

Measured memory_bytes: 256
'use strict';

const main = (input) => {
    const nums = input.split(' ');
    const N = parseInt(nums[0], 10);
    const K = parseInt(nums[1], 10);
    // a+b が N の倍数で a+c が Nの倍数であるなら (b-c) は Nの倍数
    // 同様に (a-b), (a-c) も N の倍数
    let numBCCache1 = {};
    let numBCCache2 = {};
    let count = 0;
    for (let a = 1; a <= N; a++) {
        let m = a % K;
        let minBC = K - m;
        if (((minBC * 2) % K) == 0) {
            // bc が任意の組で満たす
            // bc がいくつあるか数える
            let numBC = numBCCache1[minBC];
            if (typeof numBC === 'undefined') {
                numBC = 0;
                for (let bc = minBC; bc <= N; bc += K) {
                    numBC++;
                }
                numBCCache1[minBC] = numBC;
            }
            count += numBC * numBC;
        } else {
            // bc が任意の組で満たさない
            let numBC = numBCCache2[minBC];
            if (typeof numBC === 'undefined') {
                numBC = 0;
                for (let bc = minBC; bc <= N; bc += K) {
                    if (((bc * 2) % K) == 0) {
                        numBC++;
                    }
                }
                numBCCache2[minBC] = numBC;
            }
            count += numBC;
        }
    }
    console.log(count);
};

const isTest = false;

if (isTest) {
    main('3 2');
    main('5 3');
    main('31415 9265');
    main('35897 932');
} else {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
}

Measured memory_bytes: 23624
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int ans = 0;
        if (b / a > 0 && b % a == 0) {
            ans = a + b;
        } else {
            ans = b - a;
        }

        System.out.println(ans);
    }
}


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

int main(void){
  int n, input;
  long sum, max;
  while(cin >> n, n != 0){
    cin >> input;
    max = sum = input;
    for(int i = 0; i < n - 1; i++){
      cin >> input;
      if( sum < 0 )
	sum = input;
      else
	sum += input;
      if( max < sum )
	max = sum;
    }
    cout << max << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-

s = input()
ans = []
for i in s:
    if i == '0':
        ans.append('0')
    elif i == '1':
        ans.append('1')
    elif i == 'B' and ans.count('0') == 0 and ans.count('1') == 0:
        continue
    else:
        ans.pop()

print(''.join(ans))





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

int		main(void)
{
	string	a;
	string	b;
	cin >> a;
	for (int i = 4; i < a.size(); i++)
		b += a.at(i);
	cout << "2018" << b << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return b / gcd(b, a % b) * a; }

int main() {
  ll n, d, ans = 0;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> d, ans = ans + d - 1;
  cout << ans << endl;
  // cin >> v[0];
  // d = v[0];
  // for (int i = 1; i < n; ++i) {
  //   cin >> v[i];
  //   d = lcm(d, v[i]);
  // }
  // ll ans = 0;
  // rep(i, n) ans += (d - 1) % v[i];
  // ll ans2 = 0;
  // rep(i, n) ans2 += (d + 1) % v[i];
  // cout << max(ans,ans2) << endl;
  // cout << max(ans,ans2) << endl;
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int graph[105][105];

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

    int N, K;
    cin >> N >> K;
    for(int i = 1; i <= N; ++i) {
        for(int j = i + 1; j <= N; ++j) {
            graph[i][j] = 1;

        }
    }

    int t = K;
    for(int i = 2; i <= N && K > 0; ++i) {
        for(int j = i + 1; j <= N && K > 0; ++j) {
            graph[i][j] = 0;
            --K;

        }
    }

    if(K > 0) {
        cout << -1 << endl;
        return 0;

    }

    K = t;
    cout << N * (N - 1) / 2 - K << endl;
    for(int i = 1; i <= N; ++i) {
        for(int j = i + 1; j <= N; ++j) {
            if(graph[i][j] == 1) {
                cout << i << " " << j << endl;

            }
        }
    }

    return 0;
}



Measured memory_bytes: 384
import math
EPS = 10**-8


class P2():
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.norm2 = (self.x**2 + self.y**2)**0.5

    def __add__(self, other):
        return P2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return P2(self.x - other.x, self.y - other.y)

    def smul(self, a):
        return P2(self.x * a, self.y * a)

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def det(self, other):
        return self.x * other.y - self.y * other.x


n = int(input())
p = [P2(*map(int, input().split())) for _ in range(n)]

dist = [[(p[i] - p[j]).norm2 for j in range(n)] for i in range(n)]


def check(r):
    # 最小包含円の半径がr以下であるか

    # 半径rの円２つの交点の列挙
    cand = []
    for i in range(n - 1):
        for j in range(i + 1, n):
            c_ij = (p[i] + p[j]).smul(0.5)
            d_ij = p[i] - p[j]
            # cand.append(c_ij)

            if dist[i][j] < r * 2:
                # 点iと点jを中心とする半径rの円は交点を持つ時
                h = (r**2 - (dist[i][j] / 2)**2)**0.5
                v = P2(-d_ij.y, d_ij.x).smul(h / d_ij.norm2)
                cand.append(c_ij + v)
                cand.append(c_ij - v)

    for cand_p in cand:
        is_in = True
        for i in range(n):
            if (p[i] - cand_p).norm2 > r + EPS:
                is_in = False
                break
        if is_in:
            # print(r, cand_p.x, cand_p.y)
            return True
    return False
    # return any(all((pi - ci).norm2 <= r + EPS for pi in p) for ci in cand)


lb = 0.0  # False
ub = 2000  # True
while ub - lb > EPS:
    mid = (ub + lb) / 2
    if check(mid):
        ub = mid
    else:
        lb = mid

print(ub)


Measured memory_bytes: 3828
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static int N;
	public static int LI;

	public static int[] x;
	public static int[] y;
	public static long[] h;
	public static long[][] point;
	public static long ah;
	public static int ax;
	public static int ay;


	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		N = parseInt(st.nextToken());

		x = new int[N];
		y = new int[N];
		h = new long[N];
		point  = new long[101][101];


		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			x[i] = parseInt(st.nextToken());
			y[i] = parseInt(st.nextToken());
			h[i] = parseInt(st.nextToken());

			if(h[i] !=0) {
				LI=i;

			}
			point[y[i]][x[i]] = h[i];
		}


		label:for(int yy=0;yy<=100;yy++) {
			for(int xx=0;xx<=100;xx++) {

				if(check(xx,yy)) {
					break label;
				}

			}
		}

		System.out.printf("%d %d %d%n",ax,ay,ah);



	}




	private static boolean check(int xz, int yz) {
		int hy = Math.abs(yz - y[LI]);
		int hx = Math.abs(xz - x[LI]);
		long hz2 = h[LI] + hy + hx;


		boolean isCenter = true;
		for(int i=0;i<N;i++) {
//			if(h[i] ==0) {
//				continue;
//			}
			int hyn = Math.abs(yz - y[i]);
			int hxn = Math.abs(xz - x[i]);
			if(hz2 !=h[i] + hyn + hxn) {
				if(h[i] ==0) {
					if(hz2 >hyn + hxn) {
						isCenter = false;
						break;

					}
				}else {
					isCenter = false;
					break;
				}

			}
		}

		if(isCenter) {

			ax = xz;
			ay = yz;
			ah = hz2;
		}

		return isCenter;

	}

}

Measured memory_bytes: 24916
fn main() {
    let (n, h): (usize, i32) = readln();
    let mut v: Vec<(i32, i32)> = readlns(n);
    let normal = v.iter().map(|k| k.0).max().unwrap();
    v.sort_by_key(|x| -(x.1));

    let (throw, last_h) = v.iter().map(|x| x.1).fold((0, h), |(throw, rest), x| {
        if rest > 0 && x > normal {
            (throw + 1, rest - x)
        } else {
            (throw, rest)
        }
    });

    let answer = throw + if last_h > 0 {
        (last_h + normal - 1) / normal
    } else {
        0
    };

    println!("{}", answer);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


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

const int N = 55;
int a[N], n;
ll c[N][N], sc[N][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, s, t;
    cin >> n >> k >> s >> t;
    for (int i = 0; i < 18; i++) if ((s & (1<<i)) == 1 && (t & (1<<i)) == 0) {
        cout << "0\n";
        return 0;
    }
    c[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        c[i][0] = 1;
        for (int j = 1; j <= i; ++j) c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
    }
    for (int i = 0; i <= n; ++i) {
        sc[i][0] = 0;
        for (int j = 1; j <= k; ++j) sc[i][j] = sc[i][j - 1] + c[i][j];
    }
    for (int i = 1; i <= n; ++i) cin >> a[i];
    {
        static int b[N];
        for (int i = 1; i <= n; ++i) b[i] = a[i];
        int tot = 0;
        for (int i = 1; i <= n; ++i) {
            bool flg = 1;
            for (int j = 0; j <18; ++j) {
                if ((s & (1<<j)) == (t & (1<<j)) && (a[i] & (1<<j)) != (s & (1<<j))) {
                    flg = false;
                    break;
                }
            }
            if (flg) b[++tot] = a[i];
        }
        n = tot;
        for (int i = 1; i <= n; ++i) a[i] = b[i];
    }
    ll ans = 0;
    for (int mask = s ^ t; ; mask = (mask - 1) & (s^t)) {
        static int cnt[1 << 19];
        for (int i = 1; i <= n; ++i) {
            ++cnt[a[i] & mask];
        }
        ll tmp = 0;
        for (int i = 1; i <= n; ++i) {
            tmp += sc[cnt[a[i]&mask]][k];
            cnt[a[i]&mask] = 0; 
        }
        if (__builtin_popcount(mask) & 1)
            ans -= tmp;
        else ans += tmp;
        if (!mask) break;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4652
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int D; cin >> D;
    D %= 10;
    string ans;
    if(D == 5) ans = "Christmas";
    if(D == 4) ans = "Christmas Eve";
    if(D == 3) ans = "Christmas Eve Eve";
    if(D == 2) ans = "Christmas Eve Eve Eve";
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//試してて御免

const int cm = 1 << 16;
char ci[cm];
char *cn = ci + cm;
inline char getcha() { 
	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }
	char ret = *cn;
	cn++;
	return ret;
}
inline char getcha2() {
	char ret = *cn;
	cn++;
	return ret;
}

inline int getint() {
	if (cn - ci + 25 > cm) {
		char C = getcha();
		int A = C - '0';
		while (isdigit(C = getcha())) A = A * 10 + C - '0';
		return A;
	}
	else {
		char C = getcha2();
		int A = C - '0';
		while (isdigit(C = getcha2())) A = A * 10 + C - '0';
		return A;
	}
}

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


	int N, X;
	N = getint();
	X = getint();

	int A = 0;
	ll kotae = 0;
	rep(i, N) {
		int B = getint();
		if (A + B > X) {
			kotae += A + B - X;
			B = X - A;
		}
		A = B;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
input = sys.stdin.readline


def inp():
    return int(input())


def inpl():
    return list(map(int, input().split()))


N = inp()
aa = inpl()


ajs = []
ais = []

for i, a in enumerate(aa):
    ajs.append(a - i)
    ais.append(-a - i)


cnt = defaultdict(int)
ans = 0
for ai, aj in zip(ais, ajs):
    ans += cnt[aj]
    cnt[ai] += 1


print(ans)


Measured memory_bytes: 66708
<?php
/**
 * Created by PhpStorm.
 * User: souta
 * Date: 2018/02/13
 * Time: 9:30
 */

# スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $a, $b);

$sqrt = sqrt( sprintf("%d%d",$a,$b) );

if( $sqrt == intval($sqrt) ){
    echo 'Yes'."\n";
}else{
    echo 'No'."\n";
}

?>

Measured memory_bytes: 4604
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1010;
const int MAXK = 110;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    cout << max(0, a-b*2);
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
from collections import defaultdict
N = int(input())
As = [0]+list(map(int, input().split()))
Acc = list(accumulate(As))

d = defaultdict(int)
for a in Acc:
    d[a] += 1
ans = 0
for k in d.keys():
    n = d[k]
    ans += n * (n-1)//2
print(ans) 

Measured memory_bytes: 41620
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int a = cin.Int();
        int b = cin.Int();
        int k = cin.Int();
        var list = new List<int>();
        for(int i = 1; i <= 10000; i++) {
            if(a % i == 0 && b % i == 0) {
                list.Add(i);
            }
        }
        //foreach (var x in list) {
        //    Console.WriteLine(x);
        //}
        Console.WriteLine(list[list.Count - k]);
        Console.ReadLine();
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
    int n = 0;
    cin >> n;
    ll ans = 1;
    for(int i = 1; i <= n; ++i){
        ans = ans * i;
        ans = ans % (ll)(pow(10, 9) + 7);
    }
    cout << ans << endl;
    
    return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> h >> w;
    ans = INF;
    // T1
    REP(i, 1, w + 1) {
        a = h * i;
        ll j = h / 2;
        b = j * (w - i);
        c = (h - j) * (w - i);

        maxi = max(a, max(b, c));
        mini = min(a, min(b, c));
        ans = min(ans, maxi - mini);
    }
    if (ans == 0) {
        END(0)
    }

    // T2
    REP(i, 1, w + 1) {
        a = h * i;
        ll j = (w - i) / 2;
        b = h * j;
        c = h * (w - i - j);

        maxi = max(a, max(b, c));
        mini = min(a, min(b, c));
        ans = min(ans, maxi - mini);
    }
    if (ans == 0) {
        END(0)
    }

    // T3
    REP(i, 1, h + 1) {
        a = i * w;
        ll j = w / 2;
        b = (h - i) * j;
        c = (h - i) * (w - j);

        maxi = max(a, max(b, c));
        mini = min(a, min(b, c));
        ans = min(ans, maxi - mini);
    }
    if (ans == 0) {
        END(0)
    }

    // T4
    REP(i, 1, h + 1) {
        a = i * w;
        ll j = (h - i) / 2;
        b = j * w;
        c = (h - i - j) * w;

        maxi = max(a, max(b, c));
        mini = min(a, min(b, c));
        ans = min(ans, maxi - mini);
    }
    MSG(ans)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s,prv,curr;
int sol;
int main()
{
    cin>>s;
    prv="";
    int sz=s.size();
    for(int i=0;i<sz;i++)
    {
        curr=s[i];
        int j=i+1;
        while(j<sz && curr==prv)
        {
            curr+=s[j];
            j++;
        }
        if(curr!=prv)
            sol++;
        prv=curr;
        i=j-1;
    }
    cout<<sol;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9



int main() {
	int N; cin >> N;
	int h[N], dp[N];
	for (int i = 0; i < N; i++) cin >> h[i];

	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (int i = 2; i < N; i++) {
		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}

	cout << dp[N - 1] << endl;

	return 0;
}

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

#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<


int main(void) 
{
  llint x;
  scanf("%lld", &x);

  llint sol = x / 11 * 2;
  x %= 11;

  if (x && x <= 6) sol += 1;
  if (x > 6) sol += 2;

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

  return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

yaku = factorize(N)
c = collections.Counter(yaku)

count = 0
for i in c.values():
    hoge = 1
    for j in range(2,10*5):
        if hoge <= i:
            hoge += j
            count += 1
        else:
            break

print(count)

    

Measured memory_bytes: 9492
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int a[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=a[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
  }
  L[n1]=R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      a[k]=L[i++];
    }
    else{
      a[k]=R[j++];
    }
  }
}

void mergesort(int a[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(a,n,left,mid);
    mergesort(a,n,mid,right);
    merge(a,n,left,mid,right);
  }
}

int main(void)
{
  int a[MAX],n,i;
  cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  mergesort(a,n,0,n);
  
  for(i=0;i<n;i++){
    if(i>0){
      printf(" ");
    }
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;
}

Measured memory_bytes: 5596
N,X=map(int,input().split())
*A,=map(int,input().split())

ans=0

if A[0]>X:
    ans+=A[0]-X
    A[0]=X 

i=0
while i+1<=N-1:
    if A[i]+A[i+1]>X:
        ans+=A[i]+A[i+1]-X
        A[i+1]=X-A[i]
    i+=1

print(ans)

Measured memory_bytes: 63856
#include<bits/stdc++.h>
#include<unordered_map>	
#include<unordered_set>
#define pb emplace_back
#define rt(v) return cout<<v,0
#define sz(v) (int)(v.size())
#define all(a) a.begin(),a.end()
#define endl '\n'
#define space " "
typedef long long ll;
typedef unsigned long long ull;
const int N = 10 + 1e5;
const int mod = 1e9 + 7;
/*

███╗   ███╗███████╗███╗   ███╗███████╗    ██╗      ██████╗ ██████╗ ██████╗
████╗ ████║██╔════╝████╗ ████║██╔════╝    ██║     ██╔═══██╗██╔══██╗██╔══██╗
██╔████╔██║█████╗  ██╔████╔██║█████╗      ██║     ██║   ██║██████╔╝██║  ██║
██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║██╔══╝      ██║     ██║   ██║██╔══██╗██║  ██║
██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║███████╗    ███████╗╚██████╔╝██║  ██║██████╔╝
╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝    ╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═════╝

*/

using namespace std;
void Ferrari() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
char arr[100][100];
int main() {
	Ferrari();
	int h, w; cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> arr[i][j];
			//cout << 1;
			//cout << arr[h][w];
		}
		//cout << "\n";
	}

	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			//cin >> arr[h][w];
			cout << arr[(i + 1) / 2][j];
		}
		cout << "\n";
	}
	for (int i = h + 1; i <= h * 2; ++i) {
		for (int j = 1; j <= w; ++j) {
			//cin >> arr[h][w];
			cout << arr[(i + 1) / 2][j];
		}
		
		cout << "\n";
	}
	return 0;
}





/* stuff you should look for
	* keepin sharp mind.
	* int overflow, array bounds.
	* special cases (n=1?), set tle , make sure you understand the proble correctly.
	* don`t stuck in a problem.
	* test the idea on samples.
	*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define DEBUG

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef pair<long,long> pr;
typedef map<double,pr> mp;

short N;

int main(void){
    cin >> N;
    if (N % 10 == 9) cout << "Yes";
    else if (N - 90 > 0) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
priority_queue<int, vector<int>, less<int> > q; 
int main()
{
    int n,m,tmp,ans=0;
    cin>>n>>m;
    for(int i=0;i<n;++i)
    {
        cin>>tmp;
        q.push(tmp);
    }
    for(int i=0;i<m;++i)
    {
        ans+=q.top(); 
        q.pop();
    }
    cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,ll>
using namespace std;
typedef long long ll;
const int maxx=1e5+2;
int main(){
    int m,d; cin>>m>>d;
    int cnt=0;
    for(int i=1;i<=m;i++){
        for(int j=0;j<=d;j++){
            int x=j%10;
            int y=(j/10)%10;
            if(x>=2&&y>=2&&x*y==i){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    string S; cin >> S;
    int cnt = 0;
    rep(i,N-2) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') cnt++;
    }

    cout << cnt << endl;
}

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

int main(){
  int n;
  cin>>n;
  vector<ll>l(n);
  rep(i,n)cin>>l[i];
  ll ans=0;
  sort(l.begin(),l.end());
  rep(i,n-2){
    Rep(j,i+1,n-1){
      Rep(k,j+1,n){
	if(l[i]+l[j]>l[k]&&l[i]!=l[j]&&l[j]!=l[k])ans++;}
    }}
  cout<<ans<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h> // add option -lm
int main() {
  
  int minv,maxv,n;
  int i, j ;
  
  scanf("%d",&n);
  
  int r[n];
  for(i = 0 ; i < n ; i++) {
    scanf("%d",&r[i]);
  }
  minv = r[0];
  maxv = r[1]-r[0] ;
  
  for(j = 1; j < n ; j++) {
    maxv = fmax(maxv, r[j]-minv);    
    minv = fmin(minv, r[j]);
   
  }
  printf("%d\n",maxv);
  return 0;
}

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

int parent(int i) {
    
    return i / 2;
    
}

int left(int i) {
    
    return 2 * i;
    
}

int right(int i) {
    
    return 2 * i + 1;
    
}

int main () {
    int H, i;
    int A[1000000] = {};
    
    cin >> H;
    
    for (i = 1; i < H + 1; i ++) {
        
        cin >> A[i];
        
    }
    
    for (i = 1; i < H + 1; i ++) {
        
        cout << "node " << i << ": key = " << A[i] << ", ";
        
        if (parent(i) >= 1) {
            
            cout << "parent key = " << A[parent(i)] << ", ";
            
        }
        
        if (left(i) <= H) {
            
            cout << "left key = " << A[left(i)] << ", ";
            
        }
        
        if (right(i) <= H) {
            
            cout << "right key = " << A[right(i)] << ", ";
            
        }
        
        cout << endl;
        
    }
    
    return 0;
    
}


Measured memory_bytes: 6988
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;
vector<int> g[200002];
int main() {
    int n, m;
    
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 0; i < g[0].size(); i++) {
        for (int j = 0; j < g[g[0][i]].size(); j++) {
            if (g[g[0][i]][j] == n - 1) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 12016
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

int main() {
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	unsigned int best_b = 0xFFFFFFFF;
	for (int s = 1; s < (1<<n); s++) {
		vector<int> k(m, 0);
		int cost = 0;
		for (int i = 0; i < n; i++) {
			if ((s>>i)&1) {
				for (int j = 0; j < m; j++)
					k[j]+=a[i][j];
				cost += c[i];
				if (cost >= best_b) break;
			}
		}
		if (cost < best_b) {
			bool lower = true;
			for (int j = 0; j < m; j++) {
				if (k[j] < x) {
					lower = false;
					break;
				}
			}
			if (lower) best_b = cost;
		}
	}
	if (best_b == 0xFFFFFFFF)
		cout << -1 << endl;
	else
		cout << best_b << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=1e5+9;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    int x=s.size();
    for (int i=1;i<x;i++){
        if (s[i]==s[i-1]){
            cout<<i<<" "<<i+1<<endl;
            return 0;
        }
    }
    for (int i=2;i<x;i++){
        if (s[i]==s[i-2]){
            cout<<i-1<<" "<<i+1<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1;
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>

using namespace std;

struct node {
    int key;
    node *parent;
    node *left;
    node *right;
};

void walkInOrder(node *cur) {
    if (cur == nullptr) return;
    walkInOrder(cur->left);
    printf(" %d", cur->key);
    walkInOrder(cur->right);
}

void walkPreOrder(node *cur) {
    if (cur == nullptr) return;
    printf(" %d", cur->key);
    walkPreOrder(cur->left);
    walkPreOrder(cur->right);
}

struct binaryTree {
    node *root;

    binaryTree() {
        root = nullptr;
    }

    void insert(int x) {
        node *pParent = nullptr;
        node **v = &root;
        node *nodeX = (node *) malloc(sizeof(node));
        nodeX->key = x;
        nodeX->left = nodeX->right = nullptr;
        while (*v != nullptr) {
            pParent = *v;
            v = &((*v)->key <= x ? (*v)->right : (*v)->left);
        }
        nodeX->parent = pParent;
        *v = nodeX;
    }

    void erase(int x) {
        node *pParent = nullptr;
        node **ppV = &root;
        while (*ppV != nullptr && (*ppV)->key != x) {
            pParent = *ppV;
            ppV = &((*ppV)->key <= x ? (*ppV)->right : (*ppV)->left);
        }
        if ((*ppV) == nullptr) return;
        if ((*ppV)->left != nullptr && (*ppV)->right != nullptr) {
            pParent = *ppV;
            node **nextNode = &pParent->right;
            while ((*nextNode)->left != nullptr) {
                pParent = *nextNode;
                nextNode = &pParent->left;
            }
            (*ppV)->key = (*nextNode)->key;
            ppV = nextNode;
        }
        if ((*ppV)->left == nullptr && (*ppV)->right == nullptr) {
            free((*ppV));
            *ppV = nullptr;
        } else {
            node *vChild = (*ppV)->left != nullptr ? (*ppV)->left : (*ppV)->right;
            free((*ppV));
            *ppV = vChild;
            vChild->parent = pParent;
        }
    }

    void find(int x) {
        node *v = root;
        while (v != nullptr) {
            if (x < v->key) v = v->left;
            else if (v->key < x) v = v->right;
            else break;
        }
        printf("%s\n", v == nullptr ? "no" : "yes");
    }

    void print() {
        walkInOrder(root);
        printf("\n");
        walkPreOrder(root);
        printf("\n");
    }
};

int main() {
    int n, x;
    string op;
    binaryTree tree;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> op;
        if (op[0] == 'p') {
            tree.print();
        } else {
            cin >> x;
            if (op[0] == 'i') tree.insert(x);
            else if (op[0] == 'f') tree.find(x);
            else tree.erase(x);
        }
    }
    return 0;
}



Measured memory_bytes: 21984
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,m,k;
string x;

int main() {
  cin >> n;
  string s[n]; int t[n];
  rep(i,n) cin >> s[i] >> t[i];
  cin >> x;
  int ans=0; bool ok=false;
  rep(i,n){
    if(ok) ans+=t[i];
    if(s[i]==x) ok=true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;



int main() {
	int n;
	cin>>n;
	int l,r;
	int ans=0;
	FORI(0,n){
		cin>>l>>r;
		ans+=r-l+1;

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




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    long long int ans = 0;
    cin >> n;
    ans = n / 500 * 1000;
    ans += n % 500 / 5 * 5;
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,Q;
int const INF=INT_MAX;

struct SegmentTree{
  private:
  int n;
  vector<int> node;
  
  public:
  SegmentTree(vector<int> v){
    int sz=v.size();
    n=1; while(n<sz){n*=2;}
    node.resize(2*n-1,INF);
    for(int i=0;i<sz;i++){node[i+n-1]=v[i];}
    for(int i=n-2;i>=0;i--){node[i]=min(node[2*i+1],node[2*i+2]);}
  }
  void update(int x,int val){
    x+=(n-1);
    node[x]=val;
    while(x>0){
      x=(x-1)/2;
      node[x]=min(node[2*x+1],node[2*x+2]);
    }
  }
  int getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    if(r<=a || b<=l)return INF;
    if(a<=l && r<=b)return node[k];
    int vl=getmin(a,b,2*k+1,l,(l+r)/2);
    int vr=getmin(a,b,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
};

int main(){
  cin >> N >> Q;
  SegmentTree seg(vector<int>(N,INF));
  for(int i=0;i<Q;i++){
    int c,x,y; cin >> c >> x >> y;
    if(c==0){seg.update(x,y);}
    else cout << seg.getmin(x,y+1) << endl;
  }
}


Measured memory_bytes: 4152
import java.math.*

fun main(args: Array<String>) {
    val (N, K) = readInputLine().split(" ").map { it.toLong() }

    var ans = 0L

    for (b in LongRange(1, N)) {
        ans += Math.max(0L, N / b * (b - K))
        ans += Math.max(0L, N % b - K + 1)
    }
    
    if (K == 0L) {
        ans -= N
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 38024
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(void){
    std::string S;
    cin >> S;

    std::map<string, int> m = {
        { "SUN", 7 },
        { "MON", 6 },
        { "TUE", 5 },
        { "WED", 4 },
        { "THU", 3 },
        { "FRI", 2 },
        { "SAT", 1 },
    };

    cout << m[S] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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 = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

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


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  string s;
  int k;
  cin>>s>>k;
  set<string> set;
  for(int i = 0; i < s.length(); i++){
    for(int j = 1; j <= k; j++){
      set.insert(s.substr(i,j));
    }
  }
  
  int counter=1;
  for(auto itr = set.begin(); itr != set.end(); ++itr) {
    if(counter==k){
      cout << *itr << "\n"; 
      return 0; 
    }
      counter++;
    }
  return 0;
}



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

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

  vector<int> ans(N + 1);
  for (long long x = 1; x * x <= N; ++x) {
    for (long long y = 1; y * y <= N; ++y) {
      for (long long z = 1; z * z <= N; ++z) {
        if (1 <= x * x + y * y + z * z + x * y + y * z + z * x &&
            x * x + y * y + z * z + x * y + y * z + z * x <= N) {
          ++ans[x * x + y * y + z * z + x * y + y * z + z * x];
        }
      }
    }
  }

  for (int i = 1; i <= N; ++i) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF=1e9;
int dp[100100];
int main(){
  int m,n;
  cin>>m>>n;
  int c[550],e[550];
  vector<int>p(m);
  REP(i,100100)dp[i]=INF;
  REP(i,m)cin>>p[i];
  dp[0]=0;
  int sum=0;
  REP(i,n){
    cin>>c[i]>>e[i];
    for(int j=sum;j>=0;j--){
      dp[j+c[i]]=min(dp[j+c[i]],dp[j]+e[i]);
    }
    sum+=c[i];
    sum=min(sum,20000);
  }
  for(int i=sum;i>=0;i--){
    dp[i]=min(dp[i],dp[i+1]);
  }
  sort(ALL(p),greater<int>());
  sum=0;
  int ans=0;
  REP(i,m){
    sum+=p[i];
    ans=max(ans,sum-dp[i+1]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1648