akhauriyash/Code-Regression huggingface dataset:
use std::collections::{BTreeMap, BinaryHeap};

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let x: Vec<u64> = sc.vec(1 << n);
    let map = x.into_iter().fold(BTreeMap::new(), |mut map, x| {
        *map.entry(x).or_insert(0) += 1;
        map
    });

    let mut heap = BinaryHeap::new();
    heap.push(n);
    for (_, count) in map.into_iter().rev() {
        if heap.len() < count {
            println!("No");
            return;
        }
        let mut tmp = vec![];
        for _ in 0..count {
            let t = heap.pop().unwrap();
            for i in 0..t {
                tmp.push(i);
            }
        }
        heap.extend(tmp);
    }
    println!("Yes");
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_N = 101000;
ll A[MAX_N];
int N, K;
const ll MOD = 1000000007;

long long fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < MAX_N; ++i){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main()
{
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; ++i) scanf("%lld", &A[i]);

    sort(A, A + N);
    COMinit();

    ll mx_sum = 0, mn_sum = 0;
    for(int i = K-1; i < N; ++i) {
        mx_sum = (mx_sum + A[i] * COM(i, K-1) %MOD) % MOD;
    }
    for(int i = N-K; i >= 0; --i) {
        mn_sum = (mn_sum + A[i] * COM(N-i-1, K-1) % MOD) % MOD;
    }
    ll res = (mx_sum - mn_sum + MOD) % MOD;
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 3456
/** @xigua */
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <climits>
#include <bitset>
#include <ctime>
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 1e8 + 5;
const ll inf = 1e15 + 5;
const db eps = 1e-8;
const ll hp = 2333;
const ll base = 1e9+13;

void solve() {
    char s[10];

    while (cin >> s) {
        int flag = 0;
        if (s[0] == s[1] && s[1] == s[2]) flag = 1;
        if (s[1] == s[2] && s[2] == s[3]) flag = 1;
        if (flag) cout << "Yes\n";
        else cout << "No\n";
    }
}

int main() {
    int t = 1, cas = 1;
   //memset(dp, 0, sizeof(dp));
   //freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
   // scanf("%d", &t);
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int a,b,c,x,count=0;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&x);
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k == x)count++;
      }
    }
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a_list , b_list, c_list = [ int(v)-1 for v in input().split() ], [ int(v) for v in input().split() ], [ int(v) for v in input().split() ]
before = None
total = 0
for i in range(n):
    total += b_list[a_list[i]]
    if i > 0 and a_list[i-1] + 1 == a_list[i]:
        total += c_list[a_list[i-1]]
    before = i
print(total)

Measured memory_bytes: 38384
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC125
{
    class Program
    {
        static long GCD(long a, long b)
        {
            return (a < b)? GCD(b, a):
                   (a == 0)? b:
                   (b == 0)? a:
                   (a % b == 0)? b: GCD(b, a % b);
        }
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long[] L = new long[N + 1];
            long[] R = new long[N + 1];
            long[] res = new long[N];
            L[0] = 0; R[N] = 0;
            for (int i = 1; i <= N; i++)
            {
                L[i] = GCD(L[i - 1], A[i - 1]);
                R[N - i] = GCD(R[N - i + 1], A[N - i]);
            }
            for (int i = 0; i < N; i++) res[i] = GCD(L[i], R[i + 1]);
            Array.Sort(res);
            Console.WriteLine(res[N - 1]); 
        }
    }
}

Measured memory_bytes: 30044
import Data.Array

makeDpTable :: (Array Int Int) -> Int -> Int -> [Int] -> [Int]
makeDpTable a b c ans
 | b == 0    = makeDpTable a (b + 1) c (0:ans)
 | b == 1    = makeDpTable a (b + 1) c (((ans !! 0) + abs((a ! 1) - (a ! 0))):ans)
 | b == c    = ans
 | otherwise = makeDpTable a (b + 1) c newAns
  where newVal = min ((ans !! 0) + abs((a ! b) - (a ! (b - 1)))) ((ans !! 1) + abs((a ! b) - (a ! (b - 2))))
        newAns = newVal:ans
 
main = do
 n <- read <$> getLine :: IO Int
 hList <- map read . words <$> getLine :: IO [Int]
 print $ head $ makeDpTable (listArray (0, n - 1) hList) 0 n []

Measured memory_bytes: 54908
import sys
N = int(input())
a = []
for line in sys.stdin.readlines():
  a.append(int(line.strip()))

s = sorted(a, reverse=True)
m0 = s[0]
m1 = s[1]

for aa in a:
  if aa == m0:
    print(m1)
  else:
    print(m0)

Measured memory_bytes: 78560
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int vals[100001];
int vis[100001];
int main() {
	int N;
	scanf("%d",&N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &vals[i]);
	}
	memset(vis, 0, sizeof vis);
	bool good = false;
	int counter = 0;
	int cur = 1;
	while (true) {
		if (vis[cur]) {
			break;
		}
		vis[cur] = 1;
		cur = vals[cur];
		counter++;
		if (cur == 2) {
			good = true;
			break;
		}
	}
	if (good) {
		printf("%d", counter);
	}
	else {
		printf("-1");
	}
	return 0;
}

Measured memory_bytes: 1024
process.stdin.resume();
process.stdin.setEncoding('utf8'); 
var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});
 
reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
	const a = +lines[0];
	const e = +lines[4];
	const k = +lines[5];
	console.log(e-a<=k ? "Yay!" : ":(");
});

Measured memory_bytes: 7500
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	ll A, B, K;
	cin >> A >> B >> K;

	ll herasu = min(A, K);
	A -= herasu;
	K -= herasu;

	herasu = min(B, K);
	B -= herasu;
	K -= herasu;

	cosp(A);
	co(B);

	Would you please return 0;
}

Measured memory_bytes: 256
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
N,K=map(int,input().split())

#A=[list(reversed(list(map(int,input().split())))) for i in range(N)]
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
fac=[1,1]
for i in range(2,N+1):
    fac.append(fac[i-1]*i%mod)
ifac=[pow(i,mod-2,mod) for i in fac]


if K==1:
    print(0)
    exit()


count=0
ncount=0
for i in range(N-K+1):
    n=N-i-K
    m=i+K-2
    ncount+=fac[m]*ifac[K-2]*ifac[m-(K-2)]%mod
    ncount%=mod
    count-=A[n]*ncount
    count%=mod

ncount=0
for i in range(K-1,N):
    n=i-1
    ncount+=fac[n]*ifac[K-2]*ifac[n-(K-2)]%mod
    ncount%=mod
    count+=A[i]*ncount
    count%=mod
print(count)


Measured memory_bytes: 68776
/**So..a**/
#include<bits/stdc++.h>
//#include <chrono>
// Success after trying 5 hour 11 minute :(


using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define PB(x, v) x.push_back(v);
#define M_P(a, b) make_pair(a, b)
#define pll pair<ll, ll>
#define ll long long
#define mll map<ll, ll>
#define vl vector<ll>
#define fa(x, v) for(auto x: v)
#define fr(i, a, b) for(ll i= a;i <=b; i++)
#define TEST  int test; cin >> test; while(test--)
#define FTEST int TesT; cin >> TesT; for(int test = 1; test<=TesT; test++)

#define B_ begin()
#define E_ end()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define NL_ "\n"
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second

#define MOD 998244353
#define  ull unsigned long long


int main()
{
   int x;
   scanf("%d", &x);
   printf("%d", (x==0));

    return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,ans=0,a,mi=1e9;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(a<mi)mi=a,ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 3e7 + 10,Lim = 10,mod = 1e9 + 7;

int tot[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline int fpm(int a,int b) {
	int res = 1;
	while(b) {
		if(b & 1) res = 1ll * res * a % mod;
		a = 1ll * a * a % mod,b /= 2;
	}
	return res;
}

int main() {

	int Max = 3e7,ans = 0;
	int n = read();
	For(i,1,Max) tot[i] = tot[i / 10] + 1;
	for(int l = 1,r = 0,Sum = 0;l < 1e7;++l) {
		for(;Sum < n;Sum += tot[++r]);
		if(Sum == n) ans++;
		Sum -= tot[l];
	}

	For(i,1,n / 8) {
		if(n % i == 0) ans = (ans + fpm(10,n / i) - fpm(10,n / i - 1) - i + 1) % mod;
		else ans++;
	}

	printf("%d\n",(ans + mod) % mod);
	return 0;
}

Measured memory_bytes: 117376
#include<iostream>
using namespace std;
int main()
{
	int i, j, t, a[10];
	for (i = 0; i < 10;i++)
		cin >> a[i];
	for (j = 0; j <9; j++)
	for (i = 0; i < 9 - j; i++)
	if (a[i] < a[i + 1])
	{
		t = a[i]; a[i] = a[i + 1]; a[i + 1] = t;
	}
	cout << a[0];
	cout << "\n";
	cout << a[1];
	cout << "\n";
	cout << a[2];
	cout << "\n";
	return 0;
}

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

using namespace std;

int main(){
        int n, a, b;
        cin>>n>>a>>b;
        int res=0;
        for(int i=1;i<=n;i++){
                int ans=0;
                int ii=i;
                while(ii!=0){
                        ans+=(ii%10);
                        ii/=10;
                }
                if(ans>=a&&ans<=b){
                        res+=i;
                }
        }
        cout<<res<<endl;
        return 0;
}


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

int id = INT_MAX;
int merge(int l, int r) {
	return min(l, r);
}

struct node {
	int val;
	int all;
	node *lch, *rch;
	int size;
	node(int v) : val(v), all(v), size(1) {
		lch = rch = nullptr;
	}
};

int count(node *t) { return t == nullptr ? 0 : t->size; }
int que(node *t) { return t == nullptr ? id : t->all; }
node *update(node *t) {
	t->size = count(t->lch) + count(t->rch) + 1;
	t->all = merge(que(t->lch), merge(t->val, que(t->rch)));
	return t;
}
node *merge(node *l, node *r) {
	if (l == nullptr || r == nullptr) return l == nullptr ? r : l;
	if (rand() % (l->size + r->size) < l->size) {
		l->rch = merge(l->rch, r);
		return update(l);
	}
	else {
		r->lch = merge(l, r->lch);
		return update(r);
	}
}
pair<node*, node*> split(node *t, int k) {
	if (t == nullptr) return make_pair(nullptr, nullptr);
	if (k <= count(t->lch)) {
		pair<node*, node*> s = split(t->lch, k);
		t->lch = s.second;
		return make_pair(s.first, update(t));
	}
	else {
		pair<node*, node*> s = split(t->rch, k - count(t->lch) - 1);
		t->rch = s.first;
		return make_pair(update(t), s.second);
	}
}
node *insert(node *t, int k, int v) {
	pair<node*, node*> s = split(t, k);
	node *r = merge(s.first, new node(v));
	r = merge(r, s.second);
	return r;
}
node *erase(node *t, int k) {
	pair<node*, node*> s1 = split(t, k), s2 = split(s1.second, 1);
	if (s2.first != nullptr) delete s2.first;
	return merge(s1.first, s2.second);
}
node *find(node *t, int k) {
	if (t == nullptr) return t;
	int c = count(t->lch);
	return k < c ? find(t->lch, k) : k == c ? t : find(t->rch, k - (c + 1));
}
int find(node *t, int l, int r) {
	if (t == nullptr) return id;
	if (r < 0 || l >= count(t)) return id;
	if (l <= 0 && r >= count(t)) return t->all;
	int c = count(t->lch);
	return merge(t->lch == nullptr ? id : find(t->lch, l, r), merge(l <= c && c < r ? t->val : id, t->rch == nullptr ? id : find(t->rch, l - (c + 1), r - (c + 1))));
}
int cnt(node *t, int v) {
	if (t == nullptr) return 0;
	if (t->val < v) return count(t->lch) + 1 + cnt(t->rch, v);
	if (t->val == v) return count(t->lch);
	return cnt(t->lch, v);
}
void print(node *t) {
	if (t == nullptr) return;
	print(t->lch);
	printf(" %d", t->val);
	print(t->rch);
}
node *shift(node *t, int l, int r) {
	pair<node*, node*> s1 = split(t, l), s2 = split(s1.second, r - l), s3 = split(s2.second, 1);
	return merge(s1.first, merge(s3.first, merge(s2.first, s3.second)));
}
void change(node *t, int k, int v) {
	if (t == nullptr) return;
	int c = count(t->lch);
	if (k < c) {
		change(t->lch, k, v);
		update(t);
	}
	else if (k > c) {
		change(t->rch, k - (c + 1), v);
		update(t);
	}
	else {
		t->val = v;
		update(t);
	}
}

int main()
{
	cin.sync_with_stdio(false);
	int n, q, x, y, z;
	cin >> n >> q;
	node *root = nullptr;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		root = insert(root, i, a);
	}
	while (q--) {
		cin >> x >> y >> z;
		if (x == 0) {
			root = shift(root, y, z);
		}
		else if (x == 1) {
			printf("%d\n", find(root, y, z + 1));
		}
		else {
			change(root, y, z);
		}
	}
	return 0;
}

Measured memory_bytes: 12584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    ll sum=0;
    cin >> n;
    vector<ll>a(n);
    vector<ll>ans(n,0);
    rep(i,n) {
        cin >> a[i];
        sum+=a[i];
    }
    sum/=2;
    int damu=0;
    ll x=0;
    while(damu<n-1){
        x+=a[damu];
        damu+=2;
    }
    ans[n-1]=(sum-x)*2;
    for(int i=n-2;i>=0;i--){
        ans[i]=(a[i]-ans[i+1]/2)*2;
    }
    rep(i,n){
        cout << ans[i] << " " ;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

string s;

int main()
{
    cin >> s;
    int cnt = s.size() - 2;
    bool flag = s[0] == s[s.size() - 1];
    if (flag == true)
    {
        cout << (cnt % 2 == 1 ? "Second" : "First") << "\n";
    }
    else
    {
        cout << (cnt % 2 == 0 ? "Second" : "First") << "\n";
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n; cin>>n;
    set<char> s;
    rep(i,n){
        char a;cin>>a;
        s.emplace(a);
    }
    int c = s.size();
    if(c==4)cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
}

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

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

  int64_t N, K;
  cin >> N >> K;
  int64_t A[N], F[N];
  rep(i, N){
    cin >> A[i];
  }
  sort(A, A+N);
  reverse(A, A+N);

  rep(i, N){
    cin >> F[i];
  }
  sort(F, F+N);

  pair<int64_t, int64_t> P[N];
  rep(i, N){
    P[i].first = A[i]*F[i];
    P[i].second = F[i];
  }
  sort(P, P+N);
  int64_t num = 0;
  int64_t left = -1, right = P[N-1].first, middle;
  while(right - left >= 2){
    middle = (left+right)/2;
    num = 0;
    for(int i=0;i<N;i++){
      num += max((int64_t)0, ((P[i].first + P[i].second - 1)-middle)/P[i].second);
    }
    if(num > K) left = middle;
    else right = middle;
  }


  cout << right << endl;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i = a:i<b;i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  int n;
  while (cin >> n){
    int ans = 0;
    vector<int> vi;
    REP(i,n){
      int a;
      cin >> a;
      vi.push_back(a);
    }

    sort(ALL(vi));
    reverse(ALL(vi));
    REP(i,n){
      if(i%2 == 0){
	ans += vi[i];
      }
      else{
	ans -= vi[i];
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:as)=foldr(+)0$map(f.length).group.sort.scanr(+)0$as
f i=i*(i-1)`div`2

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

int en;
string s;

int f(int p, int q) {
	int i, j;
	for(i=0, j=q; i<=j; i++, j--) {
		if(s[i] != s[j]) return 0;
	}
	return 1;
}

int main() {
	cin >> s;
	en = s.size() - 1;
	cout << (f(0, en) && f(0, en/2-1) && f(en/2+1, en) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a, b, c, d = 0;
    scanf("%d %d %d ",&a ,&b ,&c);
    int i;
    for(i = a; i <= b; i++){
        if(c % i == 0){
            d++;
        }
    }
    printf("%d\n", d);
    return 0;
}



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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 30;
ll fact[maxn];
ll pw(ll a, ll n){
  if(n == 0) return 1;
  ll b = pw(a, n>>1);
  b = b * b % mod;
  if(n & 1) b = b * a % mod;
  return b;
}

ll binom(int n, int k){
  assert(k >= 0 && k <= n);
  ll denom = fact[k] * fact[n-k] % mod;
  denom = pw(denom, mod-2) * fact[n] % mod;
  return denom;
}

ll perform(int x, int y){
  x--;
  y--;
  return binom(x+y, y);
}

int main(){
  fact[0] = 1;
  for(int i=1;i<maxn;i++){
    fact[i] = fact[i-1] * i % mod;
  }
  int r,c; cin >> r >> c;
  int a,b; cin >> a >> b;
  ll ans = 0;
  for(int i = b+1; i <= c; i++){
    ll v1 = perform(r-a, i);
    ll v2 = perform(c-i+1, a);
    ans += v1 * v2 % mod;
    ans %= mod;
  }
  cout << (mod + ans) % mod << "\n";
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string s, t;
    cin >> s >> t;
    vector<char> ls, lt;
    rep(i, s.size()) ls.push_back(s[i]);
    rep(i, t.size()) lt.push_back(t[i]);

    sort(all(ls));
    sort(all(lt), greater<char>());

    string s_, t_;
    rep(i, ls.size()) s_ += ls[i];
    rep(i, lt.size()) t_ += lt[i];
    //cout << "s_:" << s_ << " t_" << t_ << ln;

    if(s_ < t_) cout << "Yes" << ln;
    else cout << "No" << ln;
}
    

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

#define ll long long
#define mk make_pair
#define pb push_back


using namespace std;


int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   
   int N; cin >> N;
   int p;
   if(N % 2 == 0){
      p = N / 2;
   }else{
      p = (N / 2) + 1;
   }

   cout << p;
   
   return 0;
}


Measured memory_bytes: 256
import numpy as np

N, M, X = [int(x) for x in input().split()]

data = [[] for _ in range(N)]

for i in range(N):
    data[i] = [int(x) for x in input().split()]

ans = 12 * (10 ** 5) + 1
ok = False
for i in range(2 ** N):
    v = np.array([0] * (M + 1))
    for j in range(N):
        if (i >> j) & 1:
            v += np.array(data[j])
    x = min(list(v)[1:])
    if X <= x:
        ok = True
        ans = min(ans, v[0])

if ok == True:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 27200
#include <iostream>
int main()
{
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a == b || a == c || b == c)
  {
    if (a == b && b == c)
    {
      std::cout << "No";
      return 0;
    }
    else
    {
      std::cout << "Yes";
      return 0;
    }
  }
  
  std::cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'





int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
  
  int n,d;
  cin>>n>>d;
  d = d+d+1;
  cout<<(n+d-1)/d<<endl;



}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc112/tasks/abc112_c
import sys
n = int(input())
pyramid = []
ch = 1
for _ in range(n):
    x, y, h = map(int, input().split())
    pyramid.append((x, y, h))
    ch = max(ch, h)

def cal(cx, cy, ch, x, y, h):
    height = max(ch - abs(x - cx) - abs(y - cy), 0)
    return height == h

while True:
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            for x, y, h in pyramid:
                if not cal(cx, cy, ch, x, y, h):
                    break
            else:
                print(cx, cy, ch)
                sys.exit()
    ch += 1

Measured memory_bytes: 74936
import sys
n = int(sys.stdin.readline().rstrip("\n"))
result = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for _ in range(n):
    s = sys.stdin.readline().rstrip("\n")
    result[s] += 1
for r in result.keys():
    print(r+" x "+str(result[r]))

Measured memory_bytes: 68048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define maxn 305
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m;
queue<int>q[maxn];
int book[maxn];
int sum[maxn];
int ans=1e9;
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int x=read();
            q[i].push(x);
        }
    }
    int las=m;
    while(las)
    {
        memset(sum,0,sizeof(sum));
        for(int j=1;j<=n;j++)
          while(book[q[j].front()]==1)  q[j].pop();
        for(int j=1;j<=n;j++)   sum[q[j].front()]++;
        int maxx=0;
        for(int j=1;j<=m;j++)   maxx=max(maxx,sum[j]);
        ans=min(ans,maxx);
        for(int j=1;j<=m;j++)   if(sum[j]==maxx)  book[j]=1,las--;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  int J[2]={0,0};
  string S;
  cin >> S;
  int cou = 0;
  for(int i=0;i<4;i++){
    if(50 <= (int)S[i] && (int)S[i] <= 57){
      J[cou] = 1;
    }
    else{
      if((int)S[i] == 48 && S[i+1] != '0'){
        J[cou] = 2;
      }
      else if((int)S[i] == 48 && S[i+1] == '0'){
        J[cou] = 1;
      }
      else if((int)S[i] == 49 && 48 <= (int)S[i+1] && (int)S[i+1] < 51){
        J[cou] = 2;
      }
      else if((int)S[i] == 49 && 51 <= (int)S[i+1]){
        J[cou] = 1;
      }
    }
    cou++;
    i++;
  }
  if(J[0] == 1){
    if(J[1] == 1){
      cout << "NA" << endl;
    }
    else{
      cout << "YYMM" << endl;
    }
  }
  else{
    if(J[1] == 1){
      cout << "MMYY" << endl;
    }
    else{
      cout << "AMBIGUOUS" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
function main(){
  var localInput = input;
  var f = [
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ];
  
  var len = localInput.length - 1;
  for(;len--;){
    var l = localInput[len];
    var ix = parseInt(l[0]) + 2;
    var iy = parseInt(l[2]) + 2;
    switch(l[4]){
    case '3': // no-break case;
      f[iy+2][ix]++;
      f[iy-2][ix]++;
      f[iy][ix-2]++;
      f[iy][ix+2]++;
    case '2':
      f[iy+1][ix-1]++;
      f[iy+1][ix+1]++;
      f[iy-1][ix-1]++;
      f[iy-1][ix+1]++;
    case '1':
      f[iy+1][ix]++;
      f[iy][ix-1]++;
      f[iy][ix]++;
      f[iy][ix+1]++;
      f[iy-1][ix]++;
      break;
    }
  }
  
  var nd=0;//not dropped
  var md=0;//most dropped
  var y = 10;
  for(;y--;){
    var x = 10;
    for(;x--;){
      nd += !(f[y+2][x+2]);
      md = mx(f[y+2][x+2], md);
    }
  }
  
  console.log(nd);
  console.log(md);
}
   
function mx(a, b){
 var t = (a-b);
 return a - (t & (t >> 31));
}

var
input = '';
  
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 7648
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
#n,x= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しに4 3sum変数使用はsum関数使用できないので注意
a = n//100
b = n%100
leftmonth = 0
rightmonth = 0
if 0 < a < 13: leftmonth = 1
if 0 < b < 13: rightmonth = 1
if leftmonth and rightmonth:
    print("AMBIGUOUS")
elif leftmonth:
    print("MMYY")
elif rightmonth:
    print("YYMM")
else:
    print("NA")

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

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

    auto stones = vector<int>(N);
    for (auto& x : stones) cin >> x;

    auto adjacency_list = vector<vector<int>>(N);
    for (auto i = 0; i < N-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    const function<bool(int, int)> dfs = [&](const int v, const int parent)
    {
        if (adjacency_list[v].size() == 1) return true;

        auto counts = vector<int>();
        for (auto child : adjacency_list[v]) if (child != parent)
        {
            if (!dfs(child, v)) return false;
            else counts.push_back(stones[child]);
        }

        const auto sum = accumulate(begin(counts), end(counts), 0LL);
        const auto max = *max_element(begin(counts), end(counts));
        const auto internal = sum - stones[v], external = 2*stones[v] - sum;
        const auto bound = max >= sum-max ? sum-max : sum/2;
        stones[v] = int(external);
        return 0 <= internal && internal <= bound && 0 <= external;
    };

    if (N == 2)
    {
        cout << (stones[0] == stones[1] ? "YES" : "NO") << endl;
    }
    else
    {
        auto root = 0;
        while (adjacency_list[root].size() == 1) root++;
        cout << (dfs(root, -1) && stones[root] == 0 ? "YES" : "NO") << endl;
    }
}


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

using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>
int main(void){
    int i,j,k;
    int N;
    scanf("%d",&N);
    int C[N],S[N],F[N];
    for(i=1;i<N;i++){
        scanf("%d %d %d",&C[i],&S[i],&F[i]);
    }
    int T[N+1];
    for(i=N-1;i>=1;i--){
        T[i] = 0;
        for(j=i;j<=N-1;j++){
            if(T[i] >= S[j]){
                if(T[i]%F[j]==0){
                    T[i] += C[j];
                }else{
                    T[i] += F[j] - (T[i] % F[j]) +C[j];    
                }
            }else{
                T[i] += (S[j] - T[i]) + C[j];
            }
        }
    }
    
    T[N] = 0;
    
    for(i=1;i<=N;i++)printf("%d\n",T[i]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e5+5;
vector<ll> v[N];
ll dp[N][2];//black - white
void dfs(ll idx, ll par)
{
	dp[idx][0] = dp[idx][1] = 1;
	for(ll i = 0; i < v[idx].size(); i++)
	{
		ll child = v[idx][i];
		if(child != par)
		{
			dfs(child, idx);
			dp[idx][0] = dp[idx][0] * (dp[child][0] + dp[child][1]) % mod;
			dp[idx][1] = dp[idx][1] * dp[child][0] % mod;
		}
	}
}
int main()
{
	sync;
	ll n;
	cin >> n;
	for(ll i = 0; i < n - 1; i++)
	{
		ll x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1, 0);
	cout << (dp[1][0] + dp[1][1]) % mod;
}
	

Measured memory_bytes: 17524
#!/usr/bin/env python3

import collections
import sys

def read_prob():
    inputs = []
    try:
        while True:
            line = input().strip().split()
            a, b = line[0], line[1]
            inputs.append(int(a) + int(b))
    except EOFError:
        pass
    return inputs

if __name__ == '__main__':
    inputs = read_prob()
    for inp in inputs:
        answer = len(str(inp))
        print(answer)



Measured memory_bytes: 5992
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

s = 0
for line in stdin:
    digit = bytearray()
    for c in line:
        if c.isdigit():
            digit.append(c)
        elif digit:
            s += int(digit)
            digit = bytearray()

print(s)

Measured memory_bytes: 4236
ax, va = [int(v) for v in input().split()]
bx, vb = [int(v) for v in input().split()]
t = int(input())

if vb >= va:
    print("NO")
else:
    vd = va - vb
    x = abs(ax - bx)
    if x <= vd * t:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 61688
d = {}
d['a'] = [c for c in input().strip()]
d['b'] = [c for c in input().strip()]
d['c'] = [c for c in input().strip()]
master = 'a'

while True:
    if len(d[master]) == 0:
        print(master.upper())
        break

    master = d[master].pop(0)


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

int main(){
    vector<vector<int>> A(3,vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>A[i][j];
        }
    }
    int N; cin>>N;
    int b[N];
    for(int k=0;k<N;k++){
        cin>>b[k];
    }
    for(int k=0;k<N;k++) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (b[k] == A[i][j]) {
                    A[i][j] = 0;
                }
            }
        }
    }
    bool can=false;
    for(int i=0;i<3;i++){
        if(A[i][0]==0&&A[i][1]==0&&A[i][2]==0){
            can=true;
        }
        if(A[0][i]==0&&A[1][i]==0&&A[2][i]==0){
            can=true;
        }
        if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0){
            can=true;
        }
        if(A[0][2]==0&&A[1][1]==0&&A[2][0]==0){
            can = true;
        }
    }
    if(can){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

N, M, X, Y = map(int, raw_input().split())
x = map(int, raw_input().split()) + [X]
y = map(int, raw_input().split()) + [Y]

print "No War" if max(x) < min(y) else "War"

Measured memory_bytes: 2812
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

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

using namespace std;

int n;
int g[100][100];

vector<pair<int, int> > computeSpanningTree(std::vector<pair<int, pair<int, int> > >& edges){
  class UnionFind{
  public:
    UnionFind(int n){
      for(int i = 0; i < n; ++i){
        parent.push_back(i);
      }
      rank.resize(n, 0);
    }

    bool same(int a, int b){
      return find(a) == find(b);
    }

    void unite(int a, int b){
      int p = find(a), q = find(b);

      // assume that p != q

      if(rank[p] > rank[q]){
        parent[q] = p;
      }
      else{
        parent[p] = q;
        
        if(rank[p] == rank[q]){
          ++rank[q];
        }
      }
    }

  private:
    int find(int a){
      return a == parent[a] ? a : parent[a] = find(parent[a]);
    }

  private:
    vector<int> parent, rank;
  };

  class Indexer{
  public:
    int add(int p){
      if(indexer.find(p) == indexer.end()){
        int new_id = indexer.size();
        indexer[p] = new_id;
      }
      return indexer[p];
    }

  private:
    std::map<int, int> indexer;
  };

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

  Indexer id;
  UnionFind uf(edges.size() * 2);

  vector<pair<int, int> > result;
  for(int i = 0; i < edges.size(); ++i){
    int from = edges[i].second.first;
    int to = edges[i].second.second;

    int a = id.add(from);
    int b = id.add(to);

    if(!uf.same(a, b)){
      result.push_back(make_pair(from, to));
      uf.unite(a, b);
    }
  }

  return result;
}

int main(){
	scanf("%d", &n);
	rep(i, n){
		rep(j, n){
			scanf("%d", &g[i][j]);
		}
	}

	std::vector<pair<int, pair<int, int> > > gr;
	rep(i, n){
		for(int j = i; j < n; ++j){
			if(g[i][j] != -1){
				gr.push_back(make_pair(g[i][j], make_pair(i, j)));
			}
		}
	}
	vector<pair<int, int> > edge = computeSpanningTree(gr);
	int s = 0;
	rep(i, edge.size()){
		s += g[edge[i].first][edge[i].second];
	}
	printf("%d\n", s);
	return 0;
}

Measured memory_bytes: 1220
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll n;
    vector<ll> v(100010);
    cin>>n;
    rep(i,0,n){
        ll a;
        cin>>a;
        v[a]++;
        v[a+1]++;
        v[a+2]++;
    }
    ll ans=0;
    rep(i,0,100010){
        ans=max(ans,v[i]);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int p[100001] = { 0 };

	p[3] = 1;
	p[5] = 1;
	
	for (int k = 7; k <= 100001; k += 2) {
		int u = 3;
		while (u <= sqrt(k)) {
			if (k % u == 0)
				break;
			else
				u += 2;
		}
		if (u > sqrt(k)) {
			int w = 3;
			int x = (k + 1) / 2;
			if (x % 2 == 1) {
				while (w <= sqrt(x)) {
					if (x % w == 0)
						break;
					else
						w += 2;
				}
				if (w > sqrt(x))
					p[k] = 1;
			}
		}
	}

	for (int i = 0; i < 100000; i++)
		p[i + 1] += p[i];

	int q = 0, l = 0, r = 0;

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> l >> r;
		cout << p[r] - p[l - 1] << endl;
	}

	return 0;
}

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

int main() {
  	long long int m,n;
 	cin >> n;
  	m = 1000000000000001;
  
 	int amari;
  	string ans;
  
  	while(n  > 0)
    {
      
      amari = n % 26;

      n = (n-1)/26;
        if(amari == 0){ans  = "z" + ans;}
        if(amari == 1){ans = "a" + ans;}
        if(amari == 2){ans = "b" + ans;}
      	if(amari == 3){ans = "c" + ans;}
        if(amari == 4){ans = "d" + ans;}
      	if(amari == 5){ans = "e" + ans;}
        if(amari == 6){ans = "f" + ans;}
      	if(amari == 7){ans = "g" + ans;}
        if(amari == 8){ans = "h" + ans;}
      	if(amari == 9){ans = "i" + ans;}
        if(amari == 10){ans = "j" + ans;}
      	if(amari == 11){ans = "k" + ans;}
        if(amari == 12){ans = "l" + ans;}
        if(amari == 13){ans = "m" + ans;}
        if(amari == 14){ans = "n" + ans;}
        if(amari == 15){ans = "o" + ans;}
        if(amari == 16){ans = "p" + ans;}
      	if(amari == 17){ans = "q" + ans;}
        if(amari == 18){ans = "r" + ans;}
      	if(amari == 19){ans = "s" + ans;}
        if(amari == 20){ans = "t" + ans;}
      	if(amari == 21){ans = "u" + ans;}
        if(amari == 22){ans = "v" + ans;}
      	if(amari == 23){ans = "w" + ans;}
        if(amari == 24){ans = "x" + ans;}
      	if(amari == 25){ans = "y" + ans;}

    

    }
  

  
  /*
  
         if(amari == 1){ans = "a" + ans;}
        if(amari == 2){ans = "b" + ans;}
      	if(amari == 3){ans = "c" + ans;}
        if(amari == 4){ans = "d" + ans;}
      	if(amari == 5){ans = "e" + ans;}
        if(amari == 6){ans = "f" + ans;}
      	if(amari == 7){ans = "g" + ans;}
        if(amari == 8){ans = "h" + ans;}
      	if(amari == 9){ans = "i" + ans;}
        if(amari == 10){ans = "j" + ans;}
      	if(amari == 11){ans = "k" + ans;}
        if(amari == 12){ans = "l" + ans;}
        if(amari == 13){ans = "m" + ans;}
        if(amari == 14){ans = "n" + ans;}
        if(amari == 15){ans = "o" + ans;}
        if(amari == 16){ans = "p" + ans;}
      	if(amari == 17){ans = "q" + ans;}
        if(amari == 18){ans = "r" + ans;}
      	if(amari == 19){ans = "s" + ans;}
        if(amari == 20){ans = "t" + ans;}
      	if(amari == 21){ans = "u" + ans;}
        if(amari == 22){ans = "v" + ans;}
      	if(amari == 23){ans = "w" + ans;}
        if(amari == 24){ans = "x" + ans;}
      	if(amari == 25){ans = "y" + ans;}
        */

	cout << ans << endl;
 
}

Measured memory_bytes: 3600
#![allow(unused_imports)]
#![allow(dead_code)]

use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: i64 = sc.read();
    if n == 3 {
        println!("2 5 63");
        return;
    }
    let mut ans: Vec<i64> = vec![2, 3];
    let mut prefix: Vec<(i64, i64)> = vec![(0, 0); 30];
    for i in 4..30 {
        for j in i + 1..30 {
            if gcd(i, 30) != 1 && gcd(j, 30) != 1 {
                prefix[(i + j) as usize % 30] = (i, j);
            }
        }
    }
    let mut sum: i64 = 5;
    for i in 30..30001 {
        if ans.len() == (n - 2) as usize {
            break;
        }
        if gcd(i, 30) != 1 {
            sum += i;
            ans.push(i);
        }
    }
    let rem = (30 - sum % 30) % 30;
    ans.push(prefix[rem as usize].0);
    ans.push(prefix[rem as usize].1);
    for e in ans.iter() {
        print!("{} ", e)
    }
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

using namespace std;

int main() {
    int a, b;
    cin>>a>>b;
    if(a==1) a=14;
    if(b==1) b=14;
    if(a>b) cout<<"Alice";
    else if(b>a) cout<<"Bob";
    else cout<<"Draw";
}


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

int n;
string s;

int main() {
    cin >> s;
    n = s.size();

    int k = 0;
    long long ans = 0;
    for (int i=0; i<n; i++) if (s[i] == 'W') {
        ans += i - k;
        k++;
    }

    cout << ans;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int a,b,c,d;

int main(){
	cin >> a >> b >> c >> d;
	
	if(a+b==c+d) cout << "Balanced" << endl;
	else if(a+b>c+d) cout << "Left" << endl;
	else cout << "Right" << endl;
	return 0;
}


Measured memory_bytes: 256
# ARC086C - Not so Diverse (ABC081C)
n, k = list(map(int, input().rstrip().split()))
lst = sorted(list(map(int, input().rstrip().split())))
dic = {}
for i in lst:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1

cnt = sorted([i for i in dic.values()], reverse=True)
print(n - sum(cnt[:k]))

Measured memory_bytes: 33696
#include<stdio.h>

int main(){
  int A = 0; //容器１の最大値
  int B = 0; //容器１に入っている水の量
  int C = 0; //容器2に入っている水の量
  
  scanf("%d %d %d",&A,&B,&C);
  
  while(C > 0 && A > B){
    B++;
    C--;
  }
  
  printf("%d",C);
  
  return 0;
}

Measured memory_bytes: 128
N = int(input())
TA = []
 
for _ in range(N):
    TA.append([int(x) for x in input().split()])
 
x, y = TA[0]
 
for i in range(1, N):
    X, Y = TA[i]
    if X < x or Y < y:
        mul = max(x // X + (x % X != 0), y // Y + (y % Y != 0))
        x, y = X * mul, Y * mul
    else:
        x, y = X, Y
    #print(x, y)
 
print(x + y)

Measured memory_bytes: 39152
# ABC109C - Skip
from fractions import gcd


def main():
    N, X, *A = map(int, open(0).read().split())
    ans = abs(X - A[0])
    for i in A:
        dif = abs(X - i)
        if dif % ans:
            ans = gcd(ans, dif)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 16080
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;

    int res = 1;
    string prev = s.substr(0, 1);
    for (int i = 1, len = 1; i < static_cast<int>(s.size()); i++, len++) {
        if (prev != s.substr(i - len + 1, len)) {
            prev = s.substr(i - len + 1, len);
            len = 0;
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main(){
	double num[21][2];
	int r=1;
	while(scanf("%lf,%lf",&num[r][0],&num[r][1])!=EOF){
		r++;
	}
	double ans=0.0;
	for(int i=2;i<r-1;i++){
		double a,b,c;
		a=sqrt((num[i][0]-num[1][0])*(num[i][0]-num[1][0])+(num[i][1]-num[1][1])*(num[i][1]-num[1][1]));
		b=sqrt((num[i+1][0]-num[1][0])*(num[i+1][0]-num[1][0])+(num[i+1][1]-num[1][1])*(num[i+1][1]-num[1][1]));
		c=sqrt((num[i][0]-num[i+1][0])*(num[i][0]-num[i+1][0])+(num[i][1]-num[i+1][1])*(num[i][1]-num[i+1][1]));
		double y=(a+b+c)/2.0;
		ans+=sqrt(y*(y-a)*(y-b)*(y-c));
	}
	printf("%f\n",ans);
}

Measured memory_bytes: 1236