akhauriyash/Code-Regression huggingface dataset:
import numpy as np

A = np.zeros((3, 3), dtype=int)
for i in range(3):
    A[i, :] = [int(x) for x in input().split()]
N = int(input())
b = np.zeros(N, dtype=int)
for i in range(N):
    b[i] = int(input())

for i in range(3):
    for j in range(3):
        if A[i, j] in b:
            A[i, j] = 0

is_bingo = False
for i in range(3):
    if np.sum(A[i, :]) == 0:
        is_bingo = True

for j in range(3):
    if np.sum(A[:, j]) == 0:
        is_bingo = True

if A[1, 1] == 0:
    if A[0, 0] == 0 and A[2, 2] == 0:
        is_bingo = True
    elif A[0, 2] == 0 and A[2, 0] == 0:
        is_bingo = True

if is_bingo:
    print("Yes")
else:
    print("No")


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

typedef long long ll;
typedef pair<ll, ll> pll;
const int N = 1e5 + 100;

ll n, d[N], cnt[N], dp[N];
vector<int> nei[N];
vector<pll> vec, ans;
bool no_homo;
unordered_map<ll, int> v_d;

void dfs(int v, int par = -1) {
	for (int u: nei[v])
		if(u != par) {
			dfs(u, v);
			dp[v] += dp[u] + cnt[u];
		}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> d[i], vec.push_back(pll(d[i], i)), cnt[i] = 1, v_d[d[i]] = i;
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	for (int i = 0; i < n - 1; i++) {
		ll v = vec[i].second, want = vec[i].first + 2 * cnt[v] - n, u = v_d[want];
		if(2 * cnt[v] > n)
			no_homo = true;
		//cerr << v << " want -> " << u << ' ' << want << '\n';
		if(u == 0)
			no_homo = true;
		else {
			cnt[u] += cnt[v];
			ans.push_back(pll(v, u));
			nei[v].push_back(u);
			nei[u].push_back(v);
		}
	}
	dfs(vec.back().second);
	if(d[vec.back().second] != dp[vec.back().second])
		no_homo = true;
	if(no_homo) {
		cout << -1;
		return 0;
	}
	for (pll p: ans)
		cout << p.first << ' ' << p.second << '\n';
	return 0;
}// 1 BASE

Measured memory_bytes: 19604
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define mp make_pair
#define pb push_back
#define FI first
#define SE second
#define FOR(i,a,b) for(int (i)=((int)a); (i)<((int)b); (i)++) // [a,b)
#define REP(i,N) FOR((i), 0, ((int)N)) // [0,N)
#define INF (1 << 30)
#define icin(x) int x; cin >> x
#define lcin(x) ll x; cin >> x
#define dcin(x) double x; cin >> x
#define scin(s) string s; cin >> s 
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vcin(v,N) vi v(N); REP(i,N) cin >> v[i] // 配列にも使用可能
#define vcinl(v,N) vl v(N); REP(i,N) cin >> v[i]
#define vmax(v) *max_element(all(v)) // 遅い？いつか書き直す
#define vmin(v) *min_element(all(v))
#define vidx(v,it) distance((v).begin(),(it))
#define vsum(v) accumulate(all(v),0)
#define vsumr(v,a,b) accumulate((v).begin()+(a),(v).begin()+(b),0) //[a,b)
#define vfnd(v,val) find(all(v),val) // itrを返す。存在しない場合v.end()を返す
#define vcnt(v,val) count(all(v),val)
#define vrep(v,it) for(auto it=(v).begin(); it != (v).end(); ++it)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0) // IOS;で高速化

// デバッグ用
// dbg(...) printfと同様に使用可能 
// trc(var) (変数名)=(値)と表示
// stopif(val) 条件分が真の時に止まる
// vdbg(v) vの中身を表示
#ifdef LOCAL
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
    #define trc(var) cout << #var << "=" << var << endl
    #define trc2(v) cout << #v << "={"
    #define stopif(val) assert( !(val) )
    #define vdbg(v) vector_debug(v)
#else
    #define dbg(...) 1
    #define trc(var) 1
    #define trc2(v) 1
    #define stopif(val) 1
    #define vdbg(v) 1
#endif

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > vvi;
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}
ll gcd(ll a, ll b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}
template<typename C> inline void vector_debug(vector<C> v){trc2(v);ostream_iterator<C> o(cout,",");copy(all(v),o);cout<<"}"<<endl;}
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

// icin(x) ... int x; cin >> x;
// vcin(A,N),vcinl vi(vl) Aを宣言してcinで初期化

inline bool is753(int n){
    bool a=false,b=false,c=false;
    while(n != 0){
        if(n % 10 == 3)a = true;
        if(n % 10 == 5)b = true;
        if(n % 10 == 7)c = true;
        n = n / 10;
    }
    return (a && b && c);
}

vi lst;

void make753(int cur,int N){
    trc(cur); trc(N);
    if(N == 0){
        if(is753(cur)) lst.pb(cur);
    }
    else{
        make753(cur * 10 + 3,N-1);
        make753(cur * 10 + 5,N-1);
        make753(cur * 10 + 7,N-1);
    }
}

int main(){ IOS;
    icin(N);
    FOR(i,3,10) make753(0,i);
    int cnt = 0;
    REP(i,sz(lst)){
        if(lst[i] <= N) cnt++;
    }
    cout << cnt << endl;
   return 0;
}

Measured memory_bytes: 512
#include <cstdio>
using namespace std;
int main(){
  int m, f, r;
  for (; ;) {
    scanf("%d %d %d", &m, &f, &r);
    if (m==-1 && f==-1 && r==-1) break;
    if (m==-1 || f==-1 || m+f<30) printf("F\n");
    else if (m+f>=80) printf("A\n");
    else if (m+f>=65 && m+f<80) printf("B\n");
    else if (m+f>=50 && m+f<65) printf("C\n");
    else if (m+f>=30 && m+f<50) {
      if (r>=50) printf("C\n");
      else printf("D\n");
    }
  }
}


Measured memory_bytes: 2624
import sys
N,K=map(int, input().split())
mod=10**9+7
G={}
for i in range(N):
  G[i+1]=[]
for i in range(N-1):
  a,b=map(int, input().split())
  G[a].append(b)
  G[b].append(a)

for i in range(N):
  if len(G[i+1])>=K:
    print(0)
    exit()

def nPr(n,r):
  res=1
  for i in range(r):
    res*=(n-i)
    res%=mod
  return res

from collections import deque
q=deque([(1,0)])
ans=K
while q:
  n,m=q.pop()
  if m==0:
    ans*=nPr(K-1,len(G[n]))
    ans%=mod
    for d in G[n]:
      q.appendleft((d,n))
  else:
    ans*=nPr(K-2,len(G[n])-1)
    ans%=mod
    for d in G[n]:
      if d!=m:
        q.appendleft((d,n))
print(ans)

Measured memory_bytes: 93936
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

int main() {
    string c;
    cin >> c;
    char x = ((int)c[0]) + 1;
    cout << x << endl;
}


Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

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

	int x;
	cin >> x;

	int res = (x / 500) * 1000;
	x %= 500;
	res += (x / 5) * 5;
	cout << res << '\n';
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: i64,
        p: i64,
    }

    let mut sieve = vec![true; 1000000 + 1];
    let mut primes = vec![];

    for i in 2..sieve.len() {
        if !sieve[i] {
            continue;
        }

        primes.push(i);

        let mut j = i + i;
        while j < sieve.len() {
            sieve[j] = false;
            j += i;
        }
    }

    let mut fs = std::collections::BTreeMap::new();
    let mut q = p;
    for pr in primes {
        let pr = pr as i64;
        while q % pr == 0 {
            *fs.entry(pr).or_insert(0) += 1;
            q /= pr;
        }
    }
    if q != 1 {
        *fs.entry(q).or_insert(0) += 1;
    }

    let mut ans = 1;
    for (pr, cnt) in fs.iter() {
        ans *= pr.pow((cnt / n) as u32);
    }

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


Measured memory_bytes: 6396
#include<stdio.h>

/*a>b*/
int GCD(int a,int b){

        int k,r,c;

        if(a<b){
                c=a;
                a=b;
                b=c;
        }

        while(1){

        k=a/b;
        r=a-k*b;

        if(r==0) break;

        a=b;
        b=r;
        }
        return b;
}

int main(void){

        int x,y,lcd;

        while(scanf("%d%d",&x,&y)!=EOF){

        lcd=x/GCD(x,y)*y; /* avoid calculate x*y(very large number) */

        printf("%d %d\n",GCD(x,y),lcd);
        }

        return 0;
}

Measured memory_bytes: 1756
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  double a, b, c, C, rad;
  cin >> a >> b >> C;
  cout << fixed << setprecision(5);
  rad = M_PI * C / 180;
  // S = a*b*sin θ/2
  cout << (a * b * sin(rad)) / 2 << '\n';
  // L = a + b + sqrt(a * a + b * b - 2 * a * b * cos θ
  cout << (a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad))) << '\n';
  // h = b * sin θ
  cout << (b * sin(rad)) << '\n';
}



Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

int main() {

    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<ll> sorted_a = a;
    sort(all(sorted_a));
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll more_cnt = 0;
        for (int j = i + 1; j < n; ++j) {
            if (a[i] > a[j]) {
                ++more_cnt;
            }
        }

        ll total_cnt = sorted_a.end() - upper_bound(all(sorted_a), a[i]);

        ans += total_cnt * (((k - 1) * k / 2) % MOD) + more_cnt * k;
        ans %= MOD;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int> w(N), v(N); rep(i, 0, N) { cin >> w[i] >> v[i]; }
	vector<vector<int>>x(4, vector<int>(1, 0));
	rep(i, 0, N)x[w[i] - w[0]].emplace_back(v[i]);
	rep(i, 0, 4) {
		sort(1 + all(x[i]),greater<int>());
		rep(j, 1, x[i].size())x[i][j] += x[i][j - 1];
	}
	int ans(0);
	rep(i, 0, x[0].size())rep(j, 0, x[1].size())rep(k, 0, x[2].size())rep(l, 0, x[3].size()) {
		if (i*w[0] + j*(w[0] + 1) + k*(w[0] + 2) + l*(w[0] + 3) <= W)
			chmax(ans, x[0][i] + x[1][j] + x[2][k] + x[3][l]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		String S=sc.next();

		String[] str=S.split("");

		int N=str.length;
		int c0=0;
		int c1=0;

		for(int i=0;i<N;i++) {

			if(str[i].equals("0")) c0++;
			if(str[i].equals("1")) c1++;


		}

		System.out.println(Math.min(c0, c1)*2);

		sc.close();
	}

}


Measured memory_bytes: 34440
import math
a,b,C = map(int,raw_input().split())
C = C*(math.pi/180)
S = 0.5*a * b * math.sin(C)
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))
L = a + b + c
h = b * math.sin(C)

print S
print L
print h

Measured memory_bytes: 4424
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
const ll inf=1LL<<61;
int main(){
ll n;cin>>n;
map<string,ll> mp;
rep(i,n){
  string s;
  cin>>s;
  mp[s]++;
}
cout <<"AC"<<" "<<"x"<<" " <<mp["AC"] << endl;
cout <<"WA"<<" "<<"x"<<" "<< mp["WA"] << endl;
cout <<"TLE"<<" "<<"x"<<" "<< mp["TLE"] << endl;
cout <<"RE"<<" "<<"x"<<" "<< mp["RE"] << endl;
}

Measured memory_bytes: 3600
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
INF = 10**9
MOD = 10**9+7

N = int(input())
print((N//2+N%2)/N)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; i++) {
        cin >> s[i];
    }
    int ans = 0;
    for(int si = 0; si < h; si++) {
        for(int sj = 0; sj < w; sj++) {
            if (s[si][sj] == '#') 
            continue;
            vector<vector<int>> dist(h, vector<int>(w, INF));
            queue<pair<int, int>> q;
            dist[si][sj] = 0;
            q.push({si, sj});
            while (!q.empty())  {
                int x = q.front().first, y = q.front().second;
                q.pop();
                // 全方向を試す(dirには四方の値が入ってる)
                for(int k = 0; k < 4; k++) {
                    int ni = x + dir[k][0], nj = y + dir[k][1];
                    if (ni < 0 || ni >= h || nj < 0 || nj >= w ||
                        s[ni][nj] == '#' || dist[ni][nj] != INF) 
                        continue;
                    dist[ni][nj] = dist[x][y] + 1;
                    q.push({ni,nj});
                }
            } 
            for(int i=0;i<h;i++) {
                for(int j=0;j<w;j++) {
                    if (dist[i][j] == INF) continue;
                    ans = max(ans, dist[i][j]);
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
<?php
    fscanf(STDIN, "%d%d%d%d", $a,$b,$c,$d);
    $count = 1;
    while(($a > 0) && ($c > 0)){
        //割り切れたら青木攻撃
        if($count%2==0){
            $a -= $d;
        }else{
            //割り切れなかったら高橋攻撃
            $c -= $b;
        }
        $count++;
    }
    if($count%2==0){
        echo "Yes" . "\n";
    }else{
        echo "No" . "\n";
    }
?>

Measured memory_bytes: 16332
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>
#include<math.h>

int_fast32_t insertion_sort(int_fast32_t *a, int_fast32_t n, int_fast32_t g)
{
    int_fast32_t cnt = 0;
    for(int_fast32_t i=g; i<n; ++i){
        int_fast32_t v = a[i];
        int_fast32_t j = i - g;
        while(j >= 0 && a[j] > v){
            a[j+g] = a[j];
            j -= g;
            ++cnt;
        }
        a[j+g] = v;
    }
    return cnt;
}

void shell_sort(int_fast32_t *a, int_fast32_t n)
{
    int_fast32_t cnt = 0;
    int_fast32_t m   = log(2.0*n+1.0)/log(3.0);
    int_fast32_t g[m];
    g[m-1] = 1;
    for(int_fast32_t i=1; i<m; ++i)
        g[m-i-1] = g[m-i]*3+1;

    for(int_fast32_t i=0; i<m; ++i)
        cnt += insertion_sort(a, n, g[i]);

    printf("%"PRIdFAST32"\n", m);
    printf("%"PRIdFAST32, g[0]);
    for(int_fast32_t i=1; i<m; ++i)
        printf(" %"PRIdFAST32, g[i]);
    printf("\n");
    printf("%"PRIdFAST32"\n", cnt);
}

int main(void)
{
    int_fast32_t n;
    scanf("%"SCNdFAST32, &n);

    int_fast32_t a[n];
    for(uint_fast32_t i=0; i<n; ++i)
        scanf("%"SCNdFAST32, &a[i]);

    shell_sort(a, n);

    for(uint_fast32_t i=0; i<n; ++i)
        printf("%"PRIdFAST32"\n", a[i]);

    return 0;
}

Measured memory_bytes: 9748
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b, c = (_ for _ in input().split())
    if int(a+b+c) % 4 == 0:
        print('YES')
    else:
        print('NO')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
//20190907
//Buffet
//Naru
#include<iostream>
using namespace std;

int A[21];//食べる番号
int B[21];//満足
int C[21];//追加満足

int main() {
  int N;
  cin >> N;
  for(int i=1; i<=N; i++) {
    cin >> A[i];
  }
  for(int i=1; i<=N; i++) {
    cin >> B[i];
  }
  for(int i=1; i<=N-1; i++) {
    cin >> C[i];
  }
  // main
  int ans=0;
  int bfNum = N+1;
  for(int i=1; i<=N; i++) {
    if(A[i] == bfNum+1) {
      ans += C[A[i-1]];
    }
    bfNum = A[i];
    ans += B[A[i]];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader s = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    private static int[] rai(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        return arr;
    }

    private static int[][] rai(int n, int m) {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextInt();
            }
        }
        return arr;
    }

    private static long[] ral(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextLong();
        }
        return arr;
    }

    private static long[][] ral(int n, int m) {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextLong();
            }
        }
        return arr;
    }

    private static int ri() {
        return s.nextInt();
    }

    private static long rl() {
        return s.nextLong();
    }

    private static String rs() {
        return s.next();
    }
    static int gcd(int a,int b)
    {
        if(b==0)
        {
            return a;
        }
        return gcd(b,a%b);
    }


    public static void main(String[] args) {
        StringBuilder ans = new StringBuilder();
//        int t = ri();
        int t=1;
        while (t-- > 0) {
            int n=ri();
            if(n%1000==0)
            {
                ans.append("0\n");
            }
            else {
                ans.append(1000-n%1000).append("\n");
            }
        }
        out.print(ans.toString());
        out.flush();

    }

}


Measured memory_bytes: 25388
import math


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


n = int(input())
total = 0
if n == 1:
    print("0", end="")
    exit()

ps = factorization(n)
for p in ps:
    c = int((-1 + math.sqrt(1+8*p[1]))/2)
    total += c
print(total, end="")


Measured memory_bytes: 9492
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

template <uint_fast64_t MOD> class ModInt {
    using u64 = uint_fast64_t;

  public:
    u64 a;

    ModInt(const u64 x = 0) : a(x % MOD) {}
    constexpr u64 &value() { return a; }
    constexpr ModInt operator-() { return a ? MOD - a : 0; }
    constexpr ModInt operator+(const ModInt rhs) {
        return ModInt(*this) += rhs;
    }
    constexpr ModInt operator-(const ModInt rhs) {
        return ModInt(*this) -= rhs;
    }
    constexpr ModInt operator*(const ModInt rhs) {
        return ModInt(*this) *= rhs;
    }
    constexpr ModInt operator/(const ModInt rhs) {
        return ModInt(*this) /= rhs;
    }
    constexpr ModInt &operator+=(const ModInt rhs) {
        a += rhs.a;
        if(a >= MOD) {
            a -= MOD;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) {
        if(a < rhs.a) {
            a += MOD;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) {
        a = a * rhs.a % MOD;
        return *this;
    }
    constexpr ModInt &operator/=(const ModInt rhs) {
        *this *= rhs.inv();
        return *this;
    }

    constexpr bool operator==(const ModInt rhs) { return this->a == rhs.a; }
    constexpr bool operator!=(const ModInt rhs) { return this->a != rhs.a; }
    friend constexpr ostream &operator<<(ostream &os, const ModInt<MOD> &x) {
        return os << x.a;
    }
    friend constexpr istream &operator>>(istream &is, ModInt<MOD> &x) {
        return is >> x.a;
    }

    constexpr ModInt inv() {
        u64 x = a, y = MOD, u = 1, v = 0, t = 0;
        while(y > 0) {
            t = x / y;
            a -= t * y;
            swap(x, y);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    constexpr ModInt pow(int e) {
        u64 x = 1, p = a;
        while(e > 0) {
            if(e % 2 == 0) {
                p = (p * p) % MOD;
                e /= 2;
            } else {
                x = (x * p) % MOD;
                e--;
            }
        }
        return ModInt(x);
    }
};

using mint = ModInt<MOD>;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    map<char, int> mp;
    rep(i, S.size()) { mp[S[i]]++; }
    mint res = 1;
    for(auto x : mp) {
        res *= mint(x.second + 1);
    }
    cout << res - 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int x, y;
	while (cin >> x >> y){
		if (x == 0 && y == 0)break;
		if (x < y)swap(x, y);
		int sum = 0;
		do{
			x = x%y;
			swap(x, y);
			sum++;
		} while (y != 0);
		cout << x << ' ' << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((int)(1e9))

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, T; cin >> N >> T;
	vector<int> A(N, 0);
	rep (i, N) cin >> A[i];

	int mn = INF;
	int mx = 0;
	int cnt = 0;
	rep (i, N){
		mn = min(mn, A[i]);
		int diff = A[i] - mn;
		if (diff > mx){
			mx = diff;
			cnt = 1;
		}else
		if (diff == mx){
			++cnt;
		} // end if
	} // end for

	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 640
#define alphanso                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(NULL)
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
int main()
{
	alphanso;
	ull n, a, b;
	cin>>n>>a>>b;
	if(n==1)
		a==b ? cout<<1 : cout<<0;
	else if(n==2)
		a==b ? cout<<0 : cout<<1;
	else if(a>b)
		cout<<0; 
	else{
		cout<<((n-1)*b+a)-((n-1)*a+b)+1;
	}
	return 0;
}

Measured memory_bytes: 3628
import sys
import math
input = sys.stdin.readline

a, b, x = map(int, input().split())

area = x / a

if (a * b / 2) == area:
    # 水の量が、傾けた時に、底面と高さぴったりの時
    θ = math.atan(b / a)
elif (a * b / 2) > area:
    # 水の量が、水筒の半分より小さい時
    c = area / b * 2
    θ = math.atan(b / c)
elif (a * b / 2) < area:
    # 水の量が、水筒の半分より大きい時 -> 台形になる時
    # 元々の水面の高さ
    h = x / (a * a)
    # 溢れるまで傾けた時の台形の短い部分のながさ
    # area == (d + b) * a / 2 から下を導き出す
    d = (area / (a / 2)) - b
    # 元々の水面から溢れるまで(bまで)の距離
    increment = h - d
    θ = math.atan(increment / (a / 2))

print(math.degrees(θ))


Measured memory_bytes: 38768
#include<cstdio>
#include<map>
using namespace std;

const int MAX_N = 1e4, MOD = 1e9 + 7;
int n;
int a[MAX_N];

int po(int x, int y) {
    int ans = 1;
    while (y > 0) {
        if (y & 1) ans = static_cast<long>(ans) * x % MOD;
        x = static_cast<long>(x) * x % MOD;
        y >>= 1;
    }
    return ans;
}

map<int, int> p;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) {
        int b = a[i], q[1000];
        for (int j = 2; j * j <= a[i]; j++) {
            q[j - 1] = 0;
            while (b % j == 0) {
                b /= j;
                q[j - 1]++;
            }
            if (q[j - 1] > 0 && p[j] < q[j - 1]) p[j] = q[j - 1];
        } 
        if (b != 1 && p.find(b) == p.end()) p[b] = 1;
    }
    int l = 1;
    for (auto &i : p) l = static_cast<long>(l) * po(i.first, i.second) % MOD;
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = (ans + static_cast<long>(l) * po(a[i], MOD - 2) % MOD) % MOD;
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

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

int main() {
	int n, k;
	cin >> n >> k;
	int h[n], m = (int)1e9;
	rep(i,n) cin >> h[i];
	sort(h, h+n);
	rep(i,n-k+1) m = min(m, h[i+k-1] - h[i]);
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#define endl '\n'
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define ll long long
#define INF 0x3f3f3f3f
#define sync ios::sync_with_stdio(0);
const int N=100005;
using namespace std;

int n;
ll a[N];
ll pre[N],las[N];

int main()
{sync
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		pre[i]=pre[i-1]+abs(a[i]-a[i-1]);
	}
	for(int i=n;i>=1;i--)
	{
		las[i]=las[i+1]+abs(a[i]-a[i+1]);
	}
	for(int i=1;i<=n;i++)
	{
		cout<<pre[i-1]+las[i+1]+abs(a[i+1]-a[i-1])<<endl;
	}
	return 0;
}

Measured memory_bytes: 3584
import bisect
MAXN = 1300000
primes = []
sieve = [0,0] + [1] * MAXN
n = 2
while n*n < MAXN:
    if sieve[n]:
        primes.append(n)
        for m in range(2*n,MAXN,n):
            sieve[m] = 0
    n += 1
for m in range(n,MAXN):
    if sieve[m]:
        primes.append(m)

while True:
    N = int(input())
    if N == 0: break
    l = bisect.bisect_left(primes,N)
    r = bisect.bisect_right(primes,N)
    if r-l == 1:
        print(0)
    else:
        print(primes[l] - primes[l-1])

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

typedef long long int ll;

ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}


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

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

    ll c = 0, ans = 0;
    for(ll i = 1;i < n;i++){
        ans += a[n - c - 1];
        if(i % 2 != 0){
            c++;
        }
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 4832
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX/2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int A,B;
  cin>>A>>B;
  if( A == 1) A= 14;
  if(B == 1) B = 14;
  if( A > B)
  {
    cout<<"Alice"<<endl;
  }
  if(B > A)
  {
    cout<<"Bob"<<endl;
  }
  if(A == B )
  {
    cout<<"Draw"<<endl;
  }
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
int inf = 128000000000;

int32_t main(){
	int t; cin >> t;
	while(t--){
		int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
		map<int, int> m;
		m[n]=-inf;
		priority_queue<int> q;
		q.push(n);
		while(!q.empty()){
			int i=q.top();
			while(!q.empty() && q.top() == i) q.pop();
			if(i < inf/d && m[0] > m[i]+i*d) m[0] = m[i] + i*d; // -1 all the way to zero
			if(m[i/2] > m[i] + a + d*(i % 2)){ // round down divide by two
				m[i/2] = m[i] + a + d*(i % 2);
				q.push(i/2);
			}
			if(m[i/3] > m[i] + b + d*(i % 3)){ // round down divide by three
				m[i/3] = m[i] + b + d*(i % 3);
				q.push(i/3);
			}
			if(m[i/5] > m[i] + c + d*(i % 5)){ // round down divide by five
				m[i/5] = m[i] + c + d*(i % 5);
				q.push(i/5);
			}
			if(m[i/2+1] > m[i] + a + d*(2 - (i % 2))){ // round up divide by two
				m[i/2+1] = m[i] + a + d*(2 - (i % 2));
				q.push(i/2+1);
			}
			if(m[i/3+1] > m[i] + b + d*(3 - (i % 3))){ // round up divide by three
				m[i/3+1] = m[i] + b + d*(3 - (i % 3));
				q.push(i/3+1);
			}
			if(m[i/5+1] > m[i] + c + d*(5 - (i % 5))){ // round up divide by five
				m[i/5+1] = m[i] + c + d*(5 - (i % 5));
				q.push(i/5+1);
			}
		}
		cout << m[0]+inf << endl;
	}
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n){
        cin >> s[i];
    }
    int m;
    cin >> m;
    vector<string> t(m);
    rep(i,m){
        cin >> t[i];
    }
    int MAX = 0;
    for (int i = 0; i < n; i++)
    {
        string s1 = s[i];
        int cnt = 0;
        for (int j = 0; j < n; j++)
        {
            if (s1==s[j])
            {
                cnt++;
            }
        }
        for (int i = 0; i < m; i++)
        {
            if (s1==t[i])
            {
                cnt--;
            }
        }
        MAX = max(cnt, MAX);
    }
    cout << MAX << endl;
}

Measured memory_bytes: 256
class Float
  def jpy
    self.to_f
  end
  def btc
    self.to_f * 380000
  end
end

N = gets.to_i
money = N.times.map do
  x, t = gets.split
  x.to_f.send(t.downcase)
end.inject(0.0, &:+)
puts "%.6f" % money

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int n,m,p;
int dp[32][32][33][33][2];
int t[35][35];
int ts[35][35];

int check(int a,int b,int c,int d){
	if(dp[a][b][c][d][0]!=-1)return dp[a][b][c][d][0];
	int e=ts[c][d]-ts[a][d]-ts[c][b]+ts[a][b];
	if(e>=p)dp[a][b][c][d][1]=e-p,e=1;
	else e=0;
	int f,g;
	for(int i=a+1;i<c;i++){
		f=check(a,b,i,d)+check(i,b,c,d);
		g=min(dp[a][b][i][d][1],dp[i][b][c][d][1]);
		if(e<f)e=f,dp[a][b][c][d][1]=g;
		if(e==f)dp[a][b][c][d][1]=max(dp[a][b][c][d][1],g);
	}
	for(int i=b+1;i<d;i++){
		f=check(a,b,c,i)+check(a,i,c,d);
		g=min(dp[a][b][c][i][1],dp[a][i][c][d][1]);
		if(e<f)e=f,dp[a][b][c][d][1]=g;
		if(e==f)dp[a][b][c][d][1]=max(dp[a][b][c][d][1],g);
	}
	dp[a][b][c][d][0]=e;
	return e;
}

int main(){
	int i,j,k;
	int a,b,c;
	while(cin>>n>>m>>p){
		if(n==0)break;
		memset(t,0,sizeof(t));
		memset(ts,0,sizeof(ts));
		memset(dp,-1,sizeof(dp));
		a=0;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				cin>>t[i][j];
				a+=t[i][j];
			}
		}
		p=a-p;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				ts[i+1][j+1]=ts[i][j+1]+ts[i+1][j]-ts[i][j]+t[i][j];
			}
		}
		check(0,0,n,m);
		cout<<dp[0][0][n][m][0]<<" "<<dp[0][0][n][m][1]<<endl;
	}
}



Measured memory_bytes: 11816
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector <int> ar(n);
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		ar[a - 1]++;
	}
	sort(ar.begin(), ar.end());
	int ans = 0;
	for (int i = 0; i < n - k; ++i) {
		ans += ar[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <random>
#include <map>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)
#define YN(f) f?cout<<"YES"<<endl:cout<<"NO"<<endl;
#define yn(f) f?cout<<"Yes"<<endl:cout<<"No"<<endl;

signed main(){
	int n;cin>>n;
	cout<<"Christmas";
	int c=25-n;
	while(c--){
		cout<<" "<<"Eve";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef long double     ld;
typedef string          str;
#define all(x)			(x).begin(),(x).end()
#define Sort(x)			sort(all(x))
#define A               first
#define B               second
#define sep             ' '
#define endl            '\n'
#define fast_io         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAX1 = 2e5+7,
	     MOD = 1e9+7;

ll n, m;

set <ll> st;

int main(){
	fast_io;
	cin >> n >> m;
	for (int i = 1; i <= 3; ++i)	st.insert(i);
	st.erase(n);
	st.erase(m);
	cout << *(st.begin());
    return 0;
}
/*                     now or never                         */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    int ans = INT_MAX;
    for(int i = 0; i + t.size() - 1 < s.size(); i++) {
        int tmp = 0;
        for(int j = 0; j < t.size(); j++) {
            tmp += (s[i + j] != t[j]);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>

using namespace std;

bool include(string s,char c){
  return s.find(c)!=string::npos;
}

bool boin(char c){
  return include("aeiou",c);
}

bool museishiin(char c){
  return include("ksthp",c);
}

int main(){
  for(string s;cin>>s,s[0]!='#';){
    vector<string> v;
    for(int i=0;i<s.size();){
      int l;
      if(boin(s[i])){
	l=1;
      }else{
	if(i+1==s.size()){
	  l=1;
	}else if(boin(s[i+1])){
	  l=2;
	}else if(s[i+1]==s[i]){
	  l=1;
	}else if(s[i+1]=='y'){
	  l=3;
	}else if(s[i+1]=='\''){
	  l=2;
	}else{
	  l=1;
	}
      }
      v.push_back(s.substr(i,l));
      i+=l;
    }
    bool last=false;
    for(int i=0;i<v.size();i++){
      bool c=false;
      char lc=v[i].back();
      if(!last&&boin(lc)){
	if(lc=='i'||lc=='u'){
	  c=museishiin(v[i][0])&&(i+1==v.size()||museishiin(v[i+1][0]));
	}else if(lc=='a'||lc=='o'){
	  c=i+1!=v.size()&&museishiin(v[i][0])&&museishiin(v[i+1][0])&&lc==v[i+1].back();
	}
      }
      if(c){
	cout<<v[i].substr(0,v[i].size()-1)<<'('<<lc<<')';
      }else{
	cout<<v[i];
      }
      if(boin(v[i].back())){
	last=c;
      }
    }
    cout<<endl;
  }
}

	    
	    
	  

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int total=0;
  
  for(int i=0; i<N; i++){
    int l, r;
  	cin >> l >> r;
    total += r-l+1;
  }
  
  cout << total << endl;
}

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

Measured memory_bytes: 1024
#include <queue>
#include <tuple>
#include <cstdio>
#include <iostream>
using namespace std;

const int maxn = 1055;

char M[maxn][maxn];
int  step[maxn][maxn];

int main() {
  int H, W, Ch, Cw, Dh, Dw;
  scanf("%d%d%d%d%d%d", &H, &W, &Ch, &Cw, & Dh, &Dw);
  for(int i = 1; i <= H; i++) { scanf("%s", &M[i][1]); }
  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      step[i][j] = maxn * maxn;
    }
  }
  queue<tuple<int, int> > q;
  queue<tuple<int, int> > r;
  q.push({Ch, Cw});
  step[Ch][Cw] = 0;
  int cnt = 0;
  while(!q.empty()) {
    // phase 1, 1 step
    while(!q.empty()) {
      auto [x, y] = q.front(); q.pop();
      r.push({x, y});
      vector<tuple<int, int> > walk = { {x, y + 1}, {x + 1, y}, {x, y - 1}, {x - 1, y}};
      for(auto [xx, yy]: walk) {
        if(1 <= xx && xx <= H && 1 <= yy && yy <= W && M[xx][yy] == '.') {
          if(step[xx][yy] > cnt) {
            step[xx][yy] = cnt;
            q.push({xx, yy});
          }
        }
      }
    }
    cnt += 1;
    while(!r.empty()) {
      auto [x, y] = r.front(); r.pop();
      for(int dx = -2; dx <= 2; dx++) {
        for(int dy = -2; dy <= 2; dy++) {
          if(dx == 0 && dy == 0) continue;
          int xx = x + dx, yy = y + dy;
          if(1 <= xx && xx <= H && 1 <= yy && yy <= W && M[xx][yy] == '.') {
            if(step[xx][yy] > cnt) {
              step[xx][yy] = cnt;
              q.push({xx, yy});
            }
          }
        }
      }
    }
  }
  /*
  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      cerr << step[i][j] << " ";
    }
    cerr << endl;
  } */
  if(step[Dh][Dw] == maxn * maxn) {
    puts("-1");
  } else {
    printf("%d\n", step[Dh][Dw]);
  }
  return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

template<unsigned mod=1000000007>struct mint {
   unsigned val;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=ll(val)*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=ll(val)*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
template<unsigned mod=1000000007>struct factorial {
   using Mint=mint<mod>;
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};
using Mint=mint<>;

int main(){
   string s; cin>>s; int n=s.size();
   Mint dp[101000][2]; dp[0][0]=1;
   rep(i,0,n)rep(j,0,2){
      if(!j&&(s[i]=='0'))dp[i+1][j]+=dp[i][j];
      else{
         dp[i+1][1]+=dp[i][j];
         dp[i+1][j]+=dp[i][j]*2;
      }
   }
   Mint res=dp[n][0]+dp[n][1]; printf("%d\n",res.val);
   return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> a(n);
  for (int i = 0; i < n; i++) {
    ll A, B;
    cin >> A >> B;
    a[i] = make_pair(A, B);
  }

  sort(a.begin(), a.end());
  ll sum  = 0;
  int now = m;
  for (int i = 0; i < n; i++) {
    pair<ll, ll> p = a[i];
    if (now <= p.second) {
      sum += (p.first * now);
      now = 0;
    } else {
      sum += (p.first * p.second);
      now -= p.second;
    }
    if (now == 0) { break; }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
use io::*;
use std::*;

const YES: &'static str = "Yes";
const NO: &'static str = "No";
fn solve(S: String) {
    let mut easy = true;
    for (i, c) in S.chars().enumerate() {
        let i=i+1;
        if i%2==1 {
            if c=='L' {
                easy = false;
            }
        } else {
            if c=='R' {
                easy = false;
            }
        }
    }
    println!("{}", if easy { YES } else { NO });
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut S: String;
    S = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(S)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8572