akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let n: usize = read();
    if n % digit_sum(n) == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn digit_sum(x: usize) -> usize {
    let mut sum = 0;
    let mut x = x;
    while x >= 1 {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
  unsigned long x, y, xx, yy, w, gcd, lcm;

  while(scanf("%lu %lu", &x, &y) != EOF){
    xx = x;
    yy = y;

    if(x < y){
      w = x;
      x = y;
      y = w;
    }

    while(y != 0){
      w = x % y;
      x = y;
      y = w;
    }
    gcd = x;

    xx = xx / gcd;
    lcm = xx * yy;

    printf("%lu %lu\n", gcd, lcm);
  }

  return(0);
}

Measured memory_bytes: 604
H,W = gets.split.map(&:to_i)

H_div, H_mod = H.divmod(2)
W_div, W_mod = W.divmod(2)

ans = 0

if H == 1
  puts 1
  exit
end

if W == 1
  puts 1
  exit
end

if H_mod == 0
  ans += H_div * W
else
  if W % 2 != 0
    ans += (H_div + 1) * (W / 2 + 1) + (H_div) * (W / 2)
  else
    ans += (H_div + 1) * (W / 2) + (H_div) * (W / 2)
  end
end

puts ans

Measured memory_bytes: 1788
// codeforces.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>
using namespace std;
using ll =long long int;
constexpr ll mod = 1e12;
int main()
{
	ll x, k; cin >> x >> k; ll ans = 0;
	for (int i = 0; i < k; ++i) {
		ll val; cin >> val; ans += val;
	}
	if (ans >= x)puts("Yes"); else puts("No");
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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


int main()
{
	int n;
	cin >> n;
	int a[n],b[n];
	for (int i = 0; i < n-1; ++i)
	{
		cin >> b[i];
	}
	a[0] = b[0];
	for (int i = 0; i < n-1; ++i)
	{
		if((i+1 != n-1) && b[i] > b[i+1])
			a[i+1] = b[i+1];
		else
			a[i+1] = b[i];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    int N, a, b;
    ll A, B, n;
    A = 1;
    B = 1;
    cin >> N;
    rep(i, N)
    {
        cin >> a >> b;
        n = max(ll((A + a - 1) / a), ll((B + b - 1) / b));
        A = n * a;
        B = n * b;
    }
    cout << A + B << endl;
    return 0;
}


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

int main() {
	long long N, K;
	cin >> N >> K;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < K; i++) {
		vector<int> Imos(N + 1, 0);
		for (int j = 0; j < N; j++) {
			int L, R;
			L = max(0LL, j - A[j]), R = min(N - 1, j + A[j]);
			Imos[L]++, Imos[R + 1]--;
		}
		for (int i = 0; i < N; i++) Imos[i + 1] += Imos[i];
		bool check = true;
		for (int i = 0; i < N; i++) {
			A[i] = Imos[i];
			if (A[i] != N) check = false;
		}
		if (check) break;
	}
	for (int i = 0; i < N; i++) cout << A[i] << (i == N - 1 ? '\n' : ' ');
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  
  int A,B,count,co;
  cin >> A >> B;
  co = 1;
  while( co < B ){
    co += A-1;
    count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  long long int money = 1000;
  for(long long int i = 0; i < n-1; i++){
    long long int stock = 0;
    if(a[i] < a[i+1]){
      stock = money/a[i];
    }
    money += (a[i+1]-a[i])*stock;
  }
  cout << money << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

struct Q {
  int l, r, id;
};

bool lessL(const Q &q1, const Q &q2) {
  return q1.l < q2.l;
};

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

  int N;
  cin >> N;
  vector<Q> q(N);

  int max_l = 0;
  int min_r = 1e9+7;
  int max_len = 0;
  rep(i, 0, N) {
    cin >> q[i].l >> q[i].r;
    q[i].r++;
    q[i].id = i;

    if (q[i].l > max_l) {
      max_l = q[i].l;
    }

    if (q[i].r < min_r) {
      min_r = q[i].r;
    }

    max_len = max(q[i].r - q[i].l, max_len);
  }

  int ans = max_len + max(0, min_r - max_l);

  int ans_min_r = 2e9+7;
  int ans_max_l = 2e9+7;

  vector<PI> a(N);
  rep(i, 0, N) {
    a[i].first = max(q[i].r - max_l, 0);
    a[i].second = max(min_r - q[i].l, 0);
  }

  sort(All(a));

  int mn = a[0].second;
  rep(i, 1, N) {
    ans = max(ans, mn + a[i].first);
    mn = min(mn, a[i].second);
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 2176
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n #各要素の親要素の番号を格納するリスト

    def find(self, x): #要素xが属するグループの根を返す
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y): #要素xが属するグループと要素yが属するグループとを併合する
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return

        if self.parents[x]>self.parents[y]:
            x,y=y,x

        self.parents[x]+=self.parents[y]
        self.parents[y]=x

    def size(self,x): #要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self,x,y): #要素x, yが同じグループに属するかどうかを返す
        return self.find(x)==self.find(y)

    def members(self,x): #要素xが属するグループに属する要素をリストで返す
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]

    def roots(self): #すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x<0]

    def group_count(self): #グループの数を返す
        return len(self.roots())

    def all_group_members(self): #{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

#print(list(uf.all_group_members().values())) #グループ一覧を表示

n,m,k=map(int,input().split())

uf=UnionFind(n)
cnt=[0]*n

for _ in range(m):
    x,y=map(int,input().split())
    uf.union(x-1,y-1)
    cnt[x-1]+=1
    cnt[y-1]+=1
for _ in range(k):
    x,y=map(int,input().split())
    if uf.same(x-1,y-1):
        cnt[x-1]+=1
        cnt[y-1]+=1
    
for i in range(n):
    print(uf.size(i)-cnt[i]-1,end=" ")

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

int grid[255][255];

int main() {
    int n;
    while (cin >> n, n) {
        char c;
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                cin >> c;
                grid[i][j] = c - '0';
            }
        }
        int x, y, cnt, res = 0;
        for (int i=0; i<n; ++i) {
            // right
            cnt = 0, y = i, x = 0;
            while (x < n) {
                cnt = (grid[y][x] ? cnt+1 : 0);
                res = max(res, cnt);
                ++ x;
            }
            // down
            cnt = 0, y = 0, x = i;
            while (y < n) {
                cnt = (grid[y][x] ? cnt+1 : 0);
                res = max(res, cnt);
                ++ y;
            }
            // right down
            cnt = 0, y = i, x = 0;
            while (y < n && x < n) {
                cnt = (grid[y][x] ? cnt+1 : 0);
                res = max(res, cnt);
                ++ y, ++ x;
            }
            cnt = 0, y = 0, x = i;
            while (y < n && x < n) {
                cnt = (grid[y][x] ? cnt+1 : 0);
                res = max(res, cnt);
                ++ y, ++ x;
            }
            // left down
            cnt = 0, y = i, x = n-1;
            while (y < n && 0 <= x) {
                cnt = (grid[y][x] ? cnt+1 : 0);
                res = max(res, cnt);
                ++ y, -- x;
            }
            cnt = 0, y = 0, x = i;
            while (y < n && 0 <= x) {
                cnt = (grid[y][x] ? cnt+1 : 0);
                res = max(res, cnt);
                ++ y, -- x;
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1412
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int m1,m2,d2,d1;
    cin >> m1 >> m2 >> d1 >> d2;
    if (m1!=m2){
        if (d2==1){
            cout << 1;
            rn 0;
        }
    }
    cout << 0;
    rn 0;
}



int main1(){
    double n,x;
    cin >> n;
    x = n/1.08;
    printf ("%.10f",x);
    rn 0;
}


Measured memory_bytes: 888
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; index++)
#define RFOR(index, start, end) for(int index = start; index > end; index--)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;
ll v[51];
double factorial[51];
int main(void)
{
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	FOR(i, 0, n)
	{
		scanf("%lld", &v[i]);
	}
	sort(v, v + n);
	ll sum = 0;
	ll minV = v[n - a];
	int minCount = 0;
	int minNeeded = 0;
	FOR(i, n - a, n)
	{
		sum += v[i];
		if (v[i] == minV)
		{
			minNeeded++;
		}
	}
	FOR(i, 0, n)
	{
		if (v[i] == minV)
		{
			minCount++;
		}
	}
	factorial[0] = 1;
	FOR(i, 1, n + 1)
	{
		factorial[i] = factorial[i - 1] * i;
	}
	ll ways = 0;
	if (minV != v[n - 1])
	{
		ways += round((double)1 / factorial[minNeeded] / factorial[minCount - minNeeded] * factorial[minCount]);
	}
	else
	{
		for (int i = minNeeded; i <= min(minCount, minNeeded + b - a); i++)
		{
			ways += round((double)1 / factorial[i] / factorial[minCount - i] * factorial[minCount]);
		}
	}
	printf("%.9f\n", (double)sum / a);
	cout << ways << endl;
}

Measured memory_bytes: 256
s = list(input())
n = len(s)
ans = 0
for i in range(2**(n-1)):
    f = s[0]
    for j in range(n-1):
        if (1&i>>j) == 1:
            f += "+"
        f += s[j+1]
    ans += eval(f)
print(ans)


Measured memory_bytes: 2940
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 100000000000 //10^9:∞
#define MOD 1000000 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll h,w;cin>>h>>w;
    //終点,始点を管理
    set<ll> tofrom;
    //最小を管理
    multiset<ll> cost;
    REP(i,w){
        tofrom.insert(i*MOD+i);
        cost.insert(0);
    }
    //cout<<1<<endl;
    REP(i,h){
        //cout<<SIZE(cost)<<endl;
        //cout<<SIZE(tofrom)<<endl;
        ll a,b;cin>>a>>b;a--;b--;
        //cout<<1<<endl;
        auto j=tofrom.lower_bound(a*MOD);
        ll ne=-1;
        while(j!=tofrom.end()){
            if(*j>=(b+2)*MOD)break;
            cost.erase(cost.lower_bound(ll(*j/MOD)-*j%MOD));
            ne=max((*j)%MOD,ne);
            //cout<<ne<<endl;
            j=tofrom.erase(j);
        }
        if(ne==-1){
            //cout<<1<<endl;
        }else if(b==w-1){
            cost.insert(INF);
        }else{
            cost.insert(b+1-ne);
            tofrom.insert((b+1)*MOD+ne);
        }
        if(*cost.begin()!=INF)cout<<*cost.begin()+i+1<<"\n";
        else cout<<-1<<"\n";
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int count = 0;
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }

    for(int i = 0; i < n; i++){
        while(a.at(i) % 2 == 0){
            a.at(i) /= 2;
            count++;
        }
    }   
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n, l;
  cin >> n >> l;

  ll arr[n + 5];

  ll sum1 = 0;
  for (ll i = 1; i <= n; i++) {
    arr[i] = l + i - 1;
    sum1 += arr[i];
  }

  ll min1 = inf;
  ll res;
  for (ll i = 1; i <= n; i++) {
    ll curr = sum1 - arr[i];
    if (abs(curr - sum1) < min1) {
      min1 = abs(curr - sum1);
      res = curr;
    }
  }

  cout << res << en;

  return 0;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};

ll A, B;

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll N, K;

int main() {

    cin >> N;
    if(N==0){
        cout << 0 <<endl;
        return 0;
    }
    vector<int> a;
    while (N != 0) {
        if (N % -2 == 1) {
            a.push_back(1);
            N /= -2;
        } else if (N % -2 == -1) {
            a.push_back(1);
            N /= -2;
            N++;
        } else {
            a.push_back(0);
            N /= -2;
        }

    }
    reverse(a.begin(), a.end());
    REP(i, a.size()) cout << a[i];
    cout << endl;
    return 0;

}



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

#define int             long long
#define ip(x)           int x; cin>>x;
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define mod             pow(10,9)+7
#define inf             1e18
#define endl			"\n"
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	c_p_c();
	int t;
	int temp;
	for (int j = 1; j < 6; j++) {
		cin >> temp;
		if (temp == 0)
			cout << j << endl;
	}
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int a[100000],b[100000]={0};
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i],b[a[i]-1]=i+1;
	for(int i=0;i<n;i++)cout<<b[i]<<' ';
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    int a, b;
    cin >> a >> b;
    rep(i, 1001){
        int aa = i*0.08;
        int bb = i*0.1;
        if (aa == a and bb == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3540
/****************************************************************************************************
                                        SUBMITTED BY-

                                            AISH_07

****************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define sl set<ll>
#define vs vector<string>
#define pb push_back
#define vl vector<ll>
#define vi vector<int>
#define PI  3.14159265
#define mod 998244353
int main()
{
    int n;
    cin>>n;

    int prev;
    int a[n];
    ll k;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        if(i==0)
            a[i]=-1;
        else
        {
            if(prev>=k)
                a[i]=1;
            else
                a[i]=-1;
        }
        prev=k;
    }
    int maxsum=0,sum=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==1)
           sum+=a[i];
        else
            sum=0;
        maxsum=max(sum,maxsum);
    }
    cout<<maxsum<<"\n";
   return 0;
}


Measured memory_bytes: 3992
#include<stdio.h> 
#define INFTY 1000000000

int cnt;


void merge(int A[],int left,int mid,int right){
	int n1=mid-left;		//左側の要素数
	int n2=right-mid;		//右側の要素数
	
	int L[n1],R[n2];
	
	int i,j,k;
	for(i=0;i<n1;i++){		//左半分の要素代入
		L[i]=A[left+i];
	}
	for(i=0;i<n2;i++){		//右半分の要素代入
		R[i]=A[mid+i];
	}
	L[n1]=INFTY;
	R[n2]=INFTY;
	i=0;
	j=0;
	for(k=left;k<right;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}
		else{
			A[k]=R[j];
			j++;
		}
	}
}


void mergeSort(int A[],int left,int right){
	int mid;
	if(right-left>1){	//両端の交差の有無で判断
		mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}


int main(void){
	int n;
	scanf("%d",&n);
	int i;
	int A[500000];
	cnt=0;
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	mergeSort(A,0,n);
	
	for(i=0;i<n;i++){
		if(i!=0){printf(" ");}
		printf("%d",A[i]);
	}
	
	printf("\n%d\n",cnt);
}
		
		
			


Measured memory_bytes: 5624
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int H, N; std::cin >> H >> N;
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    int A; std::cin >> A;
    sum += A;
  }
  if (H > sum) std::cout << "No" << std::endl;
  else         std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n; cin >> n;
	int ans = 10000, sum = 0;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		sum += a;
		ans = min(ans, sum / i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
//#define int long long  
signed main(){
    int N;
    int X[214514];
    int Y[214514];
    cin >> N;
    REP(i,N){cin >> X[i];Y[i]=X[i];}
    sort(X,X+N);
    REP(i,N){
        if(Y[i]<=X[N/2 -1]){
            cout << X[N/2] << endl;
        }else{
            cout << X[N/2 -1] << endl;
        }
    }
    
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.


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

double prob[N+1];

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

double dp[N+1][N+1];

for (int i = 0; i < N+1; ++i)
{
	for (int j = 0; j < N+1; ++j)
	{
		dp[i][j] = 0;
	}
}
dp[1][0] = 1.0 - prob[1];
dp[1][1] = prob[1];

for (int i = 2; i <= N; ++i)
{	
	dp[i][0] = dp[i-1][0] * (1.0-prob[i]);
	for (int j = 1; j <= i; ++j)
	{
		dp[i][j] = dp[i-1][j] * (1.0-prob[i]) + dp[i-1][j-1] * prob[i]; 
	}
}

int k = (N+1)/2;
double ans = 0;
for (int i = k; i <=N; ++i)
{
	ans = ans + dp[N][i];
}

cout<<setprecision(12)<<ans<<endl;

return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }

    auto previous = a[0];
    ll ans = 0;
    // vector<long long> step(n, 0);
    for(ll i = 1; i < n; i++){
        auto present = a[i];
        ll step = 0;
        if(present < previous){
            // step[i] = previous - present;
            step = previous - present;
            // ans += previous - present;
            ans += step;
        }
        a[i] += step;
        previous = a[i];
        // cout << step << endl;
    }

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


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

int main(){
    int n;
    vector<int> V(25), C(25);

    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> V[i];
    }
    for (int i = 0; i < n; i++){
        cin >> C[i];
    }
    int tmp, total=0;
    for (int i = 0; i < n; i++){
        tmp = (V[i] - C[i]);
        if (tmp >= 0){
            total += tmp;
        }
    }
    cout << total;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
x = [int(input()) for _ in range(n)]
f = 0

if x[0]>0: f = 1
for i in range(n-1):
    if x[i]+1 < x[i+1]: f = 1
import sys
if f:
    print(-1)
    sys.exit()
ans = 0
for i in range(n-1):
    if x[i+1] == x[i]+1:
        ans += 1
    else:
        ans += x[i+1]
print(ans)

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

int main()
{
    int m1;
    int d1;
    int m2;
    int d2;
    cin >> m1 >> d1 >> m2 >> d2;

    int ans = 0;
    if (m1 != m2)
    {
        ans = 1;
    }
    cout <<  ans << endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c,d = map(int,input().split())

taka = (int(c/b)) + (1 if c%b != 0 else 0)
aoki = (int(a/d)) + (1 if a%d != 0 else 0)

if taka <= aoki:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9180
from collections import deque
n = int(input())
a = [int(i) for i in input().split()]
b = deque()
f = True
for i in range(n):
    if f: b.append(a[i])
    else: b.appendleft(a[i])
    f = not f
if i % 2 == 0: b.reverse()
print(*b)

Measured memory_bytes: 25412
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<ll,ll>ma;
int main()
{
    ll n,m,a,ans=0,sum=0;
    scanf("%lld%lld",&n,&m);
    ma[0]=1;
    for(ll i=0; i<n; i++)
    {
        scanf("%lld",&a);
        sum=(sum+a)%m;
        ans+=ma[sum]++;
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)
 
int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a,x=0;
	cin>>a;
	int b[a];
	forr(i,0,a)
		cin>>b[i], x^=b[i];
	forr(i,0,a)
	{
		cout<<(x^b[i])<<' ';
	}	
	
	return 0; 	
}

Measured memory_bytes: 4404
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

#include <cstdlib>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int N;
int X[15], Y[15], P[15];

const llong INF = 1e18;

inline int nearest_dist(int k, int V[], int pos) {
   int dist = 2000000001;
   /*
   int j = lower_bound(V, V+k, pos) - V;
   if (j < k)
      dist = min(dist, V[j]-pos);
   if (j > 0)
      dist = min(dist, pos-V[j-1]);
   */
   
   for (int i = 0; i < k; ++i) {
      int d = abs(pos - V[i]);
      if (dist > d)
         dist = d;
   }
   
   return dist;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N;
   REP(i, N)
      cin >> X[i] >> Y[i] >> P[i];

   /*
   srand(123);
   for (int i = N-1; i > 0; --i) {
      int j = rand() % (i+1);
      if (i != j) {
         swap(X[i], X[j]);
         swap(Y[i], Y[j]);
         swap(P[i], P[j]);
      }
   }
   */

   llong ans[16];
   FOR(k, 0, N)
      ans[k] = INF;

   int Vx[16], Vy[16];

   REP(sel_mask, 1<<N) {
      for (int dir_mask = sel_mask; ; dir_mask = (dir_mask - 1) & sel_mask) {
         int kx = 1, ky = 1;
         Vx[0] = 0, Vy[0] = 0;

         REP(i, N) {
            if (!(sel_mask & (1<<i))) continue;
            if (dir_mask & (1<<i))
               Vx[kx++] = X[i];
            else
               Vy[ky++] = Y[i];
         }

      // sort(Vx, Vx+kx);
      // sort(Vy, Vy+ky);

         int k = (kx-1) + (ky-1);
         llong cost = 0;
         REP(i, N) {
            if (sel_mask & (1<<i)) continue;
            int distx = nearest_dist(kx, Vx, X[i]);
            int disty = nearest_dist(ky, Vy, Y[i]);
            cost += min(distx, disty) * 1LL * P[i];
            if (ans[k] <= cost)
               break;
         }
         if (ans[k] > cost) {
            ans[k] = cost;
            FOR(kk, k, N) {
               if (ans[kk] <= ans[k])
                  break;
               ans[kk] = ans[k];
            }
         }

         if (dir_mask == 0) break;
      }
      
   }

   FOR(k, 0, N)
      cout << ans[k] << '\n';

   return 0;
}


Measured memory_bytes: 3692
# 入力を受け取る
N = int(input())
A = int(input())

# 必要な500円玉の枚数を求める
num_500 = int(N / 500)

# ぴったりN円払うのに必要な1円玉の枚数を求める
nec_1 = N - (500 * num_500)

# ぴったり払えるか判定する
if nec_1 <= A:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const double EPS = 1e-8;

int n;
map<int,int>tu;
LL ans,a[maxn];


int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%lld", &a[i]);
		ans += tu[i - a[i]];
		tu[a[i] + i]++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 22244
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 109
using namespace std;
//priority_queue
const ll Maxn=1e5;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
bool cmp(double x,double y)
{
    return x>y;
}

int main()
{ ios::sync_with_stdio(false);

 int t;
 cin>>t;
 int sum=0;
 int a[30];
 for(int i=1;i<=t;i++)
    cin>>a[i];
  for(int i=2;i<t;i++)
    if(a[i-1]>a[i]&&a[i]>a[i+1]||a[i-1]<a[i]&&a[i]<a[i+1])
  {
      sum++;
  }
  cout<<sum;
}


Measured memory_bytes: 256
function hms(x){
   var S=x%60;
   var M=(x%3600-S)/60;
   var H=(x-(M*60)-S)/3600;
   if(S<10)S="0"+S;
   if(M<10)M="0"+M;
   if(H<10)H="0"+H;
   return [H,M,S].join(":");
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i++){
   var arr=Arr[i].split(" ").map(Number);
   var h=arr[0];
   var m=arr[1];
   var s=arr[2];
   if(h==-1 && m==-1 && s==-1)break;
   var time=(7200)-(h*3600)-(m*60)-s;
   console.log(hms(time));
   console.log(hms(time*3));
}

Measured memory_bytes: 7644
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int q;
    cin >> q;
    vi d(q), a(q), b(q);
    for (int i = 0; i < q; ++i) {
        cin >> d[i];
        if (d[i] == 1) {
            cin >> a[i] >> b[i];
        }
    }
    priority_queue<ll> pql;
    priority_queue<ll, vi, greater<ll>> pqr;
    ll suml = 0, sumr = 0;
    ll sumb = 0;
    for (ll i = 0; i < q; ++i) {
        if (d[i] == 1) {
            sumb += b[i];
            if (pql.size() == 0 || pql.top() >= a[i]) {
                pql.push(a[i]);
                suml += a[i];
            } else {
                pqr.push(a[i]);
                sumr += a[i];
            }
            if (pql.size() > pqr.size() + 1) {
                ll l = pql.top();
                pql.pop();
                pqr.push(l);
                suml -= l;
                sumr += l;
            }
            if (pql.size() < pqr.size()) {
                ll r = pqr.top();
                pqr.pop();
                pql.push(r);
                suml += r;
                sumr -= r;
            }
        } else {
            ll a = pql.top();
            cout << a << " ";
            ll left  = a * pql.size() - suml;
            ll right = sumr - a * pqr.size();
            cout << sumb + left + right << "\n";
        }
    }
    return 0;
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
//#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"
#define fi first
#define se second

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    ll n;
    cin >> n;
    cout << pow(n, 3) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <list>
#include <stdio.h>
#include <string>
using namespace std;
int main(){
    int n,x;
    string s;
    list<int> L;
    list<int>::iterator  m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="insert"){
            cin>>x;
            L.push_front(x);
        }
        else if(s=="delete"){
            cin>>x;
            for(m=L.begin();m!=L.end();m++){
                if(*m==x){
                    L.erase(m);
                    break;
                }
            }
        }
        else if(s=="deleteFirst"){
            L.pop_front();
        }
        else{
            L.pop_back();
        }
    }
    int a=L.size();
    for(int i=0;i<a;i++){
        if(i==a-1){
            cout<<L.front();
        }
        else{
            cout<<L.front()<<" ";
            L.pop_front();
        }
    }
    cout<<endl;
    return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W; cin >> H >> W;
    string grid[H]; rep(i, H) cin >> grid[i];
    set<int> row, col;
    rep(i, H){
        bool ok = true;
        rep(j, W) if(grid[i][j] == '#') ok = false;
        if(ok) row.insert(i);
    }
    rep(j, W){
        bool ok = true;
        rep(i, H) if(grid[i][j] == '#') ok = false;
        if(ok) col.insert(j);
    }
    rep(i, H){
        if(row.count(i)) continue;
        rep(j, W){
            if(col.count(j)) continue;
            cout << grid[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int all[300000][2] = {};
int cmpint(const void* a, const void* b) {
	return *(int*)b - *(int*)a;
}
int main() {
	int x, y, a, b, c;
	long long sum = 0;
	scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
	for (int i = 0; i < a; i++) {
		scanf("%d", &all[i][0]);
		all[i][1] = 1;
	}
	for (int i = 0; i < b; i++) {
		scanf("%d", &all[i + a][0]);
		all[i+a][1] = 2;
	}
	for (int i = 0; i < c; i++) {
		scanf("%d", &all[i + a + b][0]);
		all[i + a + b][1] = 3;
	}
	qsort(all, a+b+c, sizeof(all[0]), cmpint);
	int eat = 0;
	int maxeat = x + y;
	for (int i = 0;; i++) {
		if (all[i][1] == 1) {
			if (x > 0) {
				x--;
				eat++;
				sum += all[i][0];
			}
		}else if (all[i][1] == 2) {
			if (y > 0) {
				y--;
				eat++;
				sum += all[i][0];
			}
		} else {
			eat++;
			sum += all[i][0];
		}
		if (eat == maxeat) {
			break;
		}
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 4860
import sys

ct=1
def count(Map, w,h,i, j):
    global ct
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    for k in range(4):
        ix=i+dy[k]
        jx=j+dx[k]
        if (0<=ix<h and 0<=jx<w and Map[ix][jx]=='.'):
            Map[ix][jx]='#'
            ct+=1
            count(Map,w,h,ix,jx)

while(True):
    input = map(int, sys.stdin.readline().replace('\n','').split(' '))
    w,h=input
    if(w==0 and h==0):break
    Map=[]
    for i in range(h):
        s=raw_input()
        Map.append(list(s))
        
    flag=False
    for i in range(h):
        for j in range(w):
            if (Map[i][j]=='@'):
                flag=True
                Map[i][j]='#'
                break
        if flag:break

    ct=1
    count(Map,w,h,i,j)
    print ct

Measured memory_bytes: 6740
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x = INT()

if x % 11 == 0:
    tmp = 2 * x // 11

else:
    if 6 < x % 11:
        tmp = 2 + 2 * (x // 11)
    else:
        tmp = 1 + 2 * (x // 11)
print(tmp)

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

int main(){
  int n, m; cin >> n >> m;
  //int c; cin >> c;
  vector<pair <long long int, long long int> > ab(n);
  
  for(int i = 0; i < n; i++){
    int a, b; cin >> a >> b;
    ab.at(i) = make_pair(a, b);
  }
  
  sort(ab.begin(), ab.end());
  
  long long int ans = 0;
  int now_bin = 0;
  
  for(int i = 0; i < n; i++){
    now_bin += ab.at(i).second;
    ans += ab.at(i).first * ab.at(i).second;
    if (now_bin >= m) {
      ans -= ab.at(i).first * (now_bin - m);
      break;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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; }
//-------------------

int main(){
	int n,k; cin >> n >> k;
	if(k==1) cout << 0 << endl;
	else cout << n-k+1-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	long long a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	if(a%2==0 || b%2==0 || c%2==0)
		printf("0\n");
	else
		printf("%lld\n", min(a*b, min(b*c, a*c)));
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
pair<int,int> Edges[100005];
int Array[100005] , Count[100005];
long long Final[100005];

int Find( int u ){
    if( Array[u] == 0 ) return u;
    else return Array[u] = Find( Array[u] );
}

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

    for( i = 1 ; i <= m ; ++i )
        scanf( "%d%d" , &Edges[i].first , &Edges[i].second );

    fill( Array , Array + N + 1 , 0 );
    fill( Count , Count + N + 1 , 1 );
    long long Ans = ( ( N - 1 ) * 1LL * N ) / 2LL;
    Final[m] = Ans;
    int u , v , x , y , a , b;

    for( i = m ; i > 1 ; --i ){
        u = Edges[i].first;
        v = Edges[i].second;
        x = Find( u );
        y = Find( v );

        if( x != y ){
            a = Count[x];
            b = Count[y];
            Array[x] = y;
            Count[y] = a + b;
            Ans = Ans - ( a * 1LL * b ); 
        }

        Final[i - 1] = Ans;
    }

    for( i = 1 ; i <= m ; ++i )
        printf( "%lld\n" , Final[i] );
    return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

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

		while(true) {
			long[] a=new long[6];
			long[] ichi=new long[3];
			for(int i=0; i<6; i++) {
				a[i]=sc.nextLong();
			}
			int sum=1;
			for(int i=0; i<6; i++) {
				sum*=a[i];
			}
			if(sum==0) {
				System.exit(0);
			}
			else {
				long[] x=new long[(int)a[1]+1];
				long[] y=new long[(int)a[3]+1];
				long[] z=new long[(int)a[5]+1];

				x[0]=0;
				y[0]=0;
				z[0]=0;
				x[1]=a[0]%a[1];
				y[1]=a[2]%a[3];
				z[1]=a[4]%a[5];


				for(int i=2; i<=a[1]; i++) {
					x[i]=(x[i-1]*a[0])%a[1];
					if(x[i]==1) {
						ichi[0]=i;
						break;
					}
				}

				for(int i=2; i<=a[3]; i++) {
					y[i]=(y[i-1]*a[2])%a[3];
					if(y[i]==1) {
						ichi[1]=i;
						break;
					}
				}

				for(int i=2; i<=a[5]; i++) {
					z[i]=(z[i-1]*a[4])%a[5];
					if(z[i]==1) {
						ichi[2]=i;
						break;
					}
				}
			}
			long ans=1L;

			//System.out.println(ichi[0]+" "+ichi[1]+" "+ichi[2]);

			ans=lcm((long)ichi[0],(long)ichi[1]);
			ans=lcm(ans,(long)ichi[2]);

			System.out.println(ans);
		}
	}

	public static long lcm(long m, long n) {
		return m / gcd(m, n)*n;
	}
	public static long gcd(long m, long n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
		return gcd(n, m % n);
	}
}



Measured memory_bytes: 52376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll h, n, k, d;
  in2(h, n);
  vector<ll> a(n), b(n), c(h + 1, 1000000000);
  rep(i, n)
    in2(a[i], b[i]);
  c[0] = 0;
  rep2(i, 1, h + 1){
    rep(j, n){
        d = max(i - a[j], 0ll);
        c[i] = min(c[i], c[d] + b[j]);
    }
  }
  out(c[h]);
  memi;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<map>
#include<string.h>
#include<vector>
#include<set>
#include<stdio.h>
#include<math.h>
//#include<algorithm>
#include<queue>
typedef long long ll;
typedef long double ld;
using namespace std;
int p;
int sum;
int mp[100001];
int get(int x)
{
	int l=0;
	for(int i=x;i>0;i/=10)
	{
		l+=x%10;
		x/=10;
	}
	return l;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int j=n-i;
	  p=(get(i))+(get(j));
		mp[i]=p;
	}
	sum=mp[1];
	for(int i=2;i<n;i++)
	{
		if(mp[i]<sum) sum=mp[i];
	}
	cout<<sum<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	int n;
	while(~scanf("%d",&n)){
		int count=0;
		int x;
		for(int i=1;i<=n;i++){
			scanf("%d",&x);
			if(i%2!=0 && x%2!=0){
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 3228
/*
 
 * This code is written by Sanskar Agarwal
 
*/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define VPLL vector<PLL>
#define VPII vector<PII>
#define PQ priority_queue<PLL,VPLL, greater<PLL> > 
#define PQI priority_queue<PII,VPII,greater<PII> >
#define UMLL unordered_map<ll,ll>
#define UMII unordered_map<int,int>
#define VI vector<int>
#define VL vector<ll>
#define S second
#define F first
#define PB push_back


int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,i;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    double pre=a[0];
    for(i=1;i<n;i++) {
        pre=(pre+(double)a[i])/(2.000000000000000000000000);
    }
    cout << fixed << setprecision(25) << pre;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>


int main(void)
{
	int i,j;
	char str[1000],cmd[10],p[1000],temp[1000];
	char pri[] = "print", rev[]= "reverse", rep[] = "replace";
	int q,a,b;

	scanf("%s", str);
	scanf("%d", &q);
	
	for(i = 0; i < q; i++)
	{
		scanf("%s", cmd);

		if (strcmp(cmd,pri) == 0)
		{
			scanf("%d %d", &a, &b);
			strncpy(temp, str + a, b-a+1);
			temp[b - a + 1] = '\0';

			for(j = 0; j < b-a+1; j++)
			{
				printf("%c", temp[j]);
			}
			printf("\n");

		}else if (strcmp(cmd,rev) == 0)
		{
			scanf("%d %d", &a,&b);

			for(j = 0; j <= b - a; j++)
			{
				temp[j] = str[b - j];
			}
			for(j = 0; j <= b-a; j++)
			{
				str[a + j] = temp[j];
			}

		}else if (strcmp(cmd,rep) == 0)  //ok
		{
			scanf("%d %d %s", &a,&b,p);
			for(j = 0; j <= b-a; j++)
			{
				str[j + a] = p[j];
			}
		}
		
	}


	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int R;
    cin >> R;
    if (R < 1200) {
         cout << "ABC" << endl;
    }
    else if (R < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
}

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

using namespace std;


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

 vector<int> km(n);
int cnt = 0;
int min = 200001;
 for(int i = 0;i < n;i++){
    cin >> km[i];
    if(km[i] < min) {
        cnt++;
      min = km[i];
  }
 }

 cout << cnt <<endl;
}

Measured memory_bytes: 1024