akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

class Dice
{
public:
	long top, front, right, left, back, bottom;
	Dice(long top, long front, long right, long left, long back, long bottom);
	void north();
	void south();
	void west();
	void east();
	void showTop();
};

Dice::Dice(long top, long front, long right, long left, long back, long bottom){
	this->top = top;
	this->front = front;
	this->right = right;
	this->left = left;
	this->back = back;
	this->bottom = bottom;
}

void Dice::north(){
	long sv[6];
	sv[0] = this->front;
	sv[1] = this->bottom;
	sv[2] = this->right;
	sv[3] = this->left;
	sv[4] = this->top;
	sv[5] = this->back;

	this->top = sv[0];
	this->front = sv[1];
	this->right = sv[2];
	this->left = sv[3];
	this->back = sv[4];
	this->bottom = sv[5];
}

void Dice::south(){
	long sv[6];
	sv[0] = this->back;
	sv[1] = this->top;
	sv[2] = this->right;
	sv[3] = this->left;
	sv[4] = this->bottom;
	sv[5] = this->front;

	this->top = sv[0];
	this->front = sv[1];
	this->right = sv[2];
	this->left = sv[3];
	this->back = sv[4];
	this->bottom = sv[5];
}

void Dice::west(){
	long sv[6];
	sv[0] = this->right;
	sv[1] = this->front;
	sv[2] = this->bottom;
	sv[3] = this->top;
	sv[4] = this->back;
	sv[5] = this->left;

	this->top = sv[0];
	this->front = sv[1];
	this->right = sv[2];
	this->left = sv[3];
	this->back = sv[4];
	this->bottom = sv[5];
}

void Dice::east(){
	long sv[6];
	sv[0] = this->left;
	sv[1] = this->front;
	sv[2] = this->top;
	sv[3] = this->bottom;
	sv[4] = this->back;
	sv[5] = this->right;

	this->top = sv[0];
	this->front = sv[1];
	this->right = sv[2];
	this->left = sv[3];
	this->back = sv[4];
	this->bottom = sv[5];
}

void Dice::showTop(){
	cout << this->top << endl;
}

int main(){
	long roll[6];
	Dice *dice;
	for (long i = 0; i < 6; i++){
		cin >> roll[i];
	}
	//dice = new Dice(1, 2, 4, 8, 16, 32);
	dice = new Dice(roll[0], roll[1], roll[2], roll[3], roll[4], roll[5]);
	string s;
	cin >> s;
	//s = "EESWN";
	for (long i = 0; i < s.size(); i++){
		if (s[i] == 'N') dice->north();
		else if (s[i] == 'W') dice->west();
		else if (s[i] == 'S') dice->south();
		else if (s[i] == 'E') dice->east();
	}
	dice->showTop();
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

 
ll int data[100000];

int getindex(ll int* data, int lessthanthis, int l, int r){
  if(l > r) return -1;
  if(l == r || l + 1 == r){
    if(data[r] < lessthanthis) return r;
    else if(data[l] < lessthanthis) return l;
    else return -1;
  }
  int p = (l + r) / 2;
  // cout << " l :" << l << " r: " << r << " p: " << p << endl;
  if(data[p] < lessthanthis) return getindex(data, lessthanthis, p, r);
  else return getindex(data, lessthanthis, l, p);
}

// int main(){
//   REP(i, 10) data[i] = i;
//   REP(i, 10) cout << data[i] << " ";
//   cout << endl;
//   cout << getindex(data, 19, 0, 9) << endl;
// }

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll int ans = 0;
  int n, m;
  cin >> n >> m;
  REP(i, n) cin >> data[i];
  sort(data, data+n);
  vector<pair<ll int, int>> vp;
  ll int maxc = -1;
  REP(i, m){
    int b;
    ll int c;
    cin >> b >> c;
    maxc = max(maxc, c);
    c = -1 * c;
    vp.push_back(mp(c,b));
  }
  sort(All(vp));
  int target_made = getindex(data, maxc, 0, n-1);
  // cout << "target_made : " << target_made << endl;
  int cnt = n;
  FOR(i, target_made + 1, n){
    ans += data[i];
    cnt--;
  }
  int target_l = 0;
  int rewrite_numsum = 0;
  REP(i, vp.size()){
    ll int c = -1 * vp[i].first;
    int b = vp[i].second;
    // cout << " target_l : " << target_l << " c : " << c << endl;
    // cout << " getindex : " << getindex(data, c, target_l, n-1) << endl;
    ll int rewrite_num = min(b, getindex(data, c, target_l, n-1) - target_l + 1);
    // cout << " rewrite_num : " << rewrite_num << " rewrite_to : " << c << endl;
    if(rewrite_num < 0) continue;
    target_l += rewrite_num;
    ans += rewrite_num * c;
    cnt -= rewrite_num;
    rewrite_numsum += rewrite_num;
  }

  // cout << " nokori cnt: " << cnt << endl;
  for(int i = rewrite_numsum; i < rewrite_numsum + cnt; i++){
    ans += data[i];
  }
  cout << ans << endl;



}

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

using namespace std;

int dirs[4][2]={{-1, 0}, {0, 1}, {1, 0}, {0, -1}};

int MAX=100000;

int main()
{
    //freopen("inp.in", "r", stdin);
    //ios::sync_with_stdio(false);
    vector<bool> is_prime(MAX, true);
    is_prime[0]=false;
    is_prime[1]=false;
    for(int i=2; i<MAX; i++)
    {
        for(long long j=1LL*i*i; j<MAX; j+=i) is_prime[j]=false;
    }
    int n;
    scanf("%d", &n);
    vector<int> v;
    for(int i=0; i<MAX; i++)
    {
        if(is_prime[i] && i%5==1) v.push_back(i);
    }
    for(int i=0; i<n; i++)
    {
        if(i != 0) printf(" ");
        printf("%d", v[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int sum = 0;
    for(int mokemoke =a;mokemoke<=b;mokemoke++){
        if(c%mokemoke == 0){
            sum++;
        }


    }
    cout << sum << endl;


    return 0;
}

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


int main() {
    char c;
    int ans = 0;
    rep(i,3){
        cin >> c;
        if(c == '1')ans++;
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int N;
string S;

int main(void){
    cin >> N >> S;
    int ans=1;
    rep(i,N-1)if(S[i]!=S[i+1])ans++;
    cout << ans<< endl;
}


Measured memory_bytes: 512
fn main() {
    let n: usize = read();
    let mut graph: Vec<Vec<usize>> = Vec::new();
    for _ in 0..n {
        let tmp: Vec<usize> = read_vec();
        let (_left, right) = tmp.split_at(2);
        graph.push(right.iter().map(|&v| v - 1).collect());
    }

    let mut visited: Vec<bool> = vec![false; n];
    let mut log: Vec<(usize, usize)> = vec![(0, 0); n];
    let mut timestamp = 1;
    for u in 0..n {
        dfs(&graph, u, &mut timestamp, &mut visited, &mut log);
    }

    for (i, &(l, r)) in log.iter().enumerate() {
        println!("{} {} {}", i + 1, l, r);
    }
}

fn dfs(graph: &Vec<Vec<usize>>, cur: usize, timestamp: &mut usize, visited: &mut Vec<bool>, log: &mut Vec<(usize, usize)>) {
    // dbg!(&timestamp);
    if !visited[cur] {
        visited[cur] = true;
        log[cur] = (timestamp.clone(), 0);
        *timestamp = *timestamp + 1;
        for v in graph[cur].iter() {
            dfs(graph, *v, timestamp, visited, log);
        }
        log[cur] = (log[cur].0, timestamp.clone());
        *timestamp = *timestamp + 1;
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 5032
#include<iostream>

using namespace std;

class ButCoder{
    public:
        int n, r;

        int Rating(int n, int r)
        {
            int rat = r;
            if(n < 10)
            {
                rat = 100 * (10 - n);
                rat += r;
            }

            return rat;
        }

};

int main()
{

    ButCoder obj;

    cin >> obj.n >> obj.r;

    cout << obj.Rating(obj.n, obj.r) << endl;
    return 0;
}



Measured memory_bytes: 256
# python 3.4.3
import sys
input = sys.stdin.readline
import numpy as np

# -------------------------------------------------------------
# function
# -------------------------------------------------------------
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0]*(n+1)
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def check(self, x, y):
        return self.find(x) == self.find(y)

# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,K,L = map(int,input().split())
PQ = [tuple(map(int,input().split())) for _ in range(K)]
RS = [tuple(map(int,input().split())) for _ in range(L)]

# 道路
A = UnionFind(N)
for p,q in PQ:
    A.unite(p-1,q-1)
 
# 鉄道
B = UnionFind(N)
for r,s in RS:
    B.unite(r-1,s-1)

# 集計
from collections import defaultdict
dic = defaultdict(int)
for i in range(N):
    dic[A.find(i), B.find(i)] += 1
 
Ans = list(dic[A.find(i), B.find(i)] for i in range(N))
print(" ".join(map(str,Ans)))

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

int main() {
    long long X, K, D;
    cin >> X >> K >> D;
    if (X>0) {
        if (K>=(X/D)) {
            K-=(X/D);
            X-=(D*(X/D));
        }
        else {
            X-=(D*K);
            K=0;
        }
        if (K%2==0) cout << abs(X);
        else cout << abs(X-D);
    }
    else {
        if (K>=abs(X/D)) {
            K-=(X/D);
            X+=(D*abs(X/D));
        }
        else {
            X+=(D*K);
            K=0;
        }
        if (K%2==0) cout << abs(X);
        else cout << abs(X+D);
    }
}

Measured memory_bytes: 3628
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
dic = defaultdict(int)
for i in range(n):
    a = I()
    dic[a] += 1
ans = 0
for k,v in dic.items():
    ans += v%2
print(ans)


Measured memory_bytes: 20560
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 1000001;

int GCD(int a,int b){
    if(a < b)swap(a,b);
    if(a % b)return GCD(b,a % b);
    return b;
}

int main(){
    int N;
    int A[MAX];
    int table[MAX] = {0};
    bool pc = true;
    bool sc = true;

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

    for(int i = 2;i < MAX;i++){
        int cnt = 0;
        for(int j = i;j < MAX;j += i){
            cnt += table[j];
        }
        if(cnt >= 2){
            pc = false;
            break;
        }
    }

    int gcd = A[0];
    for(int i = 1;i < N;i++){
        gcd = GCD(gcd,A[i]);
    }
    if(gcd != 1){
        sc = false;
    }

    if(pc){
        cout << "pairwise coprime" << endl;
    }else if(sc){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }

    return 0;
}



Measured memory_bytes: 10832
# -*- coding: utf-8 -*-      
from collections import Counter
import numpy as np
import sys

n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
b1 = [0 for i in range(n)]
b2 = [0 for i in range(n)]
b1[0] = a1[0]
b2[n-1] = a2[n-1]
for i in range(1,n):
    b1[i] = b1[i-1] + a1[i]
    b2[n-1-i] = b2[n-i] + a2[n-1-i]
ans = 0
for i in range(n):
    ans = max(ans,b1[i]+b2[i])
print(ans)
    

Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

bool prime_number(int x){
    if (x < 2) return false;
    else if (x == 2) return true;
    else if (x % 2 == 0) return false;
    
    double sqrtN = sqrt(x);
    for (int i = 3; i <= sqrtN; i += 2){
        if (x % i == 0) return false;
    }
    return true;
}

int main(){
    int N;
    cin >> N;
    int count = 0;
    int i = 1;
    while(count < N){
        if (prime_number(i) && (i % 5 == 2)){
            cout << i << " ";
            count++;
        }
        i++;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <limits>

using namespace std;
typedef long long ll;

int main(){
    ll n, m, p;
    cin >> n >> m >> p;

    vector<vector<pair<int, int>>> to(n);
    vector<vector<int>> from(n);
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        if(a == b && c - p <= 0){ continue; }
        to.at(a).push_back(make_pair(b, c - p));
        from.at(b).push_back(a);
    }

    vector<bool> can_goal(n, false);
    can_goal.at(n - 1) = true;
    unordered_set<int> pos[2];
    pos[0].insert(n - 1);
    for(int i = 0; i < n; ++i){
        const int j = i % 2;
        const int j2 = (i + 1) % 2;
        pos[j2].clear();
        for(int x : pos[j]){
            for(int next : from.at(x)){
                if(!can_goal.at(next)){
                    can_goal.at(next) = true;
                    pos[j2].insert(next);
                }
            }
        }
    }

    vector<ll> coins(n, numeric_limits<ll>::min());
    coins.at(0) = 0;
    pos[0].clear();
    pos[0].insert(0);
    for(int i = 0; i < n; ++i){
        const int j = i % 2;
        const int j2 = (i + 1) % 2;

        pos[j2].clear();
        for(int x : pos[j]){
            for(auto& p : to.at(x)){
                if(coins.at(p.first) < coins.at(x) + p.second
                   && can_goal.at(p.first)){
                    pos[j2].insert(p.first);
                    coins.at(p.first) = coins.at(x) + p.second;
                }
            }
        }
        if(i == n - 1 && pos[j2].size()){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << max(0LL, coins.at(n - 1)) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
    int a, b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='?'){
            break;
    	}else if(op=='+'){
    	    printf("%d\n", a+b);
    	}else if(op=='-'){
    	    printf("%d\n", a-b);
    	}else if(op=='*'){
    	    printf("%d\n", a*b);
    	}else if(op=='/'){
    	    printf("%d\n", a/b);
        }
    }
    return 0;
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
#include<bitset>
using namespace std;
#define M 1000000007
#define rep(i, a, b) for(int i=a; i<b; i++)

typedef long long ll;
typedef unsigned long long int llt;
const int N = 2e5 + 10;


int main()
{
    int ans = 0;
    int n;
    string s;
    cin>>n>>s;
    char curr = '0';
    rep(i, 0, n)
    {
        if(curr != s[i])
        {
            ans++;
            curr = s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

const ll mod=1e9+7;

const ll INF=1e10+100;


int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i,n){
        cin >> h[i];
    }
    ll le=0,ri=INF;
    while(ri-le>1){
        ll mid=(ri+le)/2;
        ll sum=0;
        rep(i,n){
            if(h[i]<=mid*b) continue;
            sum+=(h[i]-mid*b-1)/(a-b)+1;
        }
        if(sum<=mid) ri=mid;
        else le=mid;
    }
    cout << ri << endl;
    return 0;
} 

Measured memory_bytes: 4044
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////
int main(){
    ll n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int MAX = a[0];
    vector<int> dp(MAX+1);
    for (int i = 0;i < n;i++){
        dp[a[i]]++;
        for (int j = 2;a[i] * j <= MAX; j++){
            dp[a[i] * j]++;
        }   
    }

    int ans = 0;
    for (int i : a){
        if (dp[i] == 1) ans++;
    }

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

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

int main(){
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	int total = 0;
	for(int i=0; i<n; i++){
		std::cin >> a[i];
		total ^= a[i];		
	}

	for(int i=0; i<n; i++){
		printf("%d ", (total ^ a[i]));
	}
	std::cout << std::endl;

	return 0;
}

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

using namespace std;

const int MAX = 1000;

struct food{
  int num;
  int p;
  int q;
  int r;
  int cal;
};

food F[MAX];
food B;

int main(){
  int in;
  while(cin >> in && in){
    for(int i = 0; i < in; i++){
      cin >> F[i].num >> F[i].p >> F[i].q >> F[i].r;
      F[i].cal = (F[i].p+F[i].r)*4+F[i].q*9;
    }
    cin >> B.p >> B.q >> B.r >> B.cal;
    
    bool print = false;

    
    for(int i = 0; i < in; i++){
      if(F[i].p <= B.p && F[i].q <= B.q &&
	 F[i].r <= B.r && F[i].cal <= B.cal){
	print = true;
	cout << F[i].num << endl;
      }
    }
    if(!print) cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1180
N, K = map(int, input().split())
MOD = 10 ** 9 + 7


nk1Ci = [1]
k1Ci1 = [1]
temp1 = 1
temp2 = 1
for i in range(K):
    temp1 = temp1 * (N - K + 1 - i) // (i + 1)
    temp2 = temp2 * (K - 1 - i) // (i + 1)
    nk1Ci.append(temp1)
    k1Ci1.append(temp2)


for i in range(1, 1 + K):
    ans_i = nk1Ci[i] * k1Ci1[i - 1]
    ans_i %= MOD
    print(ans_i)


Measured memory_bytes: 3828
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	long long N;
	cin >> N;
	vector<long long>data(100);
	data[0] = 2;
	data[1] = 1;
	for (int i = 2; i < 100; i++) {
		data[i] = data[i - 1] + data[i - 2];
	}
	cout << data[N] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int arr[n];
    int cnt = 0;
    for(int i = 0;i < n;i++)cin >> arr[i];
    int k = 1;
    for(int i = 0;i < n;i++)
    {
        if(arr[i] == k)
            k++;
        else
        {
            arr[i] = -1;
            cnt++;
        }
    }
    if(cnt == n)cout << -1;
    else cout << cnt;
    return 0;
}


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

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

using namespace std;

int main() {
  while(1) {
    int n,k,s;
    cin>>n>>k>>s;
    if(!n)break;
    vector<vector<vector<int>>> dp(k+1, vector<vector<int>>(n+1, vector<int>(s+n+1)));
    dp[0][0][0] = 1;
    REP(i,k) {
      REP(j,n+1) {
        REP(l,s)
          for(int m=j+1;m<=n;++m)
            dp[i+1][m][l+m] += dp[i][j][l];
      }
    }
    int sum = 0;
    REP(i,n+1) sum += dp[k][i][s];
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1352
n=0
t_list=[]
try:
    n=int(input())
    t_list = [int(n) for n in input().split(' ')]
except:
  print('age,price must be numbers')
  sys.exit(1)

min_v = 10000
for i in range(n):
    diff = abs(sum(t_list[0:i]) - sum(t_list[i:n]))
    if min_v > diff:
        min_v = diff
print(min_v)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool isenable (double r0, double r ){

//	cout << "r0: " << r0 << " r: " << r << endl;
	
	if (r0 > 0. && r0 < r ){
		return true;
	} // end if

	return false;
}

bool estimate (double a, double b, double r )
{
//	cout << "a: " << a << " b: " << b << " r: " << r << endl;

	if (a/2. > 0. && a/2. < r && b/2. > 0. && b/2. < r ){
		if (isenable ( (a/2.)*(a/2.) + (b/2.)*(b/2. ), r*r ) ){
			return true;
		} // end if
	} // end if

	return false;
}
 
int main()
{
//	cut here before submit 
//	freopen("testcase.carrycheese", "r", stdin);
	string str = "";
	vector <double> s(3, 0.0 );
	int i;

	while (getline (cin, str ) ){
		stringstream sss(str);
	
		for (i = 0; i < 3; ++i){
			sss >> s[i];
		} // end for
		if (s[0] == 0. && s[1] == 0. && s[2] == 0. ) {
			break;
		} // end if

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

		int n;		
		getline (cin, str );
		stringstream ssn(str);
		ssn >> n;

		for (i = 0; i < n; ++i ){
			double r = 0.0;
			getline (cin, str );
			stringstream ssr(str);
			ssr >> r;

			if (estimate (s[0], s[1], r ) ){
				cout << "OK" << endl;
			}else{
				cout << "NA" << endl;
			} // end if
		} // end for
	} // end loop

//	cout << res << endl;	
		
	return 0;
}

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

using namespace std;

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

  vector <int> digit(N + 1);
  for(int i = 0; i < N + 1; i++) {
    digit[i] = 0;
  }

  
  for(int i = 1; i <= N; i++) {
    string s = to_string(i);
    for(int j = 0; j < s.length(); j++) {
      digit[i] += (int)s[j] - '0';
    }
  }

  int mn = N;
  for(int i = 1; i < N / 2; i++) {
    //    if(digit[i] + digit[N - i] < mn) {
    //      cout << digit[i] << ", " << digit[N - i] << endl;
    //    }
    mn = min(mn, digit[i] + digit[N - i]);
  }

  cout << mn << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int Ans=100000000;
int In[15][15];
int Now[15];
int main()
{
  int N,M,K;
  cin>>N>>M>>K;
  for(int i=0;i<N;i++)
    for(int j=0;j<=M;j++)
      cin>>In[i][j];
  for(int State=0;State<(1<<N);State++)
  {
    memset(Now,0,sizeof(Now));
    int Cnt=0;
    for(int i=0;i<N;i++)
      if((State>>i)&1)
      {
        Cnt+=In[i][0];
        for(int j=1;j<=M;j++)
          Now[j]+=In[i][j];
      }
    bool OK=true;
    for(int i=1;i<=M;i++)
      if(Now[i]<K)
      {
        OK=false;
        break;
      }
    if(OK)
      Ans=min(Ans,Cnt);
  }
  if(Ans==100000000)
  {
  	puts("-1");
  	return 0;
  }
  cout<<Ans<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <utility>
using namespace std;
 
int main() {
	int n, x, p, minx, sum = 0, ans = 0;
	cin >> n >> x;
	cin >> p;
	minx = p;
	sum += p;
	ans ++;
	for(int i = 0; i < n-1; i++){
		cin >> p;
		minx = min(p, minx);
		sum += p;
		ans ++;
	}
	ans += (x - sum) / minx;
	cout << ans;
}

Measured memory_bytes: 504
#include<stdio.h>
int main(void)
{
    int n,a,b,c;
    int cal[10000]={0};
    int i,j;
    int x,z;
    int rui=0,masa = 0;
 
    scanf("%d%d%d%d",&n,&a,&b,&c);
    for(i = 0;i < n; i++) scanf("%d",&cal[i]);
 
    for(i = 0;i < n; i++){
        for(j = 0;j < n; j++){
            if(cal[i] > cal[j]){
                x = cal[i];
                cal[i] = cal[j];
                cal[j] = x;
            }
        }
    }
    z = c;
    rui = c/a;
    for(i = 1;i <= n; i++){
        z += cal[i-1];
        masa = z / ((b*i)+a);
        if(rui <=masa){
        rui = masa;
        }
        else{
        break;
        }
    }
    printf("%d\n",rui);
    return 0;
}

Measured memory_bytes: 2792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 300005
using namespace std;
int n , m , a , b;
int C = ~(1<<31), M = (1<<16)-1;
int r() {
  a = 36969 * (a & M) + (a >> 16);
  b = 18000 * (b & M) + (b >> 16);
  return (C & ((a << 16) + b)) % 1000000;
}

struct Point {
    int x , y , z;
    bool operator < (const Point& R) const {
        return x < R.x;
    }
}p[N];
struct query {
    int x , y , z , id;
    query () {}
    query (int _x , int _y , int _z , int _id) {
        x = _x , y = _y , z = _z , id = _id;
    }
    bool operator < (const query& R) const {
        if (y != R.y) return y < R.y;
        if (id != R.id) return id > R.id;
        return z < R.z;
    }
}t[N];
int cnt , D , d[N];
int f[N] , c[N] , g[N];
void add(int* c , int x , int w) {
    for ( ; x <= D ; x += x & -x)
        c[x] = max(c[x] , w);
}
int get(int* c , int x) {
    int res = 0;
    for ( ; x > 0 ; x -= x & -x)
        res = max(res , c[x]);
    return res;
}
void clr(int* c , int x) {
    for ( ; x <= D ; x += x & -x)
        c[x] = 0;
}
void solve(int l , int r)
{
    if (l >= r) return;
    int mid = (l + r) >> 1 , tx = p[mid + 1].x;
    solve(l , mid);
    cnt = 0;
    for (int i = l ; i <= r ; ++ i)
        t[cnt ++] = query(p[i].x , p[i].y , p[i].z , i);
    sort(t , t + cnt);
    for (int i = 0 ; i < cnt ; ++ i)
        if (t[i].id <= mid) {
            add(c , t[i].z , f[t[i].id]);
            if (t[i].x != tx)
                add(g , t[i].z , f[t[i].id]);
        } else {
            if (t[i].x != tx)
                f[t[i].id] = max(f[t[i].id] , get(c , t[i].z - 1) + 1);
            else
                f[t[i].id] = max(f[t[i].id] , get(g , t[i].z - 1) + 1);
        }
    for (int i = 0 ; i < cnt ; ++ i)
        if (t[i].id <= mid)
            clr(c , t[i].z) , clr(g , t[i].z);
    solve(mid + 1 , r);
}

void work() {
    int i ; D = 0;
    for (i = 1 ; i <= m ; ++ i)
        scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].z);
    for (i = m + 1 ; i <= m + n ; ++ i)
        p[i].x = r() , p[i].y = r() , p[i].z = r();
    n += m , sort(p + 1 , p + 1 + n);
    for (i = 1 ; i <= n ; ++ i)
        f[i] = 1 , d[D ++] = p[i].z;
    sort(d , d + D) , D = unique(d , d + D) - d;
    for (i = 1 ; i <= n ; ++ i)
        p[i].z = lower_bound(d , d + D , p[i].z) - d + 1;
    solve(1 , n);
    int ans = 0;
    for (i = 1 ; i <= n ; ++ i)
        ans = max(ans , f[i]);
    printf("%d\n" , ans);
}

int main() {
    while (scanf("%d%d%d%d",&m,&n,&a,&b) , n || m || a || b)
        work();
    return 0;
}

Measured memory_bytes: 13944
/*input
3 3 4
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=4e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    vector<int> v(3);
    REP(i,3) cin>>v[i];
    SORT_UNIQUE(v);
    if(sz(v)==2){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
bool isPrime(int x)
{
   FOR(i, 2, (int)sqrt(x) )
   {
      if (x % i == 0)
         return false;
   }
   return true;
}
int main()
{
   int x;
   cin >> x;
   for (int i = x;; i++)
      if (isPrime(i))
      {
         cout << i << endl;
         break;
      }
   return 0;
}


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

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin>>s;
	int m = 1e9;
	for (int i=0; i+2<(int)s.size(); ++i){
		int x = (s[i]-48)*100 + (s[i+1]-48)*10 + (s[i+2]-48);
		m = min(m, abs(753 - x));
	}
	cout<<m;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
cnt_AC = 0
cnt_WA = 0
cnt_TLE = 0
cnt_RE = 0
for i in range(N):
  S = input()
  if S == 'AC':
    cnt_AC += 1
  elif S == 'WA':
    cnt_WA += 1
  elif S == 'TLE':
    cnt_TLE += 1
  else:
    cnt_RE += 1
print('AC x', cnt_AC)
print('WA x', cnt_WA)
print('TLE x', cnt_TLE)
print('RE x', cnt_RE)

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

N = int(input())
A = [int(t) for t in input().split()]
if len(A) != N: raise

def left_sum_cut(A):
    """左部分和と左部分列を均等に分ける位置を返す"""
    A = list(A)

    # 左部分列の和
    leftsum = [0] * len(A)
    leftsum[0] = A[0]
    for i in range(1, len(A)):
        leftsum[i] = leftsum[i-1] + A[i]

    # 左部分列を均等に分ける位置
    leftcut = [0] * len(A)
    leftcut[0] = None
    leftcut[1] = 0
    for i in range(2, len(A)):
        j = leftcut[i-1]
        m = float('inf')
        while j <= i - 1:
            suml = leftsum[j]
            sumr = leftsum[i] - suml
            if m <= abs(suml - sumr): break
            m = abs(suml - sumr)
            j += 1
        leftcut[i] = j - 1
    return leftsum, leftcut

leftsum,  leftcut  = left_sum_cut(A)
rightsum, rightcut = left_sum_cut(reversed(A))

# 中央の切断位置
m = float('inf')
for i in range(1, N - 2):
    P = leftsum[leftcut[i]]
    Q = leftsum[i] - P
    S = rightsum[rightcut[N - 1 - (i + 1)]]
    R = rightsum[N - 1 - (i + 1)] - S
    m = min(max(P, Q, R, S) - min(P, Q, R, S), m)
print(m)


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

int main(){
    string s;
    cin>>s;
    int a,z;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='A'){
            a=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--){
        if(s.at(i)=='Z'){
            z=i;
            break;
        }
    }
    cout<<z-a+1<<endl;
}

Measured memory_bytes: 640
n, q = map(int, input().split())
s = str(input())
ls = [list(map(int, input().split())) for i in range(q)]
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i:i + 2] == 'AC' else 0)
for i in range(q):
    l, r = ls[i][0], ls[i][1]
    ans = t[r - 1] - t[l - 1]
    print(ans)

Measured memory_bytes: 32216
def run(N, M, A, BC):
    # sort
    A.sort()
    # Aのカウント
    countA = {}
    for a in A:
        countA.setdefault(a, 0)
        countA[a] += 1
    # sort
    A = list(set(A))
    C = list(BC.keys())
    C.sort(reverse=True)
    A.sort(reverse=True)
    ai = 0
    ci = 0
    a = A[ai]
    c = C[ci]
    now_N = N
    ret = 0
    while now_N > 0:
        # Aが大きい場合はai+1しながら加算
        while c <= a:
            cnt = countA[a]
            if now_N > cnt:
                ret += a*cnt
                now_N -= cnt
                ai += 1
            else:
                ret += a*now_N
                now_N = 0
                break
            if ai < len(A):
                a = A[ai]
            else:
                a = 0
        # Cが大きい場合は加算して次のCへ
        while c >= a:
            b = BC[c]
            if now_N > b:
                ret += c*b
                now_N -= b
                ci += 1
            else:
                ret += c*now_N
                now_N = 0
                break
            if ci < len(C):
                c = C[ci]
            else:
                c = 0
    return ret


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = {}
    for _ in range(M):
        B, C = list(map(int, input().split()))
        BC.setdefault(C, 0)
        BC[C] += B
    print(run(N, M, A, BC))


if __name__ == '__main__':
    main()


Measured memory_bytes: 32460
main = do
    line <- getLine
    let n = words line
        a = read $ n !! 0
        b = read $ n !! 1
        c = read $ n !! 2
    putStrLn $ calc a b c

calc :: Int -> Int -> Int -> String
calc a b c
    | a < b && b < c = "Yes"
    | otherwise = "No"
    


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll c[100009], l[100009], r[100009], b[100009], sc[100009], sc1[100009];
main()
{
    ll n, X;

    cin >> n >> X;

    vector<pair<ll, ll>> v;
    long long s = 0, ms = 0;
    for (ll i = 1; i <= n; i++)
    {
        cin >> b[i] >> l[i] >> r[i];
        sc[i] = l[i] * b[i] + (X - b[i]) * r[i];
        s += l[i] * b[i];
        v.push_back({sc[i], i});
    }
    sort(v.rbegin(), v.rend());
    ll j = 0;
    while (j < v.size() && ms + v[j].first <= s)
        ms += v[j].first, j++;
    if (ms == s)
    {
        cout << j * X << endl;
        return 0;
    }
    ll ans = X + 1;
    ll lo = 0, hi = X;
    while (lo < hi)
    {
        ll mi = (lo + hi) / 2;
        ll S = -1e18;
        for (ll i = 0; i < n; i++)
        {
            ll k = v[i].second;
            if (mi <= b[k])
                sc1[k] = mi * l[k];
            else
                sc1[k] = b[k] * l[k] + (mi - b[k]) * r[k];
        }
        for (ll i = 0; i < j; i++)
            S = max(S, sc1[v[i].second] - sc[v[i].second]);
        bool fl = 0;
        for (ll i = j; i < v.size(); i++)
        {
            ll k = v[i].second;
            if (sc1[k] + ms >= s)
            {
                hi = mi;
                fl = 1;
                break;
            }
            if (sc[k] + S + ms >= s)
            {
                hi = mi;
                fl = 1;
                break;
            }
        }
        if (!fl)
            lo = mi + 1;
    }
    cout << lo + j * X << endl;
    //sum(r[i1]) * X
}


Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n;
    cin >> s;
    if (n % 2) {
        puts("No");
        return 0;
    } else {
        rep(i, n/2) {
            if (s[i] != s[n/2+i]) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, m;
    while(cin >> n >> m) {
        if (n == 1 || m == 1) {
            cout << 1 << endl;
            exit(0);
        }
        cout << (n * m + 1) / 2 << '\n';
    }

}


Measured memory_bytes: 256
using System;

namespace ABC087_C_Candies
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[,] candies = new int[2, n];
			int i, j;

			for (i = 0; i < 2; i++)
			{
				string[] input = Console.ReadLine().Split(' ');
				for (j = 0; j < n; j++)
				{
					candies[i, j] = int.Parse(input[j]);
				}
			}
			
			int candyCount = 0;
			
			/*iまでの上段のキャンディ+iからnまでの下段のキャンディを算出
			  今までの最大値より多かったら更新*/
			for (i = 0; i < n; i++)
			{
				int candyCountInLoop = 0;
				for (j = 0; j <= i; j++)
				{
					candyCountInLoop += candies[0, j];
				}

				for (j = i; j < n; j++)
				{
					candyCountInLoop += candies[1, j];
				}

				if (candyCountInLoop > candyCount)
				{
					candyCount = candyCountInLoop;
				}
			}
			
			Console.WriteLine(candyCount);
		}
	}
}

Measured memory_bytes: 11092
import java.awt.Frame;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.time.chrono.MinguoChronology;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {                
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int cnt = 0;

       for (int i = a; i < b+1; i++) {
         if (c % i == 0) cnt++;
       }
        out.println(cnt);
    }
  }

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

Measured memory_bytes: 24400
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int base = 1900*m + 100*(n-m);
		base <<= m;
		System.out.println(base);
	}
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;

int32_t main() {
	FAST_IO;
	
	int k;
	cin >> k;
	
	int ans = 0;
	for (int i = 1; i <= k; i++)
		for (int j = 1; j <= k; j++)
			for (int l = 1; l <= k; l++) {
				ans += __gcd(i, __gcd(j, l));
			}
	
	cout << ans << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined



Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,M,g=0;
  cin>>N>>M;
  vector<int> A(N);
  for(int &i:A){
    cin>>i;
    g+=i;
  }
  int ans=0;
  for(int &i:A)
    if(i*4*M>=g)
      ans++;
  cout<<(ans>=M?"Yes":"No")<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];
int num[100010];
set<int> U;

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		num[A[i]-1]++;
		U.insert(A[i]);
	}
	int R=0,M=0;
	int ans=0;
	REP(i,100000){
		if(num[i]%2==1){
			R++;
		}
		else if(num[i]%2==0&&num[i]>0){
			M++;
		}
	}
	if(M%2==0){
		R+=M;
		M=0;
		ans=R;
	}
	else{
		R+=M-1;
		M=1;
		ans=R;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int ans;
    if (n % x == 0) {
        ans = (n / x) * t;
    } else {
        ans = ((n / x) + 1) * t;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 10000000000LL
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(ll*)a>*(ll*)b?1:-1;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int main(void)
{
	ll s[3],w,h,i;
	ll res=INF;
	scanf("%lld%lld",&h,&w);
	FOR(i,1,h){
		s[0]=i*w;
		s[1]=MAX((h-i)/2*w,(h-i)*(w/2));
		s[2]=h*w-s[0]-s[1];
		qsort(s,3,sizeof(ll),comp);
		res=MIN(res,s[2]-s[0]);
	}
	swap(ll,h,w);
	FOR(i,1,h){
		s[0]=i*w;
		s[1]=MAX((h-i)/2*w,(h-i)*(w/2));
		s[2]=h*w-s[0]-s[1];
		qsort(s,3,sizeof(ll),comp);
		res=MIN(res,s[2]-s[0]);
	}
	printf("%lld",res);
	return 0;
}
    

Measured memory_bytes: 128
n = int(input())
l = list(map(int, input().split()))

def ok(a, b, c):
    return a < b + c and a > abs(b - c) and a != b and b != c and c != a

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if ok(l[i], l[j], l[k]):
                ans += 1

print(ans)

Measured memory_bytes: 68724
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  ans = 2000
  D, G = map(int, input().split())
  P = [0]*D
  C = [0]*D
  for i in range(D):
    P[i],C[i] = map(int, input().split())
  for p in product([0,1],repeat=D):
    if sum(p)<D:
      for i in range(D-1,-1,-1):
        if p[i]==0:
          maxi = i
          break
    cnt = 0
    score = 0
    for i in range(D):
      if p[i]==1:
        score += (i+1)*100*P[i]+C[i]
        cnt += P[i]  
    if -(-(G-score)//(100*(maxi+1)))>=P[maxi]:
      continue
    if G>score:
      cnt += -(-(G-score)//(100*(maxi+1)))
    ans = min(ans,cnt)
  return ans
print(solve())

Measured memory_bytes: 9176
while True:
    N,M,P=map(int,raw_input().split())
    if N==M==P==0:break
    s,b=0,-1
    for i in range(1,N+1):
        x=input()
        s+=x
        if i==M:
            b=x
    print int(s*100*(100-P)/(100.0*b)) if b!=0 else 0

Measured memory_bytes: 4252
if __name__ == '__main__':
	S = input()
	S = [s.split()[0] for s in S]
	ans = []
	for i in range(0,len(S)):
		if S[i] == 'B' and len(ans)>0:
			ans.pop()
		elif S[i] != 'B':
			ans.append(S[i])

	ans = ''.join(ans)
	print(ans)

Measured memory_bytes: 3060