akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X,Y;cin>>N>>X>>Y;
  vector<int> kazu(N,0);//最短がiのルート数
  for(int i=1;i<N;i++){
    for(int j=i+1;j<=N;j++){
      int a=min(j-i,abs(i-X)+abs(j-Y)+1);
      //cout<<i<<" "<<j<<" "<<j-i<<" "<<abs(i-X)+abs(j-Y)+1<<" "<<a<<endl;
      kazu[a]++;
    }
  }
  for(int i=1;i<N;i++)cout<<kazu[i]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve();
int main()
{
//	freopen("SNOOKER.inp","r",stdin);
//	freopen("SNOOKER.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}
/*----------------------------------------------------------------------
 
-----------------------------------------------------------------------*/
using ll =  long long;
#define endl "\n"
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define what_is(x)  cerr << #x << " is :" << (x) << endl
const int MOD =  1e9+7;
const ll inf = LLONG_MAX;
const int MAX_N = 1e5 + 7;

int n, max_weight;

ll wei[MAX_N], va[MAX_N], dp[107][MAX_N];
void solve()
{
	
	cin >> n >> max_weight;
	for(int i = 1; i <= n ; i++)
	{
		cin >> wei[i] >> va[i] ;
		//dp[i][0] = 0;
	}
	
	fill(dp[0], dp[0] + MAX_N, 0 );
	
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 0 ; j <= max_weight; j++)
		{
			dp[i][j]  =  dp[i-1][j] ;
			if(j >= wei[i])
			dp[i][j] = max(dp[i-1][j-wei[i]] + va[i], dp[i][j] ) ;
		}
	}
	
	cout << dp[n][max_weight];
}


Measured memory_bytes: 82176
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}
 
func input() string {
	sc.Scan()
	return sc.Text()
}
 
func main() {
	n, _ := strconv.Atoi(input())
	a := make([]int, 3*n)
	for i := 0; i < 3*n; i++ {
		a[i], _ = strconv.Atoi(input())
	}
	sort.Ints(a)
	a = a[n:]
 
	ans := 0
	for i := 0; i < n; i++ {
		ans += a[i*2]
	}
	fmt.Println(ans)
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum1,sum2;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    int ans=1e9;
    for(int i=0;i<n;i++)
    {
        sum1=0;
        sum2=0;
        for(int j=0;j<=i;j++)
        {
            sum1+=v[j];
        }
        for(int k=i+1;k<v.size();k++)
        {
            sum2+=v[k];
        }
        int diff=abs(sum1-sum2);
        ans=min(ans,diff);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W = br.readLine().toLowerCase();
		String END = "END_OF_TEXT";
		int cnt = 0;
		for(;;) {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(W)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 24224
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int D, N;
	cin >> D >> N;

	int ans = 0;

	if (N == 100) {
		N += 1;
		ans = N * pow(100, D);
	}
	else {
		ans = N * pow(100, D);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1 
#define BLACK 2
 
int n, M[N][N];
int color[N], d[N], f[N], tt; 

void dfs_visit(int u) {
	int v;
	color[u] = GRAY;
	d[u] = ++tt;
	for(v = 0; v < n; v++) {
		if(M[u][v] == 0) continue;
		if(color[v] == WHITE) {
			dfs_visit(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}

void dfs() {
	int u;
	for(u = 0; u < n; u++) color[u] = WHITE;
	tt = 0;
	
	for(u = 0; u < n; u++) {
		if(color[u] == WHITE) dfs_visit(u);
	}
	
	for(u = 0; u < n; u++) {
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}
}
 
int main() {
    int u, k, v, i, j;
    
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        M[i][j] = 0;
      } 
    }
    
    for(int i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        u--;
        for(int j = 0; j < k; j++ ) {
           scanf("%d", &v);
           v--;
           M[u][v] = 1; 
        }       
    }
     
     
    dfs();
     
    return 0;
}  

Measured memory_bytes: 2716
from itertools import permutations 

n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
a = 0
b = 0
cnt = 0
st = 0
for i in permutations(range(1,n+1)):
    cnt += 1
    if list(i) == p:
        a = cnt
        st += 1
    if list(i) == q:
        b = cnt
        st += 1
    if st == 2:
        break
    
print(abs(a-b))

Measured memory_bytes: 3064
import java.io.*;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    
    int count = 0;
    for(int i = 0; i < str.length(); i++) {
      count += str.charAt(i) == '+' ? 1 : -1;
    }
    
    System.out.println(count);
  }
}


Measured memory_bytes: 20692
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  set<string> ans;
  for (int i = 0; i < N; ++i) {
    string S;
    cin >> S;
    ans.insert(move(S));
  }
  cout << ans.size() << endl;
}


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


int main(void){

double r,m,l;
cin >> r;

m = (r *2) * 3.14159265358;
l = r * r * 3.141592653589;

 cout << std::fixed <<  std::setprecision(6) <<l  << " " << m << endl; 
// printf("%f %f\n", l,m);
}



Measured memory_bytes: 3268
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[1234][1234];
signed main() {
	ll n = 0, m = 0, k, l, cnt = 0, z = 0; string s; cin >> s;
	for (int h = 0; h < 3; h++) {
		if (s[h] == '1') { cnt++; }
	}
	cout << cnt << endl;
	cin >> n; return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    int s[M],c[M];
    for(int i=0; i<M; i++){
        cin >> s[i] >> c[i];
    }
    int ans=0;
    for(int i=0; i<999; i++){
        int Ni;
        if(i>99){
            Ni=3;
        }else if(i>9){
            Ni=2;
        }else{
            Ni=1;
        }

        if(Ni!=N) continue;

        bool flag=true;
        for(int j=0; j<M; j++){
            int tmp = (int) pow(10,N-s[j]);
            //cout << "tmp " << tmp << endl;
            int tmp2= i/(tmp);
            //cout << "tmp2 " << tmp2 << endl;
            tmp2 = tmp2%10;
            //cout << "tmp2-2 " << tmp2 << endl;
            if( c[j]!=tmp2 ){
                flag=false;
            }
        }
        if(flag){
            cout << i << endl;
            return 0;
        }

    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,ans=0;
int dis[16],got[16];
int o[17][17]; 
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		int x;cin>>x;
		memset (o[i],-1,sizeof(o[i]));
		for (int j=0;j<x;j++){
			int y,z;cin>>y>>z;
			o[i][y-1]=z;	
		}
	}
	for (int i=0;i<(1<<n);i++){
		memset (got,-1,sizeof(got));
		for (int j=0;j<n;j++){
			if ((1<<j)&i) got[j]=1;
			else got[j]=0;
		}
		int pt=0,ok=1;
		for (int j=0;j<n && ok;j++)if((1<<j)&i){
			pt++;
			for (int k=0;k<n && ok;k++){
				if (o[j][k]==-1 || o[j][k]==got[k]);
				else ok=0;
			}
		}
		if (ok) ans=max(ans,pt);
	}
	cout<<ans;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    printf("%s\n", (A1 + A2 + A3 <= 21) ? "win" : "bust");

    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
LL a[202020];

LL calc(LL mid) {
	LL ret = 0;
	REP(i, n) {
		ret += abs (a[i] - (mid + (i + 1LL)));
	}
	return ret;
}

int main() {
	cin >> n;
	REP(i, n)cin >> a[i];

	LL left = -INF, right = INF;
	REP(wtw,200) {
		LL midl = (left * 2LL + right) / 3LL;
		LL midr = (left + right * 2LL) / 3LL;
		LL vl = calc(midl);
		LL vr = calc(midr);
		if (vl < vr)right = midr;
		else left = midl;
	}
	LL ans = LINF;
	for (int i = -50; i <= 50; i++) {
		ans = min(ans, calc(i + left));
	}
	cout << ans << endl;

}

Measured memory_bytes: 1792
from collections import Counter
import sys
from random import randint
from time import time
start = time()
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline


def get_sat():
    sat = 0
    when = [-1] * 26
    for i in range(d):
        sat += s[i][t[i]]
        when[t[i]] = i
        for j in range(26):
            sat -= c[j] * (i - when[j])
    return sat


d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = [randint(0, 25) for i in range(d)]
ans = get_sat()
while time() - start < 1.8:
    p, q = randint(0, d - 1), randint(0, 25)
    x = t[p]
    t[p] = q
    y=get_sat()
    if ans >= y:
        t[p] = x
    else:
        ans=y
for i in t:
    print(i + 1)


Measured memory_bytes: 80984
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include "bits/stdc++.h"

#define fastio      ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
#define TC          int t; cin >> t; for(int tc = 1; tc <= t; tc++)
#define read        freopen("input.txt", "r", stdin);
#define write       freopen("output.txt", "w", stdout);
#define nl          '\n'
#define pii		    pair<int, int>
#define ll 		    long long
#define pb		    push_back
#define eb		    emplace_back
#define all(v)	    v.begin(), v.end()
#define rall(v)	    v.rbegin(), v.rend()
#define d(x)	    cerr << #x << " = " << x << nl


using namespace std;


int main() {
    int ans = 0;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'R') {
            int count = 0;
            while(s[i] == 'R') count++, i++;
            ans = max(ans, count);
        }
    }
    cout << ans << nl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

int cp(int x[], int y[]){
	return x[0]*y[1]-y[0]*x[1];
}

int next(int &idx, int n){
	++idx;
	idx%=n;
	return idx;
}

int main(){
	int n;
	cin >> n;
	int set = 0;
	while(n){
		int x[50][2];
		bool used[50];
		int s = 0;
		memset(used,false,sizeof(used));
		for(int i = 0; i < n; i++){
			cin >> x[i][0] >> x[i][1]; 
		}
		int idx = 0;
		int m = n;
		while(n>=3){
			int dx[2][2];
			int a;
			for(int i = 0; i < 2; i++){
				a = idx;
				while(used[next(idx,m)]);
				dx[i][0] = x[idx][0]-x[a][0];
				dx[i][1] = x[idx][1]-x[a][1];
			}
			s += cp(dx[0], dx[1]);
			used[a] = true;
			n--;
		}
		if(s<0) s*=-1;
		printf("%d %.1f\n",++set,(double)s/2);
		cin >> n;
	}
}

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

int main(){
    long long int N;
    cin >> N;
	if (N % 2 == 1){
      cout << 0 << endl;
      return 0;
    }
  	N /= 2;
    long long int ans;
	
  	long long int div;
    long long int tmp;
    for (int i = 50; i > 0; i--){
      	div = pow(5, i);
      	tmp = (long long int) N / div;
        ans += tmp;
    }
    cout << ans << endl;
  	return 0;

}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 5000000000000000007 //1e18+7
#define mk  make_pair
#define ff  first
#define ss  second
#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define coud(a,b) cout << fixed << setprecision((b)) << (a)
#define mset(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x)    for(auto &a : x)

const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int d8x[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int d8y[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int d4x[4]={1, 0, 0, -1};
int d4y[4]={0, -1, 1, 0};
ll power(ll x,ll y){ll ans=1;x=x;while(y>0){if(y&1)ans=(ans*x);y=y>>1;x=(x*x);}return ans;}
ll sqr(ll x) { return x * x;}

template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0) { if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<int,int>  pii;
typedef pair<ll,ll>  pll;
typedef vector<pll>  vpll;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
#define minpq priority_queue<T,vector<T>,greater<T> >;
// #define T int
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
//*X.find_by_order(k) returns the kth largest element (0-based).
//X.order_of_key(val) returns the no. of values less than val.
ll ncr(ll n,ll r) {ll ans=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){ans*=(n-i);ans/=(i+1);}return ans;}
const int MOD = 1000000007;   
const int N = 300010;

ll n,m,Ta,x,y,cnt1[N],cnt2[N],ans,col[N];
map <pii,int> is;
vll v[N];
void run() {
  cin >> n >> m >> Ta;
  while(Ta--) {
    cin >> x >> y;
    v[x].pb(y);
    is[mk(x,y)] = 1;
    cnt1[x] ++;
    cnt2[y] ++;
  }
  ll mx=0;
  rep(i,1,m) chmax(mx,cnt2[i]);
  ll tot=0;
  rep(i,1,m) if(cnt2[i]==mx) col[i]=1,tot++;

  rep(i,1,n) {
    ll p=0;
    trav(it,v[i]) {
      if(col[it]==1) p++;
      chmax(ans,cnt2[it] - 1 + cnt1[i]);
    }
    if(p!=tot) chmax(ans,cnt1[i]+mx);
  }
  cout<<ans;
}

int32_t main() {
  cin.sync_with_stdio(0);cin.tie(0);
  cin.exceptions(cin.failbit);
  int tc=1;
  //cin >> tc;
  for (int i=1; i<=tc; ++i) {
    run();
  }
  return 0; 
}
/* 
    stuff you shoulds look for
    * int overflow,array bounds.
    * special cases (n=1?).
    * N,MOD value.
*/

Measured memory_bytes: 45796
#include <cstdio>
#include <cmath>
#include <limits>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdint>
#include <functional>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;

const ll mod = 1000000000 + 7; //10^9


// bool is_integer(double x){
//     return floor(x) == x;
// }

// vector<int> bitsearch(int n, int bit) {
//     for (int i = 0; i < n; i++)
//     {
//         vector<int> S(n);
//         if(bit & (1 << i)){
//             S.push_back(i);
//         }
//     }
// }./  

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int a = S.size();
    int ans = 0;
    for (int i = 0; i < a - 2; i++)
    {
        if (S[i] == 'A')
        {
            if (S[i + 1] == 'B' )
            {
                if (S[i + 2] == 'C')
                {
                    ans ++;
                }
                
            }
            
        }
        
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3616
# 10th
s = input()
#sの後ろから文字列を取り除いていく方針だが,
#文字列自体を操作するのではなく,indexを減らす方法を取った。
t = len(s)
flag = True
while t > 0:
    if s[t-5:t] == "erase" or s[t-5:t] == "dream":
        t -= 5
    elif s[t-6:t] == "eraser":
        t -= 6
    elif s[t-7:t] == "dreamer":
        t -= 7
    else:
        flag = False
        print("NO")
        break

if flag:
    print("YES")

Measured memory_bytes: 3188
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	a := scanInts(n)

	for i := 0; i < k; i++ {
		p := make([]int, n+1)
		for j := 0; j < n; j++ {
			p[max(0, j-a[j])]++
			p[min(n, j+a[j]+1)]--
		}
		na := make([]int, n)
		t := 0
		for i := 0; i < n; i++ {
			t += p[i]
			na[i] = t
		}
		a = na
		f := true
		for j := 0; j < n; j++ {
			if a[j] != n {
				f = false
			}
		}
		if f {
			break
		}
	}

	for i := 0; i < n; i++ {
		fmt.Fprint(wr, a[i], " ")
	}
	fmt.Fprintln(wr)

}


Measured memory_bytes: 12008
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <utility>
#include <queue>
#define INF 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

//(int)'a'=97 (int)'A'=65 (int)'1'=49
//おまじない

const int maxn = 100000;

int main(){
    
    ll n,a,b;
    ll ans = INF;
    ll M=0,m=0;
    ll h[maxn]={0};
    cin >> n>>a>>b;
    rep(i,n){
        cin >> h[i];
    }
    M=1000000000;
    sort(h,h+n);
    reverse(h,h+n);
    a=a-b;
//    int c=0;
    while(m<M){
        ll mid = (M+m)/2;
        ll cnt=0;
//        cout <<m<<space<<M<<space<<mid<<endl;
//        c++;
//        if(c==100){
//            cout << "forced"<<endl;
//            break;
//        }
        bool key=false;
        rep(i,n){
            if(h[i]<=mid*b){
                break;
            }else{
                ll rest = h[i]-mid*b;
                cnt+=rest/a;
                if(rest%a!=0)cnt++;
            }
        }
        if(cnt<=mid)key=true;
        if(key){
            ans=min(ans,mid);
            M=mid;
        }else{
            m=mid+1;
        }
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S; cin>>S;
  int N=S.size();
  int C=MOD,F=-1;
  rep(i,0,N){
    if(S[i]=='C'){
      C=i;
      break;
    }
  }
  rep(i,0,N){
    if(S[i]=='F') F=i;
  }
  string ans="No";
  if(C<F) ans="Yes";
  cout<<ans<<endl;
  }


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

Measured memory_bytes: 596
import java.util.Scanner;

/**
 *
 * @author ena000078
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        boolean shipB[] = new boolean[N+1];
        boolean shipN[] = new boolean[N+1];
        
        for(int i=0;i<M;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a==1){
                shipB[b] = true;
            }else if(b==N){
                shipN[a] = true;
            }
        }
        
        
        String pos = "IMPOSSIBLE";
        for(int i=2;i<N;i++){
            if (shipB[i]){
                if(shipN[i]){
                    pos = "POSSIBLE";
                    break;
                }
            }
        }
        System.out.println(pos);
    }
    
}

Measured memory_bytes: 94044
n = input()

for i in xrange(n):
    tmp = map(int, raw_input().split())
    if tmp[0]**2 + tmp[1]**2 == tmp[2]**2 or tmp[1]**2 + tmp[2]**2 == tmp[0]**2 or tmp[2]**2 + tmp[0]**2 == tmp[1]**2:
        print "YES"
    else:
        print "NO"

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if ( A + B >= A - B  && A + B >= A * B ){
    cout << A + B << endl;
  }
  else if ( A - B >= A + B && A - B >= A * B ){
    cout << A - B << endl;
  }
  else if ( A * B >= A + B && A * B >= A - B ){
    cout << A * B << endl;
  }
}

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

int main()
{
	int num,i,j,x,y,z;
	
	char a[20],b[20],c[20];
	scanf("%s %s %s",a,b,c);
	
	x = strlen(a);
	y = strlen(b);
	z = strlen(c);
	
	if(a[x-1] == b[0] && b[y-1] == c[0]) cout << "YES";
	else cout << "NO";
	
	
	
}

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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

const int MOD = 1e9 + 7;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	vl x(n), y(m);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
	}

	LL sumX, sumY;
	sumX = sumY = 0;

	for (int i = 0; i < n; i++) {
		int k = i + 1;
		sumX += (k - 1) * x[i] - (n - k) * x[i];
	}
	for (int i = 0; i < m; i++) {
		int k = i + 1;
		sumY += (k - 1) * y[i] - (m - k) * y[i];
	}

	cout << (sumX % MOD) * (sumY % MOD) % MOD << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;

int arr[maxn];
bitset <250000> bit;
bool solve(vector <int> vec, int goal) {
	//cout << "Solve : ";
	//sort(vec.begin(),vec.end());
	//for (auto u : vec) cout << u << ' ';
	//cout << endl;
	//cout << goal << endl;
	
	bit.reset();
	bit[0] = 1;
	int sumall = 0;
	for (auto u : vec) sumall += u;
	//printf("%d %d %d\n",sumall,goal,sumall-goal);
	if(sumall<goal)return false;
	//WZIETE - NIE = goal
	//WZIETE - (sumall - WZIETE) = goal
	//2 * WZIETE = goal - sumall
	int WZIETE = abs(goal - sumall);
	if (WZIETE % 2) return 0;
	WZIETE /= 2;
	for (auto u : vec) bit |= (bit << u);
	return bit[WZIETE];
}
string tmp;

int main()
{
	ios_base::sync_with_stdio(false);
	int n; cin >> tmp; n = (int)tmp.size();
	vector <int> v[2];
	int ost = -1;
	for (int i=1; i<=n; ++i) {
		if (tmp[i-1] == 'T') arr[i] = 1;
		else arr[i] = 0;
	}
	int x, y, curr = 0;
	cin >> x >> y;
	swap(x, y);
	for (int i=1; i<=n; ++i) {
		if (arr[i] == 1) {
			if (ost == -1) ost = 1;
			else {
				if (curr > 0) v[ost].push_back(curr);
				if (ost == 0) ost = 1;
				else ost = 0;
			}
			curr = 0;
		}
		else {
			if (ost == -1) --y;
			else ++curr;
		}
	}
	if(ost!=-1)if(curr>0)v[ost].push_back(curr);
	
	//cout << v[0][0] << ' ' << v[1][0] << endl;
	if (solve(v[1], abs(x)) && solve(v[0], abs(y))) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long

void solve(void) {
  ll N, K;
  cin >> N >> K;

  vector<ll> candle(N);
  for (ll i = 0; i < N; ++i) cin >> candle[i];

  ll res = 10000000000;

  for (ll ci = 0; ci + (K-1) < N; ++ci) {
    ll left = candle[ci];
    ll right = candle[ci+(K-1)];

    ll dist1 = abs(left) + abs(right - left);
    ll dist2 = abs(right) + abs(right - left);

    res = min(res, min(dist1, dist2));
  }
  cout << res << endl;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int N,M; cin >> N >> M;
	
	int l = 1;
	int r = N;
	for (int i = 0; i < M; i++) {
		int L,R; cin >> L >> R;
		l = max(l,L);
		r = min(r,R);
	}
	cout << max(0,r-l+1) << endl;

	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct Koumon {
  int x,l,f,d,ud;
  Koumon() {}
  Koumon(int x, int l, int f, int d, int ud) :
    x(x),l(l),f(f),d(d),ud(ud) {}
  double otime() {
    if (ud) return double(l)/d;
    else return double(l)/f;
  }
  double itime() {
    if (ud) return double(l)/f;
    else return double(l)/d;
  }
  double ini() {
    if (ud) return double(l)/f;
    else return 0;
  }
};

double dpin[101][1500];
double dpout[101][1500];
double dpava[101][1500];

Koumon koumon[100];
int kid[1500];
int v[100];

int main() {
  int n, m, k;
  while(cin>>n>>m>>k,n||m||k) {
    memset(kid,-1,sizeof(kid));
    REP(i,n) {
      int x,l,f,d,ud;
      cin>>x>>l>>f>>d>>ud;
      x+=100;
      koumon[i]=Koumon(x,l,f,d,ud);
      kid[x] = i;
    }
    REP(i,m) cin>>v[i];
    REP(i,m+1)REP(j,k+105) {
      dpin[i][j]=dpout[i][j]=dpava[i][j]=-1e100;
    }
    REP(i,m) {
      REP(j,k+103) {
        if (kid[j] >= 0) {
          dpava[i+1][j+1] = max(koumon[kid[j]].ini(), dpout[i][j+1] + koumon[kid[j]].itime());
        }
        dpin[i+1][j+1] = max(dpout[i+1][j]+1.0/v[i], dpin[i][j+2]);
        if (i==100-j) dpin[i+1][j+1] = 0;
        if (kid[j] >= 0) chmax(dpin[i+1][j+1], dpava[i+1][j+1]);
        dpout[i+1][j+1] = dpin[i+1][j+1];
        if (kid[j] >= 0) chmax(dpout[i+1][j+1], dpin[i+1][j+1] + koumon[kid[j]].otime());
        // cout << i << " " << j << " " << dpin[i+1][j+1] << " " << dpout[i+1][j+1] << endl;
      }
    }
    printf("%.10f\n", dpout[m][k+101]);
  }
}

Measured memory_bytes: 4752
#include <stdio.h>

int main(void)
{
    char s[5], *sp;
    sp = s;
    int i, count;
    count = 0;

    scanf("%s", s);
    
    for(i = 0; i <= 3; i++){
        if( *(sp+i) == '+' ){
            count++;
        }else if(*(sp+i) == '-' ){
            count--;
        }
    }

    printf("%d", count);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

#include <fstream>

using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;
char s[Z], t[Z];
#define rep(i,s,n)for(ll i = s;i<n;i++)

ll strlength(const char *s) {
	int n = 0;
	while (*s++)n++;
	return n;
}
bool checkEven(char *s) {
	ll len = strlength(s);
	if (len % 2 != 0) return false;

	char* t = s + len / 2;

	while (*s == *t) {
		s++;
		t++;
	}
	if (*t == '\0') {
		return true;
	}
	return false;
}

void deletelastchar(char* s) {
	ll ln = strlength(s);
	*(s + ln - 1) = '\0';
}
int main() {
	cin >> s;
	deletelastchar(s);

	while (true) {
		if (checkEven(s)) {
			cout << strlength(s) << endl;
			return 0;
		}
		deletelastchar(s);
	}

	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
 
int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> ans(n,0);
  for(int i=1;i<n;i++){
    cin>>a.at(i);
    ans.at(a.at(i)-1)++;
  }
  for(int i=0;i<n;i++)cout<<ans.at(i)<<endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 double PI = acos(-1.0);
// cout << fixed << setprecision(14);

const int MAX = 2000010;

long long 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 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;
}
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    COMinit();

    int N;
    cin >> N;
    int A[N+1];
    map<int, int> mp;
    int num, num1, num2;
    rep(i,N+1){
        cin >> A[i];
        if(mp[A[i]] == 0){
            mp[A[i]] = i+1;
        }
        else{
            num = i+1 - mp[A[i]];
            num1 = mp[A[i]]-1;
            num2 = i;
        }
    }
    for(int i=1;i<=N+1;i++){
        int ans = COM(N+1,i);
        if(i == 1) --ans;
        else{
            ans -= COM(N-num2+num1,i-1);
        }
        ans += MOD*5;
        ans %= MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 55168
/*
A2739.c
title:Delivery to a Luxurious House
@kankichi573
*/

#include <stdio.h>

int main()
{
  int n,m,t,a,i;
  int st,en,all;
  
  scanf("%d %d %d",&n,&m,&t);

  all=0;
  scanf("%d",&a);
  st=a-m,en=a+m;

  for(i=1;i<n;i++)
      {
	scanf("%d",&a);
	if(a>en+m)
	  {
	    all += (en-st); 
	    st=a-m,en=a+m;
	  }
	else
	en = a+m;
      }
  if(en < t)
    all += (en-st);
  else
    all += t-st;
  printf("%d\n",t-all);
  return(0);
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main() {
  ll n;
  cin >> n;
  ll x = (ll)sqrt(n);
  ll m = 1;
  for (int i = 2; i < x + 1; ++i) {
    if (n % i == 0) m = i;
  }
  cout << (m - 1) + (n / m - 1) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		String[] sArray = s.split("/");
		if (Integer.parseInt(sArray[1]) <= 4) {
			System.out.println("Heisei");
		} else {
			System.out.println("TBD");
		}
	}
}


Measured memory_bytes: 22612
#include <cstdlib>
#include <cstring>
#include <cstdio>
int lst[100005], to[200005], pre[200005], tot; 
bool rem[100005]; 
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u]; 
	lst[u] = tot++; 
}
void dfs(int u, int fa = -1)
{
	rem[u] = true; 
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] == fa)
			continue; 
		dfs(to[i], u); 
		if (rem[to[i]])
		{
			if (rem[u])
			{
				rem[to[i]] = false; 
				rem[u] = false; 
			}
			else
			{
				puts("First"); 
				exit(0); 
			}
		}
	}
}
int main()
{
	// freopen("AGC014-D.in", "r", stdin); 
	memset(lst, -1, sizeof(lst)); 
	int n;
	scanf("%d", &n); 
	for (int i = 1; i < n; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		add_edge(--u, --v);
		add_edge(v, u);
	}
	dfs(0); 
	puts(rem[0] ? "First" : "Second"); 
	return 0; 
}


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

int n,ans;
map<ll,ll>mapi;
map<ll,ll>::iterator it;

ll k,total,a,b;

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

    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a>>b;
        mapi[a]+=b;
    }

    for(it=mapi.begin();it!=mapi.end();++it)
    {
        total+=it->second;
        if(total>=k)
        {
            cout<<it->first<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define li long long int
#define ld long double
#define F first
#define S second
const li M = 1000000007;
#define ld long double
li dx[]={-1,1,0,0};
li dy[]={0,0,-1,1};

li bs(li k,vector<li> &B)
{
	li N=B.size();
	li lb=0,ub=N-1,md;
	if(k >= B[ub])
		return ub;
	if(B[0]>=k)
		return 0;
	while(lb <= ub)
	{
		md=(lb+ub)/2;
		if(B[md]<=k && B[md+1]>k)
			return md;
		if(B[md]<=k)
		lb=md+1;
		else
		ub=md-1;
			
	}
	return -1;
}
int main()
{
	li N,M,K,k,i,j;  cin>>N>>M>>K;
	vector<li> A(N+1,0),B(M+1,0);
	for(i=1;i<=N;i++)
	{
		cin>>A[i]; A[i]+=A[i-1];
	}
	for(i=1;i<=M;i++)
	{
		cin>>B[i]; B[i]+=B[i-1];
	}
	
	li ans=0;
	for(i=0;i<=N;i++)
	{
		if(A[i] > K)
		break;
		ans=max(ans, i + bs(K-A[i],B));
	}
	cout<<ans;
			
}



Measured memory_bytes: 6364
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();

       if(op.equals("+")){
         System.out.print(a+b);
       }else{
         System.out.print(a-b);
       }
      
    }
}

Measured memory_bytes: 21716
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def yn(f) return (f)? "Yes": "No" end
def ynb(f) return (f)? "YES": "NO" end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
a,p = inp
puts (a*3+p)/2
=begin
 
=end

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

int main(){
	int n, k;
	cin >> n >> k;
	int answer = 1;
	for(int i = 0 ; i < n ; i++){
		if(answer < k){
			answer = answer * 2;
		}else{
			answer = answer + k;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int  n , x ;
  scanf("%d %d",&n,&x);
  
  int m[n];
  int kari = 0,min = 1001;
  
  for(int i = 0;i < n;i ++){
    scanf("%d",&m[i]);
    kari += m[i];
    if(min>m[i]){
      min = m[i];
    }
  }
  
printf("%d",((x-kari)/min) + n);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>

using namespace std;

long n, x;
long ans = 0;
long countP[51];

void rec(int nn, long from, long to)
{
    //cout << nn << ", " << from << ", " << to << ", " << ans << endl;

if(from < 0 || to < 0 || ans<0) return;

    if(nn == 0)
    {
        ans++;
        return;
    }

    long midP = from + (to - from)/2;

    if(x == from) return;
    else if(x < midP)
    {
        //cout << "pattern 1" << endl;
        rec(nn-1, from + 1, midP-1);
    }
    else if(x == midP)
    {
        //cout << "pattern 2" << endl;
        //ans++;
        ans += countP[nn-1] + 1;
        //rec(nn-1, from + 1, midP-1);
    }
    else if(x == to || x == to - 1)
    {
        //cout << "pattern 3" << endl;
        ans += countP[nn];
    }
    else
    {
        //cout << "pattern 4" << endl;
        ans += countP[nn-1] + 1;
        //ans++;
        //rec(nn-1, from + 1, midP-1);
        rec(nn-1, midP+1, to-1);
    }

}

int main() {

    countP[0] = 1;
    for(int i=1; i<=50; i++)
    {
        countP[i] = countP[i-1] * 2 + 1;
    }

    cin >> n;
    cin >> x;

    long len = 1;
    for(int i=1; i<=n; i++) len = len * 2 + 3;
//cout << len << endl;
    rec(n, 1, len);

    cout << ans << endl;
}

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

int main()
{
  int n;
  cin >> n;
  map<ll, ll> num;
  
  REP(i, n)
  {
    int a; cin >> a;
    num[a]++;
  }
  ll s = 0;
  for(auto p : num)
  {
    s += p.first * p.second;
  }
  int q; cin >> q;
  REP(i, q)
  {
    ll b, c; cin >> b >> c;
    s += (c - b) * num[b];
    num[c] += num[b];
    num[b] = 0;
    
    cout << s << endl;
  }
  
  return 0;
}

Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;     // Initialize result 
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;    
        y = y>>1; // y = y/2 
        x = (x*x) % p;  // Change x to x^2 
    } 
    return res; 
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);} 

ll modinv(ll a,ll p){return power(a,p-2,p);}

int solve(){
    ll x;
    cin>>x;
    f(i,0,1000){
        ll a = i*i*i*i*i;
        f(j,-1000,1000){
            ll b =j*j*j*j*j; 
            if (a-b==x)
            {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
        
    }
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);



    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    

    // tests(){solve();}
    solve();
    return 0;
}/*#ifndef ONLINE_JUDGE
    #endif*/

    // make_pair make_tuple  tuple<int,int,int> continue resize insert

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

const int N = 2e6 + 10;

int fac[N], inv[N], invFac[N];

void pre(){
	inv[1] = 1;
	int m = 1e9 + 7;
	for(int i = 2; i < N; i++)
		inv[i] = (m - (m/i)*inv[MOD % i]) % MOD ;
	
	fac[0] = invFac[0] = 1;
	for(int i = 1; i < N; i++){
		fac[i] = fac[i-1] * i % MOD;
		invFac[i] = invFac[i-1] * inv[i] % MOD;
	}	
}

int solve(int x, int y){
	int ans = 0;
	ans = (fac[x+y] * invFac[x] % MOD) * invFac[y] % MOD;
	return ans;
}

int32_t main(){
	pre();
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int ans = (((solve(x2+1,y2+1) - solve(x2+1,y1) - solve(x1,y2+1) + solve(x1,y1)) % MOD + MOD) % MOD);
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 47104
N=int(input())
task=[]
for _ in range(N):
    task.append([int(i) for i in input().split()])

task=sorted(task, key=lambda x: x[1])

spent_time1=0
spent_time2=0
for i in range(N):
    spent_time2+=task[i][0]
ans='Yes'

for i in range(N):
    spent_time1+=task[i][0]
    deadline1=task[i][1]
    if i!=0:
        spent_time2-=task[N-i][0]
    deadline2=task[N-1-i][1]
    if deadline1<spent_time1:
        ans='No'
        break
    elif deadline2<spent_time2:
        ans='No'
        break
    

print(ans)

Measured memory_bytes: 42836
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((maze)),(maze).begin(),TL<char>)
# define UPPER(s)    transform(ALL((maze)),(maze).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
LL a[303030];
LL sum[303030];
map<LL, LL> sumcnt;

int main() {
	cin >> n;
	sumcnt[0]++;
	REP(i, n) {
		cin >> a[i];
		if (i) {
			sum[i] = sum[i - 1] + a[i];
			sumcnt[sum[i]]++;
		}
		else {
			sum[i] = a[i];
			sumcnt[sum[i]]++;
		}
	}
	LL ans = 0;
	for (auto it = sumcnt.begin(); it != sumcnt.end(); it++) {
		ans += (it->second)*(it->second - 1) / 2;
	}
	cout << ans << endl;
}

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

int main(){
  cout << fixed << setprecision(12);

  int a, b;
  cin>>a>>b;
  
  cout<<a / b<<" ";
  cout<<a % b<<" ";
  cout<<(double)a / b<<endl;
  
  return 0;
}


Measured memory_bytes: 3260
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

typedef long long int ll;
const int N_MAX = 200005;
const ll INF = 1E+18 + 5;
ll n, k;
ll A[N_MAX];
vector<long long int> P;
vector<long long int> Z;
vector<long long int> M;

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        if (A[i] > 0)P.push_back(A[i]);
        else if (A[i] < 0)M.push_back(A[i]);
        else Z.push_back(A[i]);
    }
    ll ans;
    ll numP = (ll)(P.size()-1) * P.size()/2 + (ll)(M.size()-1) * M.size()/2;
    ll numM = (ll)P.size() * M.size();
    ll numZ = n * (n-1)/2 - numP - numM;
    if (k <= numM){
        ll lb = -INF;
        ll ub = 0;
        sort(M.begin(), M.end());
        sort(P.begin(), P.end());
        while(ub - lb > 1){
            ll mid = (lb + ub)/2;
            ll num = 0;
            int j = 0;
            for(int i = 0; i < P.size(); i++){
                while(j < M.size() && (ll)P[i] * M[j] < mid)j++;
                num += j;
            }
            if (num < k)lb = mid;
            else ub = mid;
        }
        ans = lb;
    }
    else if (k <= numM + numZ) ans = 0;
    else{
        k -= numM + numZ;
        ll lb = 0;
        ll ub = INF;
        sort(P.begin(), P.end());
        sort(M.begin(), M.end(), greater<int>());
        while(ub - lb > 1){
            ll mid = (ub + lb)/2;
            ll num = 0;
            int j = 0;
            for(int i = P.size()-1; i >= 0; i--){
                while(j < P.size() && (ll)P[i] * P[j] < mid)j++;
                if ((j-1) < i)num += j;
                else num += j-1;
            }
            j = 0;
            for(int i = M.size()-1; i >= 0; i--){
                while(j < M.size() && (ll)M[i] * M[j] < mid)j++;
                if ((j-1) < i)num += j;
                else num += j-1;
            }
            num /= 2;
            if (num < k)lb = mid;
            else ub = mid;
        }
        ans = lb;
    }
    cout << ans  << endl;
    return 0;
}

Measured memory_bytes: 3700