akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
ab = [[int(x) for x in input().split()] for _ in range(m)][::-1]

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

def cmb(n, k):
    return n * (n - 1) // 2
convinience = [0]

for i in ab:
    a, b = i
    res = convinience[-1]
    a -= 1
    b -= 1
    if find(a) == find(b):
        convinience.append(res)
        continue
    if size(a) > 1:
        res -= cmb(size(a), 2)
    if size(b) > 1:
        res -= cmb(size(b), 2)
    unite(a, b)
    res += cmb(size(a), 2)
    convinience.append(res)

convinience = convinience[1::][::-1] + [0]

ans = [0]
for i in range(m):
    ans.append(convinience[i] - convinience[i + 1] + ans[-1])
for i in ans[1:]:
    print(i)


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

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

  // 左から W の累積和
  vector<int> cw(N);
  if (S[0] == 'W') cw[0] = 1;
  else cw[0] = 0;
  for (int i=1; i<N; i++) {
    if (S[i] == 'W') cw[i] = cw[i-1] + 1;
    else cw[i] = cw[i-1];
  }

  // 右から E の累積和
  vector<int> ce(N);
  if (S[N-1] == 'E') ce[N-1] = 1;
  else ce[N-1] = 0;
  for (int i=N-2; i>=0; i--) {
    if (S[i] == 'E') ce[i] = ce[i+1] + 1;
    else ce[i] = ce[i+1];
  }

  // 一番左がリーダーのときと一番右がリーダーのとき比較
  int ans = min(ce[1], cw[N-2]);
  // その間がリーダーのとき
  for (int i=1; i<N-1; i++) {
    ans = min(ans, ce[i+1] + cw[i-1]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N; cin >> N;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    int ans = 0;
    rep(i,N-1){
        if(p[i]-1 == i){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    if(p[N-1] == N) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 640
n, k = map(int, input().split())

mod = 10 ** 9 + 7
N = 10 ** 6

#逆元テーブル
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

#階乗計算
kai = [1, 1]
rev_kai = [1, inv_t[1]]
for i in range(2, N):
	kai.append(kai[-1] * i % mod)
	rev_kai.append(rev_kai[-1] * inv_t[i] % mod)

# コンビネーション計算
def cmb(n, r):
	return kai[n] * rev_kai[r] * rev_kai[n-r] % mod

ans = 0
for i in range(0, min(k+1, n)):
    ans += cmb(n, i) * cmb(n-1, i) % mod
    ans %= mod
print(ans)


Measured memory_bytes: 121844
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC087 A - Buying Sweets
// 2020.07.07

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X, A, B; cin >> X >> A >> B;
  int ans = (X-A)%B;
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
typedef long long int ll;
int main() {
    int n,k;
    int p[5000],c[5000];
    scanf("%d %d",&n,&k);
    for (int i=0;i<n;i++) scanf("%d",&p[i]);
    for (int i=0;i<n;i++) scanf("%d",&c[i]);
    for (int i=0;i<n;i++) p[i]--; //0-indexed
    ll ans = -1e10; //if all loops have negative sum
    for (int i=0;i<n;i++) { //calculate each loop
        int x=i;
        int elem[5000];
        int elem_idx=0;
        ll total=0;
        while(1) {
            elem[elem_idx]=c[x];
            elem_idx++;
            total+=c[x];
            x = p[x];
            if (x == i) break;
        }
        int loop_length=elem_idx;
        ll tmp=0;
        for (int i=0;i<loop_length;i++) {
            tmp+=elem[i];
            if (i+1>k) break;
            ll now=tmp;
            if (total>0) {
                ll rot=(k-(i+1))/loop_length;
                now+=total*rot;
            }
            if (ans<now) ans=now;
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int min = 1000000;
    int max = -1000000;
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        min = a < min ? a : min;
        max = a > max ? a : max;
        sum += a;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2720
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue> 
using namespace std;
int main(){
    int n;
    cin >> n;
    int count=0;
    vector<queue<int>> vec(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            int N;
            scanf("%d", &N);
            N--;
            vec[i].push(N);
        }
    }
   // cout<<vec[1].front()<<endl;
   bool kuzu=false;
    while(1){
        bool h=true;
        vector<bool> bl(n,true); 
        for(int i=0;i<n;i++){
            if(vec[i].empty()){
                continue;
            }
            int a = vec[i].front();
            if(bl[i]==false){
                continue;
            }
            if(bl[a]==false){
                continue;
            }
          //  cout<<a<<endl;
         //   cout<<"入った"<<endl;
            
            if(vec[a].front()==i){
                //cout<<"入った"<<endl;
                vec[i].pop();
                vec[a].pop();
                h=false;
                bl[i]=false;
                bl[a]=false;
             //   cout<<"i"<<i+1<<"a"<<a+1<<endl;
            }
        }
        if(h){
            break;
        }
        count++;
        if(count==7000){
            kuzu=true;
            break;
        }
    }
    bool ha=true;
    for(int i=0;i<n;i++){
        if(!vec[i].empty()){
            ha=false;
            break;
        }
    }
    if(kuzu)cout<<499500<<endl;
    else if(ha){
        cout<<count<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 4736
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let aoki = s.next().unwrap().parse::<usize>().unwrap() - 1;
	let takh = s.next().unwrap().parse::<usize>().unwrap() - 1;
	let mut edges = vec![vec![]; n];
	for _ in 0..n - 1 {
		let a = s.next().unwrap().parse::<usize>().unwrap() - 1;
		let b = s.next().unwrap().parse::<usize>().unwrap() - 1;
		edges[a].push(b);
		edges[b].push(a);
	}
	let tree = Tree::new(&edges, takh);
	let ans = edges.iter().enumerate().fold(0, |r, (i, l)|{
		if l.len() == 1 {
			let a = tree.lca(aoki, i);
			if tree.depth[aoki] - tree.depth[a] < tree.depth[a] {
				return std::cmp::max(r, tree.depth[i] - 1);
			}
		}
		r
	});
	println!("{:?}", ans);
}

struct Tree {
	parent: Vec<Vec<Option<usize>>>,
	depth: Vec<i32>,
}

impl Tree {
	fn new(edges: &Vec<Vec<usize>>, root: usize) -> Self {
		let n = edges.len();
		let log = (n as f64).log(2.).floor() as usize;
		let mut parent = vec![vec![None; n]; log + 1];
		let mut depth = vec![0; n];
		let mut st = std::collections::VecDeque::new();
		st.push_front((root, None, 0));
		while let Some((v, p, d)) = st.pop_back() {
			parent[0][v] = p;
			depth[v] = d;
			for e in edges[v].iter() {
				if *e != p.unwrap_or(std::usize::MAX) {
					st.push_back((*e, Some(v), d + 1));
				}
			}
		}
		for k in 0..parent.len() - 1 {
			for v in 0..n {
				if let Some(p) = parent[k][v] {
					parent[k + 1][v] = parent[k][p];
				}
			}
		}
		Tree { parent: parent, depth: depth }
	}

	fn lca(&self, u: usize, v: usize) -> usize {
		let (mut u, mut v) = if self.depth[u] > self.depth[v] { (v, u) } else { (u, v) };
		for k in 0..self.parent.len() {
			if ((self.depth[v] - self.depth[u]) >> k) & 1 != 0 {
				v = self.parent[k][v].unwrap();
			}
		}
		if u == v {
			u
		} else {
			for k in (0..self.parent.len()).rev() {
				if self.parent[k][u] != self.parent[k][v] {
					u = self.parent[k][u].unwrap();
					v = self.parent[k][v].unwrap();
				}
			}
			self.parent[0][u].unwrap()
		}
	}
}


Measured memory_bytes: 53500
n, a, b = map(int, input().split())
total = 0
for i in range(1, n+1):
  total_digit = 0
  j = i
  while True:
    total_digit += j % 10
    j //= 10
    if j == 0:
      if total_digit >= a and total_digit <= b:
        total += i
      break
print(total)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string res = "";
  for (int i = 0; i < 3; i++) {
    string s;
    cin >> s;
    res += s[i];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 2e5+10, M = 1 << 10;
int n, m, k;
ll a[N], b[N];
int ans = 0;
int main() {
	cin>>n>>m>>k;
	rep(i, 1, n + 1) scanf("%lld", &a[i]);
	rep(i, 1, m + 1) scanf("%lld", &b[i]);
	rep(i, 1, n + 1) a[i] += a[i - 1];
	rep(i, 1, m + 1) b[i] += b[i - 1];
	int j = m;
	rep(i, 0, n + 1) {
		if(a[i] > k) break;
		while(a[i] + b[j] > k) {
			j--;
		}
		ans = max(ans, i + j);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6776
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N, M = map(int, input().split())
a = list(map(int, list(input())[: -1]))
a.reverse()
res = []

table = []
for i in range(N + 1):
  if a[i] == 0: table.append(i)
#print(table)
p = 0
while p < N:
  j = bl(table, p + M)
  q = table[min(len(table) - 1, j)]
  if q > p + M: j -= 1
  q = table[min(len(table) - 1, j)]
  #print(p, q, res)
  if p == q:
    print(-1)
    exit(0)
  res.append(q - p)
  p = q
res.reverse()
print(*res)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

constexpr ll MOD = 1000000000 + 7;

int N, M;
std::vector<P> v;

ll f(){
    int n = N * M, po = 0;
    int r = 0, c = 0, rem = 0;
    ll cnt = 1;
    
    while(n > 0){
        if(po < v.size() && fst(v[po]) == n){
            int x1, y1;
            std::tie(x1, y1) = v[po];

            if(po + 1 < v.size() && fst(v[po+1]) == n){
                if(snd(v[po+1]) == y1){
                    return 0;
                }

                po += 2;
                rem += r + c;
                r += 1;
                c += 1;
            }else{
                if(y1 == 1){
                    if(c == 0){
                        return 0;
                    }

                    cnt = cnt * c % MOD;
                    r += 1;
                    rem += c - 1;
                }else{
                    if(r == 0){
                        return 0;
                    }

                    cnt = cnt * r % MOD;
                    c += 1;
                    rem += r - 1;
                }

                po += 1;
            }
        }else{
            if(rem == 0){
                return 0;
            }

            cnt = cnt * rem % MOD;
            rem -= 1;
        }

        n -= 1;
    }

    if(r < N || c < M || rem > 0){
        return 0;
    }

    return cnt;
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        int A;
        std::cin >> A;

        v.emplace_back(A, 1);
    }

    for(int i=0;i<M;++i){
        int B;
        std::cin >> B;

        v.emplace_back(B, 2);
    }

    std::sort(v.rbegin(), v.rend());

    ll res = f();
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

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

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	string A[3];
	FOR(i, 0, 3) cin >> A[i];

	string ans = "YES";
	FOR(i, 0, 2) {
		int L = A[i].size();
		if (A[i][L - 1] != A[i + 1][0]) {
			ans = "NO";
			break;
		}
	}

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


Measured memory_bytes: 256
/**
 * author:    Ziel
 * created:   13.04.2020 19:42:34
**/

#include <bits/stdc++.h>

using namespace std;

const int N = 100100;

int n, h[N];
long long dp[N];

int main() {
	scanf("%d",&n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", h + i);
    }
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    printf("%lld", dp[n]);
    
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}


int main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> ab(N);
  rep(i,M){
    int a, b; cin >> a >> b;
    a--; b--;
    ab[a].push_back(b);
    ab[b].push_back(a);
  }
  
  bool ok = false;
  int size1 = ab[0].size();  
    rep(i,size1){
      int second = ab[0][i];
      int size2 = ab[second].size();
      rep(j,size2){
        int third = ab[second][j];
        if(third == N-1){
          ok = true;
          cout << "POSSIBLE" << endl;
          return 0;
        }
      }
    }
  
  if(!ok) cout << "IMPOSSIBLE" << endl;
  
}

  



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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    int a,b;
    cin>>a>>b;
    for(int i=1; i<=10000000; i++) {
        if((i*8)/100==a&&i/10==b) {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        String s = arr01[0];
        String t = arr01[1];

        System.out.println(t + s);

    }

}

Measured memory_bytes: 22484
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int d = Integer.parseInt(in.next());

            while (true) {
                c = c - b;
                if (c <= 0) break;
                a = a - d;
                if (a <= 0) break;

            }
            // 出力
            if (a <= 0) {
                out.println("No");
            } else {
                out.println("Yes");
            }

        }

    }
}



Measured memory_bytes: 35940
#include "bits/stdc++.h"
using namespace std;
const int N = 2e6 + 6;
const int mod = 1e9 + 7;
int n;
int dp[N + 2];
int sm[N + 2];
int main(){
	scanf("%d" , &n);
	sm[N + 1] = 0;
	for(int i = N ; i > n ; --i){
		dp[i] = 1;
		sm[i] = (sm[i + 1] + dp[i]) % mod;
	}
	dp[n] = n;
	sm[n] = (sm[n + 1] + dp[n]) % mod;
	for(int pos = n - 1 ; pos >= 1 ; --pos){
		long long res = 0;
		res += dp[pos + 1];
		res += 1LL * (n - 1LL) * (n - 1LL);
		res += sm[pos + 3] - sm[pos + n + 2];
		res %= mod;
		res += mod;
		res %= mod;
		dp[pos] = res;
		sm[pos] = (sm[pos + 1] + res) % mod;
	}
	printf("%d\n" , dp[1]);
}

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef pair<double, string> P;

int main ( void )
{
	int n;

	while (cin >> n, n) {
		priority_queue<P, vector<P>, greater<P> > que;

		for (int i = 0; i < n; ++i) {
			string l;
			int p, a, b, c, d, e, f, s, m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;

			int kin = f * m * s - p;
			int time = a + b + c + (d + e) * m;
			que.push(P(-(double)kin/time, l));
		}

		while (!que.empty()) {
			P p = que.top(); que.pop();
			cout << p.second << endl;
		}
		cout << '#' << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
from collections import Counter
from itertools import accumulate
from bisect import bisect_left
N=int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A=prime_factorize(N)
a=list(range(1,11))
b=list(accumulate(a))
ans=0
for i,value in Counter(A).items():
    if value in b:
        ans+=b.index(value)+1
    else:
        ans+=bisect_left(b,value)
print(ans)

Measured memory_bytes: 67748
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> east_sum(s.size() + 1);
  vector<int> west_sum(s.size() + 1);
  REP(i, s.size()) {
    east_sum[i + 1] = east_sum[i] + (s[i] == 'E');
    west_sum[i + 1] = west_sum[i] + (s[i] == 'W');
  }

  int res = s.size();
  REP(i, s.size()) {
    res = min(res, west_sum[i] + (east_sum[s.size()] - east_sum[i + 1]));
  }
  cout << res << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,m,x,c[20],a[20][20],ans[20],mincost=1e18,cost;
void solve()
{
    cin>>n>>m>>x;
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    }
    int len=(1LL<<n);
    for(int mask=1;mask<len;mask++)
    {
        memset(ans,0,sizeof(ans));
        cost=0;
        for(int i=0;i<n;i++)
            if((1LL<<i)&mask)
            {
                cost+=c[i];
                for(int j=0;j<m;j++)
                    ans[j]+=a[i][j];
            }
        //cout<<mask<<'\n';
        //for(int j=0;j<m;j++)cout<<ans[j]<<" ";cout<<'\n';
        int flag=1;
        for(int j=0;j<m;j++)
            if(ans[j]<x)flag=0;
        if(flag)mincost=min(mincost,cost);
    }
    if(mincost==1e18)cout<<-1;
    else cout<<mincost;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("CUBE.inp","r",stdin);
    //freopen("CUBE.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
ll mod = 1000000007;
signed main(){
    string s;
    cin >>s;
    vector<ll> v(26,0);
    for (int i = 0; i < s.size(); i++)
    {
        v.at(s.at(i)-'a')++;
    }
    ll ans=(s.size())*(s.size()-1)/2 +1;//反転しない分を足す
    for (int i = 0; i < 26; i++)
    {
        if(v.at(i)>1){
            ans-=(v.at(i))*(v.at(i)-1)/2;
        }
    }
    cout<<ans<<endl;
}
/*何をカウントすればいいのかわからなかった
回文はカウント、ただ入力例3が分からない
→abraは、brを反転してもabraを反転しても同じになる！
実験が足りなかった

アルファベットは26*/


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(void)
{
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    
    if(x>0&&y>0&&x+r<=W&&y+r<=H)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <stdlib.h>
#define ll long long

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll dp[1000010];
int n;
int bs(ll x){
	//dp[l]<x<=dp[r]
	int l=0,r=n*n+1;
	while(r-l>1){
		int m=(l+r)/2;
		if(dp[m]<x)l=m;
		else r=m;
	}
	return r;
}


ll a[1010],b[1010];
int main(){
	ll v;
	scanf("%d%lld",&n,&v);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	for(int i=0;i<n;i++)scanf("%lld",b+i);
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)dp[i*n+j]=a[i]+b[j];
	sortup(dp,n*n+1);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	for(int i=0;i<n;i++)scanf("%lld",b+i);

	long ans=0;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++){
		long t=v-(a[i]+b[j]);
		if(t){
			int l=bs(t);
			if(dp[l]!=t)continue;
			ans+=bs(t+1)-l;
		}
	}
	printf("%ld\n",ans);
}


Measured memory_bytes: 17104
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
#define rep(i,n) for(int i=0; i<n; ++i)
using ll = long long;
const ll Inf = (1ULL << 62) -1;

ll n=0, wmax=0;
vector<ll> w, v;
ll dp[101][100001];

int main() {
    cin >> n >> wmax;
    w.resize(n);
    v.resize(n);
    rep(i,n) cin >> w[i] >> v[i];
    rep(i,n) {
        rep(r,wmax+1) {
            if (r >= w[i]) {
                dp[i+1][r] = max(dp[i][r], dp[i][r-w[i]] + v[i]);
            } else {
                dp[i+1][r] = dp[i][r];
            }
        }
    }

    ll ans = dp[n][wmax];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81264
N,M=map(int,input().split())
A=list(map(int,input().split()))
import heapq
for i in range(N):
    A[i]=-A[i]
heapq.heapify(A)
for i in range(M):
    X=heapq.heappop(A)
    X=X//2 if X%2==0 else X//2+1
    heapq.heappush(A,X)
print(-1*sum(A))

Measured memory_bytes: 73496
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans = B[i] + ans
for i in range(N-1):
    if A[i+1] == A[i]+1:
        ans = C[A[i]-1] + ans
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    int a;
    cin >> a;
    int n=a%10;
    if(n==2 or n==4 or n==5 or n==7 or n==9) cout << "hon" << endl;
    else if(n==3) cout << "bon" << endl;
    else cout << "pon" << endl;
    return 0;
}


Measured memory_bytes: 3572
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    ["dream", "dreamer", "erase", "eraser"].map!(s => s.retro.to!(char[])).pipe!((ary) {
        char[] str = readln.chomp.retro.to!(char[]);
        while({
            if (str.empty) return false;
            foreach(e; ary) {
                size_t s = e.length;
                if (str.length>=s && str[0..s]==e) {
                    str = str[s..$];
                    return true;
                }
            }
            return false;
        }()){}
        return str.empty;
    }).pipe!(a =>a?"YES":"NO").writeln;
}


Measured memory_bytes: 1560
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double r = Double.parseDouble(sc.next());

		double s = Math.PI * r * r;
		double l = 2 * Math.PI * r;

		System.out.print(String.format("%.06f %.06f",s,l));
	}
}

Measured memory_bytes: 26560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,f,n) for(int i=f; i<(n); i++)
int main()
{
  int ans = 0;
  cin >> ans;
  if(ans==0)
  cout << 1 << endl;
  else
  {
    cout << 0 << endl;
  }
  

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3620
n,m = map(int,input().split())
abc = []

dist = [[float('inf')] * n for _ in range(n)]
for i in range(n):
  dist[i][i] = 0
for _ in range(m):
  abc.append(list(map(int,input().split())))

for a,b,c in abc:
  dist[a-1][b-1] = c
  dist[b-1][a-1] = c
for k in range(n):
    for i in range(n):
      for j in range(n):
          dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])

ans = 0
for a,b,c in abc:
    if dist[a-1][b-1]  < c:
        ans += 1

print(ans)

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 a, b, k;
    std::cin >> a >> b >> k;
    i64 da = std::min(a, k);
    k -= da;
    i64 db = std::min(b, k);
    std::cout << a - da << " " << b - db << std::endl;

    return 0;
}


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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

bool ans[85][85][13000];

int main() {
  ll N,K;
  cin>>N>>K;
  vector<P> v(N);
  rep(i,N) cin>>v[i].second>>v[i].first;
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  ll p = K-1;
  ll total = 0;
  ll ans = 0;
  map<ll,ll> m;
  ll cnt = 0;
  rep(i,K){
    total += v[i].first;
    if(m[v[i].second]==0) cnt++;
    m[v[i].second]++;
  }
  ans = total + cnt*cnt;
  priority_queue<ll,vector<ll>,greater<ll>> q;
  rep(i,K){
    if(m[v[K-i-1].second]!=1) {
      q.push(v[K-i-1].first);
      m[v[K-i-1].second]--;
    }
  }
  priority_queue<ll> pl;
  for(int i = K; i < N; i++){
    if(m[v[i].second]==0) pl.push(v[i].first);
    m[v[i].second]++;
  }
  while(!q.empty()&&!pl.empty()){
    ll t = q.top();
    ll s = pl.top();
    q.pop();
    pl.pop();
    total -= t;
    total += s;
    cnt++;
    chmax(ans,total+cnt*cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11372
#include<stdio.h>
#include<string.h>

int LCSlength(char*,char*);

int main(){

  int q,i,length;
  char x[1000],y[1000];

  scanf("%d",&q);

  for(i=0;i<q;i++){

    scanf("%s",x);
    scanf("%s",y);

    length=LCSlength(x,y);

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

  return 0;

}

int LCSlength(char X[],char Y[]){

  int m,n,i,j;

  m = strlen(X);
  n = strlen(Y);  

  int c[m+1][n+1];
  
  for(i=1;i<=m;i++){
    c[i][0] = 0;
  }

  for(j=0;j<=n;j++){
    c[0][j]=0;
  }
   
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){

      if(X[i-1]==Y[j-1]) c[i][j]=c[i-1][j-1]+1;
      
      else if(c[i-1][j] >= c[i][j-1]) c[i][j]=c[i-1][j];

      else c[i][j]=c[i][j-1];

    }
  }

    return c[m][n];
}

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

struct Data{
       long long ex_pos; // 元の位置
       long long num; // 実際のデータ
       long long end;
       long long start;
};

int cmp( const void *p, const void *q ) {
    return ((Data*)p)->end - ((Data*)q)->end;
}

int main() {   
    long long N;
    long long ans=0;
    cin >> N;
    Data d[N];
    for (long long i = 0; i < N; i++) {
        cin >> d[i].ex_pos >> d[i].num;
        d[i].end = d[i].ex_pos + d[i].num;
        d[i].start = d[i].ex_pos - d[i].num;
    }

    qsort( d, N, sizeof(Data), cmp );

    long long now = d[0].ex_pos;
    long long now_a = d[0].num;
    long long t = d[0].start-1;

    for (long long i = 0; i < N; i++) { 
        if(t <= d[i].start){
            ans++;
            t = d[i].end;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6524
import numpy as np

def test():
    n = int(input())
    s = input()
    w = [0]*n
    e = [0]*n
    ans = float("inf")
    for i in range(n):
        if s[i] == "W":
            w[i] = 1
        else:
            e[i] = 1
    w = np.cumsum(w)
    e = np.cumsum(e)

    for i in range(n):
        res = 0
        if i>=1:
            res += w[i-1]
        res += e[n-1] - e[i]
        ans = min(ans,res)
    print(ans)


if __name__ == "__main__":
    test()


Measured memory_bytes: 22128
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;
int n, k;

int main()
{
	cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int tot = 0;
	for (int i = 0; i < k; ++i)
	{
		tot += v[i];
	}
	cout << tot << "\n";
	
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    bool flag[n];
    for (int i = 0; i < n; i++) {
        if (a[i] % 2) flag[i] = false;
        else flag[i] = true;
    }
    int count = 1;
    for (int i = 0; i < n; i++) {
        count *= 3;
    }
    int count2 = 1;
    for (int i = 0; i < n; i++) {
        if (flag[i]) count2 *= 2;
    }
    cout << count - count2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int 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 COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
int a, b, c, d, k;
signed main() {
	cin >> a >> b >> c >> d >> k;
	int memo1 = c * 60 + d;
	int memo2 = a * 60 + b;
	cout << memo1 - memo2 - k << endl;
	ggr
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>

int main()
{
  for ( ; ; ) {
    int x, y ;
    std::cin >> x >> y ;
    if ( x == 0 && y == 0 )
      break ;
    if ( x > y )
      std::swap( x, y ) ;

    std::cout << x << " " << y << std::endl ;
  }

  return 0 ;
}

Measured memory_bytes: 3052
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long k = scan.nextLong();
		long ans = 0;
		boolean loop = true;
		
		if(n == 0) {
			loop = false;
		}
      
      	if(k == 1) {
			loop = false;
		}
      	long x = n;
		if(x > k) {
			long a = x / k;
			x = x - (k * a);
			if(x == 0) {
				loop = false;
			}
		} else if(x == k){
			loop = false;
		}
      	
		long pre = x;
		while(loop) {			
			x = x - k;
			if( x == 0) {
				loop = false;
			}
			if(x < 0) {
				loop = false;
                x = Math.abs(x);
				if(x < pre) {
					ans = x;
				} else {
					ans = pre;
				}
			}
			
			pre = Math.abs(x);
		}
				
		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
def main():
    import numpy as np
    N, W = map(int, input().split())
    ndp = np.zeros(W+1, dtype= np.int64)
    for _ in range(N):
        w, v = map(int,input().split())
        np.maximum(ndp[:-w] + v, ndp[w:], out = ndp[w:])
    else:print(ndp[-1])

if __name__=="__main__":
    main()

Measured memory_bytes: 22292
#include<stdio.h>
long power_(long a,long n){
  long i = 0;
  long result = 1;
  for(i=0;i<n;i++){
    result *= a;
  }
  return result;
}

long modminus2(long n){
  if((n/(-2))*(-2) == n){
    return 0;
  }else{
    return 1;
  }
}

int main(){
  long n = 0;
  long m = 0;
  long i = 0;
  int d[1000] = {};
  long cnt = 0;
  scanf("%ld",&n);
  m = n;
  cnt = 0;
  while(m != 0){
    d[cnt] = modminus2(m);
    cnt++;
    m = (m - modminus2(m))/(-2);
    //printf("%d/",m);
  }
  if(n == 0){
    printf("0");
  }else{
    for(i=0;i<cnt;i++){
      printf("%d",d[cnt-1-i]);
    }
  }
  
  return 0;
}
    
  

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;

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

map <string , int > r;
string p;
int a= -1;
vector<string> x;

rep(i,n){
  cin>>p;
  r[p]++;

if(r[p]==a){
  x.push_back(p);
}

if(a<r[p]){
  x.clear();
  a=r[p];
  x.push_back(p);
}

}

sort(x.begin(),x.end());

for(ll i=0; i<x.size(); i++){
  cout << x[i] << endl;
}

return 0;
}

Measured memory_bytes: 26736
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,l=0,sum=0;
  int a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%2==1) l++;
  }
  if(l) cout<<"first\n";
  else cout<<"second\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;
int main(){   
    int h,a;
    cin>>h>>a;
    int ans = 0;
    while(ans * a < h)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a, b, max;
  cin >> a >> b;

  max = ((int)ceil(b * 10.0) > (int)ceil(100 * a / 8.0) ? (int)ceil(b * 10.0) : (int)ceil(100 * a / 8.0));
  if ((int)floor(max * 0.08) == a && (int)floor(max * 0.1) == b)
  {
    cout << max << endl;
  }
  else
  {
    cout << "-1" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    string S; cin>>S;
    vec R(N),L(N);
    REP(i,N-1){
        R[i+1]=R[i];
        if(S[i]=='W') R[i+1]++;
        L[N-i-2] = L[N-i-1];
        if(S[N-i-1]=='E') L[N-i-2] ++;
    }
    int ans = N;
    REP(i,N) ans = min(ans,L[i]+R[i]);
    Out(ans);
}


Measured memory_bytes: 5396
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=10000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;

typedef pair<int,P>Pa;
vector<int> v[100001];
int n,m;
int x[100005],y[100005];
int C[100005];
int D[100005]={};
bool b[100005]={};
struct edge{
	int score;
	int num;
};
int main() {
	cin>>n>>m;
	rep(i,0,m){
		cin>>x[i]>>y[i];
		v[x[i]-1].push_back(y[i]-1);
		b[y[i]-1]=true;
		D[y[i]-1]++;
	}
	rep(i,0,n)C[i]=-1;
	queue<edge> que;
	rep(i,0,n)if(!b[i])que.push(edge{0,i});
	while(!que.empty()){
		edge e=que.front();que.pop();
		if(C[e.num]>e.score)continue;
		for(int num2:v[e.num]){
			if(--D[num2]>0)continue;
			if(C[num2]<e.score+1){
				C[num2]=e.score+1;
				que.push(edge{e.score+1,num2});
			}
		}
	}
	int ans=0;
	rep(i,0,n){
		ans=max(ans,C[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7424
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
const int MaxN = 1e5;
using namespace std;
int a[MaxN + 5] , n , c , k;
int main()
{
	while(~scanf("%d%d%d" , &n , &c , &k)){
		for(int i = 1;i <= n;i++) scanf("%d" , &a[i]);
		sort(a + 1 , a + n + 1);
		int cont = 1 , ans = 1;
		for(int i = 1;i <= n;i++){
			if(a[i] - a[cont] > k || i - cont + 1 > c) ans++ , cont = i;
		}
		printf("%d\n" , ans);
	}
}

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

signed main(){
  int N, K; cin >> N >> K;
  long long ans = 0;
  for(int b = K + 1; b <= N; b++){
    int p = N/b;
    int r = N%b;
    ans += (p * max(0, b - K) + max(0, r - K + 1)) - (K == 0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

ll rec(ll x)
{
  auto next = x >> 1;
  if (next > 0) {
    return 2 * rec(next) + 1;
  }
  else {
    return 1;
  }
}

void solve(void)
{
  ll H; cin >> H;
  auto ans = rec(H);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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


void solve()
{
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
    
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    /*int t;
    cin >> t;
    while(t--)
    {
         solve();  
    }
   */ solve();
    return 0;
}



Measured memory_bytes: 3652
package main 

import (
  "fmt"
)

func main() {
  var N int
  data := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
  fmt.Scanf("%d\n", &N)
  
  fmt.Println(data[N-1])
}


Measured memory_bytes: 512