akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Get a number from stdio and convert it
	sc.Split(bufio.ScanWords)
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	result := 0
	for i > 0 {
		if i/100000 != 0 {
			i = i - 1
		} else if i/10000 != 0 {
			if i == 10000 {
				result++
				i--
				continue
			}
			result += ((i/10000)-1)*10000 + (i % 10000) + 1 //just 10000
			i = 999
		} else if i/1000 != 0 {
			i = 999
		} else if i/100 != 0 {
			if i == 100 {
				result++
				i--
				continue
			}
			result += ((i/100)-1)*100 + (i % 100) + 1 //just 100
			i = i % 100
		} else if i/10 != 0 {
			result += 9
			break
		} else {
			if result != 0 {
				result += 9
			} else {
				result += i
			}
			break
		}
	}
	fmt.Println(result)
}

Measured memory_bytes: 640
# - coding : utf-8 -*-
import numpy as np

def mean_temp(t, x):
    temp = t - x * 0.006
    return temp

def getNearestIdx(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

if __name__ == '__main__':
    n = int(raw_input())
    t, a = map(int, raw_input().split())
    hs = map(int, raw_input().split())

    result = []
    for h in hs:
        result.append(mean_temp(t, h))
    output = getNearestIdx(result, a) + 1
    print output

Measured memory_bytes: 19056
#include<set>
#include<map>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>

#define	pf	push_front
#define	pb	push_back
#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

int not3(int p)
{
	int res[3]={2,1,0};
	return res[p];
}

int or3(int p,int q)
{
	int res[3][3]={{0,1,2},{1,1,2},{2,2,2}};
	return res[p][q];
}

int and3(int p,int q)
{
	int res[3][3]={{0,0,0},{0,1,1},{0,1,2}};
	return res[p][q];
}

string subst(string x,int p,int q,int r)
{
	for(int i=0;i<x.length();i++){
		switch(x[i]){
			case 'P':	x[i]=p+'0';	break;
			case 'Q':	x[i]=q+'0';	break;
			case 'R':	x[i]=r+'0';	break;
		}
	}
	return x;
}

int satisfy(string x,int p,int q,int r)
{
	int len=x.length();

	if(x[0]=='(' && x[len-1]==')'){
		bool chk=true;
		for(int i=1,d=1;i<len-1;i++){
			if(x[i]=='(')	d++;
			if(x[i]==')')	d--;
			if(d==0)	chk=false;
		}
		if(chk)	return satisfy(x.substr(1,len-2),p,q,r);
	}

	int divpos=-1;
	for(int i=0,d=0;i<len;i++){
		if(x[i]=='(')	d++;
		if(x[i]==')')	d--;
		if(d==0){
			if(x[i]=='-' && divpos==-1)	divpos=i;
			if(x[i]=='+')	divpos=i;
			if(x[i]=='*')	divpos=i;
		}
	}

	if(divpos!=-1){
		switch(x[divpos]){
			case '-':
				return not3(satisfy(x.substr(divpos+1),p,q,r));
			case '+':
				return  or3(satisfy(x.substr(0,divpos),p,q,r),satisfy(x.substr(divpos+1),p,q,r));
			case '*':
				return and3(satisfy(x.substr(0,divpos),p,q,r),satisfy(x.substr(divpos+1),p,q,r));
		}
	}
	else{
		return x[0]-'0';
	}
}

int main()
{
	for(string x;cin>>x,x!=".";){
		int cnt=0;
		for(int p=0;p<3;p++)for(int q=0;q<3;q++)for(int r=0;r<3;r++)
			cnt+=satisfy(subst(x,p,q,r),p,q,r)==2?1:0;
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 1; i < n; i++) {
            int value = sc.nextInt();
            arr[value - 1]++;
        }
        for (int i = 0; i < n; i++) {
            System.out.println(arr[i]);
        }
    }
}


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

int main() {
  int x, y;
  cin >> x >> y;
  int ans;
  if(x==y) {
    cout << 0 << endl;
    return 0;
  }
  if(x==-y) {
    cout << 1 << endl;
    return 0;
  }
  if(abs(x)>abs(y)) {
    ans = abs(x)-abs(y);
    if(x>0) ans++;
    if(y>0) ans++;
    cout << ans << endl;
    return 0;
  }
  else {
    ans = abs(y)-abs(x);
    if(x<0) ans++;
    if(y<0) ans++;
    cout << ans << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int N;
	cin >> N;
	int Ans = 0;

	for (int i = 1; i <= N; i=i+2) {
		int count = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0) count++;
		}
		if (count == 8) Ans++;
	}

	cout << Ans;

	return 0;
}


Measured memory_bytes: 256
#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 = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); 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(){
    ll n; cin >> n;
    ll cnter[10][10];rep(i, 10)rep(j, 10)cnter[i][j] = 0;//first, last

    rept(i, 1, n+1){
        string s = to_string(i);
        int first = s[0] - '0', last = s.back() - '0';
        cnter[first][last]++;
    }
    ll sum = 0;
    rept(i, 1, n+1){
        string s = to_string(i);
        int first = s[0] - '0', last = s.back() - '0';
        sum += cnter[last][first];        
    }
    cout << sum << ln;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,ans;

signed main() {
    cin >> n;
    int hoge = (int)sqrt(n);
    rep1(i,hoge) {
        int tmp = (n-i)/i;
//        cout << tmp << endl;
        if (!tmp) continue;
        if (n/tmp == n%tmp) ans += tmp;
    }
    cout << ans << endl;
}












Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

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



Measured memory_bytes: 3096
n=int(input())
a=0
b=0
flag=0
while a<=n and flag==0:
    b=0
    while b<=(n-a):
        if b+a==n:
            print("Yes")
            flag=1
            break
        b=b+7
    a=a+4
    
if flag==0:
    print("No")

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

void init(vector<int>& V){
    int tmp;
    for (int i = 0; i < 6; i++){
    cin >> tmp;
    V.push_back(tmp);
    }
}

void move_N(vector<int>& V){
    int tmp_zero = V[0];
    V[0] = V[1];
    V[1] = V[5];
    V[5] = V[4];
    V[4] = tmp_zero;
    }

void move_E(vector<int>& V){
    int tmp_zero = V[0];
    V[0] = V[3];
    V[3] = V[5];
    V[5] = V[2];
    V[2] = tmp_zero;
}

void move_W(vector<int>& V){
    int tmp_zero = V[0];
    V[0] = V[2];
    V[2] = V[5];
    V[5] = V[3];
    V[3] = tmp_zero;
}

void move_S(vector<int>& V){
    int tmp_zero = V[0];
    V[0] = V[4];
    V[4] = V[5];
    V[5] = V[1];
    V[1] = tmp_zero;
}

int main(){
    string moves; 
    vector<int> values;
    init(values);
    cin >> moves;
    for (int i=0; i < moves.length();i++){
        if (moves[i] == 'N'){
            move_N(values);
        } else if (moves[i] == 'E'){
            move_E(values);
        } else if (moves[i] == 'W'){
            move_W(values);
        } else if (moves[i] == 'S'){
            move_S(values);
        } else {
            cout << "illegal input" << endl;
            return 0;
        }
    }
    cout << values[0] << endl;
    return 0;
}


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b)*b);
}


int main() {
    int K,A,B;
    cin >> K >> A >> B;

    bool flag = false;
    for (int i = A; i <= B; i++)
    {
        if(i % K == 0) flag = true;
    }
    


    string ans = ( flag ? "OK":"NG");
    cout << ans;
    //printf("%.8lf", ans);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
	static char[][]hw;
	static long[][]memo;
	static int h,w;
	
	public static long dp(int i,int j) {
		
		if(i==h-1&&j==w-1)
			return 1l;
		if(i==h||j==w)
			return 0l;
		 if(memo[i][j]!=-1)
			 return memo[i][j];
		 if(i+1<h&&j+1<w&&hw[i+1][j]=='.'&&hw[i][j+1]=='.')
			return memo[i][j] =(dp(i+1,j)+dp(i,j+1))%1000000007l;
		 if(i+1<h&&hw[i+1][j]=='.')
			return memo[i][j] = dp(i+1,j);
		 if(j+1<w&&hw[i][j+1]=='.')
		return memo[i][j] =dp(i,j+1);
		return  memo[i][j] =0;
		
		
		
	}
	public static void main (String[]args) {
		Scanner sc=new Scanner(System.in);
		h=sc.nextInt();
		w=sc.nextInt();
		hw=new char [h][w];
		for(int i=0;i<hw.length;i++) {
			
			
				hw[i]=sc.next().toCharArray();
			
			}
			memo=new long[h][w];
			for(long[]x:memo)
				Arrays.fill(x,-1);
			
		
		
		System.out.println(dp(0,0));
		
		
		
		
	}
}

Measured memory_bytes: 56336
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let a = nextIntArray()
    let b = nextIntArray()
    let c = nextIntArray()
    let ans = 0
    for(let i = 0;i<a.length; i++){
        ans += b[a[i]-1]
        if(a[i]+1 == a[i+1]) ans += c[a[i]-1]
    }
    console.log(ans)
}
Main()


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  
  int answer = 0;
  for(int i = 0; i < n; i++) {
    answer += a.at(i) - 1;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
import sys
import itertools
import math

"""
B - Five Dishes
https://atcoder.jp/contests/abc123/tasks/abc123_b
"""


def order(order_list):
    t1 = math.ceil(order_list[0] / 10) * 10
    t2 = t1 + math.ceil(order_list[1] / 10) * 10
    t3 = t2 + math.ceil(order_list[2] / 10) * 10
    t4 = t3 + math.ceil(order_list[3] / 10) * 10
    t5 = t4 + order_list[4]
    return t5


if __name__ == '__main__':
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    all_order = sorted([a, b, c, d, e])

    all_cases = list(itertools.permutations(all_order))

    min_time = sys.maxsize

    for e in all_cases:
        time = order(e)
        if time < min_time:
            min_time = time

    print(min_time)


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

int main(void){
    string N;
    int i=0,sum=0;
    cin>>N;
    while(N[i]!='\0'){
        sum=(sum+(int)(N[i])-48)%9;
        i++;
    }
    if(sum%9==0){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];
  ll ans = 0;
  for (ll i = N - 1; i >= 0; i--) {
    if (0 == (A[i] + ans) % B[i]) continue;
    ans += B[i] - (A[i] + ans) % B[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    //すべての文字列を左右反転する
    reverse(S.begin(), S.end());
    for(int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    //端から切っていく
    bool can = true;
    for(int i = 0; i < S.size();) {
        bool can2 = false;  //4個の文字列のどれかでdivideできるか
        for(int j = 0; j < 4; ++j) {
            string d = divide[j];
            if(S.substr(i, d.size()) == d) { //dでdivideできたら
                can2 = true;
                i += d.size(); //iを増加する
            }
        }
        if(!can2) { //できなかったら
            can = false;
            break;
        }
    }

    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 512
MOD = 10**9+7

N,M=map(int,input().split())
A=[0]*M
for i in range(M):
    A[i] = int(input())

dp = [0]*(N+4)
dp[0] = 1
for a in A:
    dp[a] = -1

for i in range(1,N+1):
    if dp[i] != -1:
        if dp[i-2] != -1:
            dp[i] += dp[i-2]
        if dp[i-1] != -1:
            dp[i] += dp[i-1]
        dp[i] = dp[i] % MOD

print(dp[N])

Measured memory_bytes: 7668
#include <stdio.h>

int t, five, seven;

int main(void)
{
  int i;
  
  for (i = 0; i < 3; ++i)
  {
	scanf("%d", &t);
    if (t == 5) five++;
    else if (t == 7) seven++;
  }
  
  printf((five == 2 && seven == 1) ? "YES" : "NO");
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(1000000000)
def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f
def main():
    N = int(input())
    X = input()
    d = {}
    dd = {}
    x1 = X.count('1')
    xn = int(X, 2)
    def hoge(i):
        if i in dd:
            return dd[i]
        if i not in d:
            j = popcount(i)
            d[i] = i % j
            if d[i] == 0:
                dd[i] = 1
            else:
                dd[i] = 1 + hoge(d[i])
        return dd[i]
    if N == 1:
        if X == '1':
            print(0)
            return 0
        else:
            print(1)
            return 1
    if x1 == 1:
        xn1 = 0
    else:
        xn1 = xn % (x1-1)
    xn2 = xn % (x1 + 1)
    for i in range(N):
        if X[i] == '1':
            t = xn1
            if x1-1 == 0:
                print(0)
                continue
            t -= pow(2, N-1-i, x1-1)
            t %= (x1-1)
        else:
            t = xn2
            t += pow(2, N-1-i, x1+1)
            t %= (x1 + 1)
        if t == 0:
            print(1)
        else:
            print(1 + hoge(t))
main()


Measured memory_bytes: 13520
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n;
  map<int, int> mp;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] -= i;
    ++mp[a[i]];
  }
  int64 ans = 0;
  for (int i = 0; i < n; ++i) {
    auto it = mp.find(a[i]);
    --it->second;
    if (!it->second) {
      mp.erase(it);
    }
    it = mp.find(-a[i] - i - i);
    if (it != end(mp)) {
      ans += it->second;
    }
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 12588
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		int t = 1;
		while(t-->0) solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			int m = scan.nextInt(), d = scan.nextInt();
			int count = 0;
			for(int i = 1; i <= m; i++) {
				for(int j = 1; j <= d; j++) {
					int t = j/10;
					int o = j % 10;
					if(t >= 2 && o >= 2 && t * o == i) count++;
				}
			}
			out.println(count);
		}
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
	static void shuffle(long[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

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

}


Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int L[200];

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

	int N; cin >> N;
	for (int i = 0; i < 2*N; i++) cin >> L[i];
	sort(L, L + 2 * N);
	ll ans = 0;
	for (int i = 0; i < 2 * N; i += 2) ans += L[i];
	cout << ans << endl;

	return 0;
}

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

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

using namespace std;
using lint = long long;

int main(void)
{
    string S;
    cin >> S;
    
    int Q;
    cin >> Q;
    string X = "";
    rep(i, Q) X += "x";
    int fp = X.size()-1;
    int bp = X.size() + S.size();

    S = X + S + X;
    //cout << S << endl;
    int dir = 1;
    for(int i = 0; i < Q; i++){
        int T;
        cin >> T;
        if(T == 1){
            dir *= -1;
        }
        else{
            int F;
            char C;
            cin >> F;
            cin >> C;
            if(dir == 1 && F == 1){
                S[fp] = C;
                fp--;
            }
            else if(dir == 1 && F == 2){
                S[bp] = C;
                bp++;
            }
            else if(dir == -1 && F == 1){
                S[bp] = C;
                bp++;
            }
            else{
                S[fp] = C;
                fp--;
            }
        }
    }
    //cout << fp << " " << bp << endl;
     if(dir == 1){
            for(int i = fp+1; i < bp; i++){
                cout << S[i];
            }
            cout << endl;
        }
        else{
            //reverse(S.begin(), S.end());
            for(int i = bp-1; i > fp; i--){
                cout << S[i];
            }
            cout << endl;
        }
    
    return 0;
}

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

//最大公約数(引数の型に注意)
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}

//最小公倍数
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
 
int main() {
    int n;
    cin>>n;
    vector<ll> T(n);
    rep(i,n)cin>>T[i];
    if(n==1){
        cout<<T[0]<<endl;
        return 0;
    }
    ll ans=lcm(T[0],T[1]);
    for(int i=2;i<n;i++){
        ans=lcm(ans,T[i]);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int k, i, j;
    vector<string> v;
    set<string> st;
    string s;
    cin >> s >> k;
    for(i=0; i<s.length(); i++){
        for(j=0; j<k && i+j<s.length(); j++){
            v.push_back(s.substr(i, j+1));
        }
    }
    sort(v.begin(), v.end());
    i = 0;
    while(st.size() < k){
        st.insert(v[i]);
        i++;
    }
    cout << v[i-1] << "\n";
    return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
while(true){
int a = scan.nextInt();
char op = scan.next().charAt(0);
int b = scan.nextInt();

if(op == '?'){break;}

if(op == '+'){System.out.println(a + b);}

if(op == '-'){System.out.println(a - b);}

if(op == '*'){System.out.println(a * b);}

if(op == '/'){System.out.println(a / b);}
}}}

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

class Tree{
public:
    string s;
    vector<Tree*> children;
    
    Tree(string s, int idx);
    void add(int k, string s, int idx);
    void print(int depth);
};

map<int, Tree*> nodes;

Tree::Tree(string s, int idx): s(s){
    nodes[idx] = this;
}
void Tree::add(int k, string s, int idx){
    Tree *tree = new Tree(s, idx);
    nodes[k]->children.push_back(tree);
}
void Tree::print(int depth){
    for(int i=0; i<depth; i++)
        cout << ".";
    cout << s << endl;
    
    for(auto child: children){
        child->print(depth+1);
    }
}

int N;

int main(){
    cin >> N;
    
    int k;
    string s;
    
    cin >> k >> s; k;
    Tree tree(s, k);
    
    for(int i=0; i<N-1; i++){
        cin >> k >> s; k--;
        tree.add(k, s, i+1);
    }
    
    tree.print(0);
    
    return 0;
}

Measured memory_bytes: 3384
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int i,n,j;
	while(cin>>n>>i){
	j=n-i+1;
	cout<<j<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type
#define int long long
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << endl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << endl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << endl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << endl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod2 = 1e9+7;
const int MAX_N = 100005, MAX_M = 200010, INF = 1e18;
//
vector<pii> adj[MAX_N];
ll dist[MAX_N];
int N, M;
void Solve() {
    cin >> N >> M;
    for (int i = 2; i <= N; i++){
        adj[i].eb(i-1, 0);
        dist[i] = INF;
    }
    for (int i = 1, u, v, c; i <= M; i++){
        cin >> u >> v >> c;
        adj[u].eb(v, c);
		adj[v].eb(u, c);
    }
    
    priority_queue<pii, vector<pii>, greater<pii>> bfs;
    bfs.push(make_pair(0, 1));
    while (!bfs.empty()){
        int x = bfs.top().S, d = bfs.top().F; bfs.pop();
        if (d == dist[x]){				
			for (auto v:adj[x]){
				if (dist[v.F] > dist[x] + v.S){
					dist[v.F] = dist[x] + v.S;
					bfs.push(make_pair(dist[v.F], v.F));
				}
			}
		}
    }
    cout << ((dist[N] != INF) ? dist[N]:-1);
}

signed main(){
    FAST_IO;
    int TC = 1; 
	// cin >> TC;
    while(TC--) Solve();
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOREACH(element, vec_name) for (auto &(element) : (vec_name))

#define VECCIN(vec_name) for (auto &element : (vec_name)) cin >> element

#define dump(x) cout << #x << " = " << (x) << endl;

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

const int INF = 1e9;
const int MOD = 1e9+7;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }//最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }//最小公倍数

int GCD(vector<int> vec){ //多入力のGCD．入力はvectorとして与える
    int g = vec[0];
    FOREACH(element, vec){
        g = gcd(g, element);
    }
    return g;
}


int main()
{
    int h;
    int a;
    int ans = 1;
    cin >> h >> a;
    while(h > a){
        h -= a;
        ans++;
    }

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

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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    int right, left, top, bottom;
    right = x + r;
    left = x - r;
    top = y + r;
    bottom = y - r;
    if (top <= H && 0 <= bottom && 0 <= left && right <= W){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;
int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
int calc(int x,int y){
	int res=0;
	while(x){
		res+=(x%10);x/=10;
	}
	while(y){
		res+=(y%10);y/=10;
	}
	return res;
}
int main(){
	int n=read(),ans=1e9;
	for(int i=1;i<n;i++)ans=min(ans,calc(i,n-i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

print(' '.join(map(str, a)))
for i in range(1, n):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    print(' '.join(map(str, a)))



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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int k; cin>>k;
	int x=k/2;
	cout << x*(k-x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	
	char S[N];
	
	scanf("%s", S);
		
	if(S[K-1]=='A') S[K-1] = 'a';
	else if(S[K-1]=='B') S[K-1] = 'b';
	else	S[K-1] = 'c';

	printf("%s", S);
	
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;


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

    ll dp[101][2][101];
    rep(i,0,101) rep(j,0,2) rep(k,0,101) dp[i][j][k] = 0;

    dp[0][0][0] = 1;

    rep(i,0,n){
        rep(j,0,n){
            if(s[i] == '0'){
                dp[i+1][0][j] += dp[i][0][j];
            }
            else{
                dp[i+1][0][j+1] += dp[i][0][j];
                dp[i+1][1][j+1] += ((ll)(s[i] - '0') - 1)*dp[i][0][j];
                dp[i+1][1][j] += dp[i][0][j];
            }

            dp[i+1][1][j+1] += 9*dp[i][1][j];
            dp[i+1][1][j] += dp[i][1][j];
        }
    }

    cout << dp[n][0][k] + dp[n][1][k] << endl;
}


Measured memory_bytes: 3756
def counting_sort(A, B, k):
    C = [0 for _ in xrange(k+1)]
    for a in A:
        C[a] += 1

    for i in xrange(k):
        C[i] = C[i] + C[i-1]

    for i in xrange(n-1, -1, -1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1


n = int(raw_input())
A = map(int, raw_input().split())
B = [0 for _ in xrange(n)]

counting_sort(A, B, 10000)

print " ".join(map(str, B))

Measured memory_bytes: 202524
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,a[3],b,c,ans=0,cnt=0,tmp;
string s,t;
int main(){
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	ans+=a[1]-a[0];
	ans+=a[2]-a[1];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    int k, j;
    for(int i = 0; i < n; i = k){
        int x, y;
        j = i + 1;
        while(j < n && s[j] == 'R')
            j++;
        k = j + 1;
        while(k < n && s[k] == 'L')
            k++;
        x = j - i;
        y = k - j;
        ans[j - 1] = (x + 1) / 2 + y / 2;
        ans[j] = x / 2 + (y + 1) / 2;
    }
    for(int i = 0; i < n; i++)
        cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 3832
from collections import defaultdict
from heapq import heappush, heappop, heapify, heapreplace

class Solution:
    def main(self):
        N, M = map(int, input().split())
        K = []
        S = []
        for i in range(M):
            line = list(map(int, input().split()))
            k = line[0]
            s = line[1:]
            K.append(k)
            S.append(s)
        P = list(map(int, input().split()))
        on = [0] * N
        #print(on)
        #print(S)
        res = 0
        for _ in range(2**N):
            # print(on)
            for i in range(M):
                if sum([on[idx-1] for idx in S[i]]) % 2 != P[i]:
                    break
            else:
                res += 1
            self.increment(on, 0)
        print(res)

    def increment(self, array, i):
        if len(array) <= i:
            return array
        elif array[i] == 0:
            array[i] = 1
            return array
        else:
            array[i] = 0
            return self.increment(array, i+1)


if __name__ == '__main__':
    Solution().main()

Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
//------------------------------------------------------------
ll X;

void solve() {
  cin>>X;

  ll Y=100;
  ll count=0;

  while(X>Y)
  {
    Y = floor(Y + (Y*0.01));
    ++count;
  }

  print(count);

  return;
}


Measured memory_bytes: 3760
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut r:usize = read!();
    if n<10 {
        println!("{}",r+100*(10-n));
    }
    else {
        println!("{}",r);
    }
}

Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long int ll;

struct Edge{
	int to,rev; ll cap;
	Edge(int to,ll cap,int rev):to(to),cap(cap),rev(rev){}
};
// ここの値に注意！！
const int N=205000;
const ll INF=1e9;
vector<Edge> g[N];
int level[N]; 
int iter[N];
void add_edge(int s,int t,ll c){
	g[s].push_back(Edge(t,c,g[t].size()));
	g[t].push_back(Edge(s,0,g[s].size()-1));
}
void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> q;
	level[s]=0;
	q.push(s);
	while(q.size()){
		int v=q.front(); q.pop();
		for(auto &e:g[v]){
			if(e.cap>0&&level[e.to]<0){
				level[e.to]=level[v]+1;
				q.push(e.to);
			}
		}
	}
}
ll dfs(int v,int t,ll f){
	if(v==t)return f;
	for(int &i=iter[v];i<g[v].size();i++){
		Edge &e=g[v][i];
		if(e.cap>0&&level[v]<level[e.to]){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				g[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
ll max_flow(int s,int t){
	ll flow=0;
	while(1){
		bfs(s);
		if(level[t]<0)return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,INF))>0){
			flow+=f;
		}
	}
}

vector<int> gg[100100];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	for(int i=0;i<m;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		gg[x].push_back(y);
		gg[y].push_back(x);
		add_edge(x,y,1);
		add_edge(y,x,1);
	}
	int six=0;
	int four=0;
	vector<int> v;
	for(int i=0;i<n;i++){
		if(gg[i].size()%2){
			cout << "No" << endl;
			return 0;
		}
		if(gg[i].size()==6)six++;
		if(gg[i].size()==4){
			four++;
			v.push_back(i);
		}
	}
	if(six){
		cout << "Yes" << endl;
		return 0;
	}
	if(four>=3){
		cout << "Yes" << endl;
		return 0;
	}
	else{
		if(four==2){
			if(max_flow(v[0],v[1])==2){
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}else{
			cout << "No" << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 22528
import java.util.*;

public class Main {    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);          
           
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        if(C >= A && C <= B){
           System.out.println("Yes");
        }else{
           System.out.println("No");
        }                
         
    }            
}
        
       

Measured memory_bytes: 21588
import java.util.Scanner;
import java.lang.String;
public class Main{
	public static void main(String [] args){
    Scanner sc= new Scanner(System.in);
    String str1= sc.next();
    if(str1.endsWith("s"))
    {
    str1=str1+"es";
    }
    else
    {
    str1=str1+"s";
    }
    System.out.println(str1);
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int N;
    cin >> N;
    vector<ll> a(N), b(N);
    ll asum = 0, bsum = 0, dif = 0, cnt = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        asum += a[i];
    }
    priority_queue<ll> q;
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
        bsum += b[i];
        if (a[i] < b[i])
        {
            dif += b[i] - a[i];
            cnt++;
        }
        if (b[i] < a[i])
        {
            q.push(a[i] - b[i]);
        }
    }
    if (asum < bsum)
    {
        cout << -1 << endl;
        return 0;
    }
    while (dif > 0)
    {
        cnt++;
        dif -= q.top();
        q.pop();
    }
    cout << cnt << endl;
}


Measured memory_bytes: 2428
#include <iostream>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
	double x;
	while(cin>>x){
		double h = (5+4.9*x/9.8*x/9.8)/5;
		int y=0;
		while(y<h) y++;
		cout << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <cstring>
char str[10001];
int main() {
	while(scanf("%s",str)!=EOF) {
		int len=strlen(str);
		int joi=0,ioi=0;
		for(int i=0;i<len-2;i++) {
			if(str[i]=='J') {
				if(str[i+1]=='O'&&str[i+2]=='I')joi++;
			}else if(str[i]=='I') {
				if(str[i+1]=='O'&&str[i+2]=='I')ioi++;
			}
		}
		printf("%d\n%d\n",joi,ioi);
	}
}

Measured memory_bytes: 972
N, capW = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]
 
def knapsack01(items, capW):
    dp = [0] * (capW+1)
    for wi, vi in items:
        for w in reversed(range(wi, capW+1)):
            v0 = dp[w-wi] + vi
            if v0 > dp[w]:
                dp[w] = v0
    return max(dp)
 
print(knapsack01(items, capW))

Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,r;
	cin>>l>>r;
	int js=0;
	int d;
	cin>>d;
	for(int i=l;i<=r;i++)
	{
		if(i%d==0) js++;
	}
	cout<<js<<endl;
 } 

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" <<endl;
    else cout << "ABC" << endl;
    
    return 0;
}

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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<string> ans(h);

    rep(i, h)
    {
        rep(j, w)
        {
            int cnt = 0;
            if (s[i][j] == '.')
            {
                for (int k = -1; k <= 1; k++)
                {
                    for (int l = -1; l <= 1; l++)
                    {
                        if (i + k >= 0 && j + l >= 0 && i + k <= h - 1 && j + l <= w - 1)
                        {
                            if (s[i + k][j + l] == '#')
                            {
                                cnt++;
                            }
                        }
                    }
                }
                cout << cnt;
            }
            else
            {
                cout << '#';
            }
        }
        cout << endl;
    }
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

LL dp[2][200005];

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL d, g;cin >> d >> g;g /= 100;
    vector<LL> p(d), c(d);
    inc(i, 0, d){
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    inc(i, 0, 2){
        inc(j, 0, 200005){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    inc(i, 0, d){
        inc(k, 0, 200005){
            dp[(i+1)%2][k] = dp[i%2][k];
        }
        inc(j, 0, p[i]-1){
            inc(k, 0, 200005){
                if(dp[i%2][k] != INF){
                    if(k+(i+1)*(j+1) < 200005){
                        dp[(i+1)%2][k+(i+1)*(j+1)] = min(dp[(i+1)%2][k+(i+1)*(j+1)], dp[i%2][k]+(j+1));
                    }
                }
            }
        }
        inc(k, 0, 200005){
            if(k+(i+1)*p[i]+c[i] < 200005){
                dp[(i+1)%2][k+(i+1)*p[i]+c[i]] = min(dp[(i+1)%2][k+(i+1)*p[i]+c[i]], dp[i%2][k]+p[i]);
            }
        }
    }

    LL ans = INF;
    dec(i, g, 200005){
        ans = min(ans, dp[d%2][i]);
    }

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


Measured memory_bytes: 3328
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
amari = 0
for i in range(n):
         ans += min(a[i],amari+b[i])
         if amari > a[i]:
                  amari = b[i]
         else:
                  amari =max(0,(amari + b[i]) - a[i] )
         
ans += min(a[n],amari)
print(ans)


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

int main(){
  int a,b;scanf("%d%d",&a,&b);
  double ret=0;
  for(int i=1;i<=a;i++){
    double tmp=1.0/a;
    int now=i;
    while(now<b){
      now*=2;
      tmp/=2;
    }
    ret+=tmp;
  }
  printf("%.12f\n",ret);
}

Measured memory_bytes: 256
//AtCoder Beginner Contest 047 B問題
#include <bits/stdc++.h>
using namespace std;

int main(){
	int w,h,n;
	scanf("%d%d%d", &w,&h,&n);
	int aw1 = 0;
	int aw2 = w;
	int ah3 = 0;
	int ah4 = h;
	int x[n],y[n],a[n];
	for(int i=0; i<n; i++){
		scanf("%d%d%d", &x[i],&y[i],&a[i]);
	}
	for(int i=0; i<n; i++){
		if(a[i] == 1 && x[i] > aw1){
			aw1 = x[i];
		}
		if(a[i] == 2 && x[i] < aw2){
			aw2 = x[i];
		}
		if(a[i] == 3 && y[i] > ah3){
			ah3 = y[i];
		}
		if(a[i] == 4 && y[i] < ah4){
			ah4 = y[i];
		}
	}
	if(aw2-aw1 <= 0 || ah4-ah3 <= 0){
		printf("0\n");
	}
	else{
		printf("%d\n", (aw2-aw1)*(ah4-ah3));
	}

}

Measured memory_bytes: 256