akhauriyash/Code-Regression huggingface dataset:
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
B.append(0)

for i in reversed(range(n)):
    if B[i] <= A[i]+A[i+1]:
        ans += B[i]
        if B[i] < A[i+1]:
            A[i] = A[i]
        else:
            A[i] = A[i]-(B[i]-A[i+1])
    else:
        ans += A[i]+A[i+1]
        A[i] = 0
print(ans)


Measured memory_bytes: 24204
//
//  main.cpp
//  Atcoder Beginner Contest 071 C
//
//  Created by luras on 2017/8/20.
//  Copyright © 2017年 luras. All rights reserved.
//

#define ms(x, y) memset(x, y, sizeof(x))
#define mc(x, y) memcpy(x, y, sizeof(x))
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define ls o << 1
#define rs o << 1 | 1
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#include<list>
#include<set>
#include<string>
#include<algorithm>
#pragma comment(linker,"/STACK:102400000,102400000")
template <class T> inline void gmax(T &a, T b){if(b > a) a = b;}
template <class T> inline void gmin(T &a, T b){if(b < a) a = b;}
using namespace std;
const int N = 1e5 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647, ms1 = 16843009, ms31 = 522133279, ms63 = 1061109567, ms127 = 2139062143;
const double PI = acos(-1.0), eps = 1e-8;
typedef long long LL;
void fre()
{
    freopen("/Users/luras/Desktop/in.txt", "r", stdin);
    freopen("/Users/luras/Desktop/out.txt", "w", stdout);
}
const int INF = 1e9;
int casenum, casei;

int n;
map<int, int> mop;
map<int, int> :: iterator it;

int main()
{
    while(~ scanf("%d", &n)){
        for(int i = 1; i <= n; i ++){
            int x;
            scanf("%d", &x);
            mop[x] ++;
        }
        LL ans = 0;
        int l = 0, r = 0;
        for(it = mop.begin(); it != mop.end(); it ++){
            if(it -> second >= 2){
                r = it -> first;
                gmax(ans, 1LL * l * r);
                l = r;
            }
            if(it -> second >= 4){
                r = it -> first;
                gmax(ans, 1LL * l * r);
                l = r;
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

/*
 
 
 题意:
 
 类型:
 
 分析:
 
 优化:
 
 trick:
 
 数据:
 
 Sample Input
 
 Sample Output
 
 
 */






Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int A, B, C;
int X;
int solve(){
int ans = 0;
for(int i = 0; i <= A; ++i){
for(int j = 0; j <= B; ++j){
for(int k = 0; k <= C; ++k){
int tmp = i * 500 + j * 100 + k * 50;
if(tmp == X) ans++;
}
}
}
return ans;
}
int main(){
scanf("%d%d%d%d", &A, &B, &C, &X);
int ans = solve();
printf("%d\n", ans);
return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]

count = 0
dic1 = {}
#print(s)
for i in range(n):
    #print(s[i])
    so = sorted(s[i])
    so = ''.join(so)
    if so in dic1:
        count += dic1[so]
        dic1[so] += 1
    else:
        dic1[so] = 1
    #print(count, dic1)
print(count)


Measured memory_bytes: 24976
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;


const ll MAX = 10000000;

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

// NのP乗をMで割った余りを返す
ll pow_mod(ll n,ll k,ll m){
  if(k==0){
    return 1;
  }else if(k%2==1){
    return pow_mod(n,k-1,m)*n%m;
  }else{
    ll t=pow_mod(n,k/2,m);
    return (t*t)%m;
  }
}

//(10*9*8)/(3*2*1);
//10*9*8 -> ansMul
//3*2*1 -> ansDiv
long calcComb(int a, int b) {
	if (b > a - b) return calcComb(a, a - b);


	long ansMul = 1;
	long ansDiv = 1;
	for (int i = 0; i < b; i++)
	{
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}
	//ansMul / ansDivをやりたい
	//ansDivの逆元を使って求めよう！

	long ans = ansMul * pow_mod(ansDiv,MOD - 2,MOD);
	return ans;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin >> N >> M;
  map<int,int> mp;
  ll ans=1;
  for(int i=2;i*i<=M;i++){
    while(M%i==0){
      mp[i]++;
      M/=i;
    }
  }
  COMinit();
  if(M!=1)mp[M]++;
  for(auto e:mp){
    ans*=calcComb(e.second+N-1,N-1)%MOD;
    ans%=MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec[i];
  vector<int> copy = vec;
  map<int, int> mp;
  sort(all(copy));
  rep(i, n) mp.insert(make_pair(copy[i], i));
  int left, right;
  left = copy[n/2-1];
  right = copy[n/2];
  rep(i, n){
    if(mp[vec[i]] <= n/2-1) cout << right << endl;
    else cout << left << endl;
  }
  return 0;
}

Measured memory_bytes: 13920
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str1 = sc.next();
        String str2 = sc.next();
        for (int i=0; i<str1.length(); i++) {
            if (str1.equals(str2)) {
                System.out.println("Yes");
                return;
            }
            str1 = str1.substring(str1.length()-1) + str1.substring(0, str1.length()-1);
        }
       System.out.println("No");
    }
}


Measured memory_bytes: 21972
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        double n=s.nextDouble();
        double ans=0;
        if(n==1)
            ans=1;
        if(n%2==0)
            ans=(n/2)/n;
        if(n%2==1)
        ans=((n+1)/2)/n;
        System.out.println(ans);
    }
}

Measured memory_bytes: 25172
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
int usi[221001]; string test[210012], cou[213456], ans[213456];
signed main() {
	int n, a = 0, b = 0, c = 0, ma = 0; cin >> n; string s;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	sort(test, test + n);
	for (int h = 1; h < n; h++) {
		if (test[h] == test[h - 1]) {
			if (b == 0) { cou[a] = test[h]; usi[a] = 2; b++; }
			else { usi[a]++; }
		}
		else {
			if (usi[a] == 0) { usi[a] = 1; cou[a] = test[h - 1]; }
			b = 0; ma = max(ma, usi[a]); a++;
		}
	}
	if (usi[a] == 0) { usi[a] = 1; cou[a] = test[n - 1]; a++; }
	if (b != 0) { ma = max(ma, usi[a]); a++; }
	for (int h = 0; h < a; h++) {
		if (usi[h] == ma) {
			ans[c] = cou[h]; c++;
		}
	}
	sort(ans, ans + c);
	for (int h = 0; h < c; h++) {
		cout << ans[h] << endl;
	}
}

Measured memory_bytes: 19200
import sys

cin = sys.stdin
# cin = open("in.txt", "r")


def line2N():
    return map(int, cin.readline().split())


N, = line2N()
a = list(line2N())
t = [0] * N

for i in range(N):
    while a[i] % 2 ==0:
        t[i] += 1
        a[i] //= 2

print(sum(t))


Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    ll dp[N.size() + 1][K + 2][2] = {};
    dp[0][0][0] = 1;

    // keta dp
    REP(i, 0, N.size()) {
        int n = N[i] - '0';
        REP(j, 0, K + 1) {
            REP(k, 0, 2) {
                if (k == 0) {
                    REP(l, 0, n + 1) {
                        dp[i + 1][j + (l != 0)][l < n] += dp[i][j][k];
                    }
                } else {
                    REP(l, 0, 10) {
                        dp[i + 1][j + (l != 0)][k] += dp[i][j][k];
                    }
                }
            }
        }
    }
    cout << dp[N.size()][K][0] + dp[N.size()][K][1] << endl;
    return 0;
}

Measured memory_bytes: 3616
h, w = map(int, raw_input().split())
if h % 3 == 0 or w % 3 == 0:
    print 0
else:
    ans = min(w, h)
    for x in xrange(1, w):
        A = x * h
        B = (h / 2) * (w - x)
        C = w*h - A - B
        result = max(A, B, C) - min(A, B, C)
        ans = min(ans, result)
    for y in xrange(1, h):
        A = y * w
        B = (w / 2) * (h - y)
        C = w*h - A - B
        result = max(A, B, C) - min(A, B, C)
        ans = min(ans, result)
    print ans


Measured memory_bytes: 2568
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n;
	cin >> n;
	if(n==3) cout << "2 3 25" << endl;
	else{
		int now = 0;
		if(n % 2 == 1){
			cout << "30 ";
			now++;
		}
		REP1(x, 30000){
			if(x%30 >= 15 || x%30==0) continue;
			if(x%2 == 0 || x%3 == 0 || x%5 == 0){
				cout << x << " " << x - 2 *(x%30) + 30 << " ";
				now +=2 ;
			}
			if(now == n) break;
		}
		cout << endl;
		//cout << now;
	}
	//cout << ans << endl;
}

Measured memory_bytes: 3656
N = int(input())
a = list(map(int, input().split()))

cnt4 = 0
cnt1 = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt4 += 1
    if a[i] % 2 != 0:
        cnt1 += 1

if cnt4 >= cnt1:
    print("Yes")
else:
    if N == cnt4 + cnt1 and cnt4 + 1 == cnt1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14252
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
// namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
using namespace std;

bool ok = true;
const size_t SIZE = 5000;
V<ll> edges[SIZE];
ll X[SIZE];

PLL dfs(ll cur) {
    bitset<SIZE + 10> bs;
    bs.set(0, 1);
    ll sum = 0;
    for(ll nxt : edges[cur]) {
        ll a, b;
        tie(a, b) = dfs(nxt);
        if(!ok) return PLL();
        sum += a + b;
        bs = (bs << a) | (bs << b);
    }
    for(ll i = SIZE; 0 <= i; i--) {
        if(!bs.test(i)) continue;
        if(X[cur] < i) continue;
        return PLL(X[cur], sum - i);
    }
    ok = false;
    return PLL();
}

int main() {
    ll N;
    scanf("%ld", &N);
    for(ll i = 1; i < N; i++) {
        ll c = i;
        ll p;
        scanf("%ld", &p);
        edges[p - 1].push_back(c);
    }
    for(ll i = 0; i < N; i++) scanf("%ld", X + i);
    dfs(0);
    if(!ok) printf("IM");
    printf("POSSIBLE\n");
    return 0;
}


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

using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,(n))

int N;
int counter;
string S;

void input(){
  counter=0;
  cin>>N;
  REP(i,N){
    cin>>S;
    if(S=="A")counter++;  
    else counter--;

    if(counter<0)
      counter=-10000;
  }
}

void solve(){
  if(counter==0&&S=="Un")cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

}
    
int main(){
  input();
  solve();
}

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

int main() {

    int N;
    int l,r;
    int sum = 0;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> l >> r;
        sum += r - l + 1;
    }

    cout << sum << endl;    
}


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

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

const int mod = 1000000007;
const int inf = -1;

char maze[20][20];
int d[20][20];

int ans[20][20];

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

int bfs(int w, int h, int sx, int sy)
{
    queue<p> que;
    rep(i, 20)
        rep(j, 20)
            d[i][j] = inf;
    d[sx][sy] = 0;
    que.push(p(sx, sy));
    while (que.size())
    {
        p pos = que.front();
        que.pop();
        rep(i, 4)
        {
            int nx = pos.first + dx[i];
            int ny = pos.second + dy[i];
            if (nx >= 0 && nx < w && ny >= 0 && ny < h && maze[nx][ny] != '#' && d[nx][ny] == inf)
            {
                que.push(p(nx, ny));
                d[nx][ny] = d[pos.first][pos.second] + 1;
            }
        }
    }
    int max = 0;
    rep(i, h)
    {
        rep(j, w)
        {
            if (max < d[j][i])
            {
                max = d[j][i];
            }
            //cout << d[i][j];
        }
        //cout << endl;
    }
    return max;
}

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, 20)
    {
        rep(j, 20)
        {
            ans[i][j] = -1;
            maze[i][j] = '#';
        }
    }
    rep(i, n)
    {
        rep(j, m)
        {
            char c;
            cin >> c;
            maze[j][i] = c;
        }
    }
    int res = 0;
    rep(i, n)
    {
        rep(j, m)
        {
            if (maze[j][i] == '#')
            {
            }
            else
            {
                ans[j][i] = bfs(m, n, j, i);
            }
            if (res < ans[j][i])
            {
                res = ans[j][i];
            }
            //cout << ans[i][j] << endl;
        }
    }
    cout << res << endl;
}
/*
012-1-1
1-1-1-1-1
234-1-1

123-1-1
0-1-1-1-1
123-1-1

234-1-1
1-1-1-1-1
012-1-1

345-1-1
2-1-1-1-1
123-1-1

8910-1-1
7-1-1-1-1
654-1-1
101-1-1
2-1-1-1-1
345-1-1
212-1-1
10-1-1-1
212-1-1
345-1-1
2-1-1-1-1
101-1-1
456-1-1
3-1-1-1-1
212-1-1
789-1-1
6-1-1-1-1
543-1-1
210-1-1
3-1-1-1-1
456-1-1
321-1-1
4-10-1-1
321-1-1
456-1-1
3-1-1-1-1
210-1-1
567-1-1
4-1-1-1-1
321-1-1
678-1-1
5-1-1-1-1
432-1-1
*/

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

LL test = 120;
string getString(LL num){
	stringstream ss;
	ss << num;
	return ss.str();
}

bool query(LL num){
	cout << "? " << num << endl;
//*
	string res;
	cin >> res;
	return (res[0]=='Y');
//*/
	string tStr = getString( test );
	string nStr = getString( num );
	bool B1 = false;
	bool B2 = false;
	if( num <= test && nStr <= tStr ){
		B1 = true;
	}
	if( num > test && nStr > tStr ){
		B2 = true;
	}
	return B1^B2;
}
void pow10(){//10^n
	LL base = 2;
	while( query(base) == false ){
		base *= 10;
	}
	cout << "! " << base/2 << endl;
}
void solve(){
	int base = (int)1e9;
	
	if( query( base ) ){
		pow10();
		return;
	}

	//桁数の決定
	int keta = 9;
	base /= 10;
	while( query( base ) == false ){
		--keta;
		base /= 10;
	}

	//
	LL H,L;
	L = base;
	H = base*10-1;
	
	while(H-L>1){
		LL mid = (L+H)/2;
		if( query( mid*10 ) ){
			H = mid;
		}else{
			L = mid;
		}
	}
	
	cout << "! " << H << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 596
#include <stdio.h>

int main (void)
{
	int a, b;
	char op;

	while (1){
		scanf("%d %c %d", &a, &op, &b);

		if (op == '?')break;

		else if (op == '+'){
			printf("%d\n", a + b);
		}
		else if (op == '-'){
			printf("%d\n", a - b);
	    }
		else if (op == '*'){
			printf("%d\n", a * b);
		}
		else {
			printf("%d\n", a / b);
		}

		
	}

	return (0);
}

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

int main(void){

    int ans=0,a[4];
    for(int i=0;i<3;++i){
        cin>>a[i]; 
    }
    sort(a,a+3);
    for(int i=0;i<2;++i){
        ans+=abs(a[i]-a[i+1]);
    }

    cout<<ans;
    
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

n,m = map(int,input().split())
e = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    e[a-1].append(b-1)
def dfs(x):
    num = 0
    for nex in e[x]:
        if dis[nex] < 0:
            dfs(nex)
        num = max(num,dis[nex]+1)
    dis[x] = num
    return 
dis = [-1]*n
for i in range(n):
    if dis[i] < 0:
        dfs(i)
print(max(dis))

Measured memory_bytes: 59056
#include<iostream>
#include<cstring>

bool student[501][501];
bool party[501];

int main(){

	int n, m;
	while (std::cin >> n >> m, n || m){

		memset(student, 0, sizeof(student));
		memset(party, 0, sizeof(party));

		for (int i = 0; i < m; i++){
			int a, b;
			std::cin >> a >> b;
			student[a][b] = true;
			student[b][a] = true;
		}

		for (int i = 2; i <= n; i++){
			if (student[1][i]){
				party[i] = true;
				for (int j = 2; j <= n; j++){
					if (student[i][j])party[j] = true;
				}
			}
		}

		int res = 0;
		for (int i = 2; i <= n; i++){
			if (party[i])res++;
		}
		std::cout << res << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin >> x;
    int maxx = 1;
    for(int i=2;i<=100;i++){
        int tmp = i*i;
        while(tmp<=x){
            maxx = max(tmp,maxx);
            tmp *= i;
        }
    }
    cout << maxx << endl;
}

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

int main() {
    int n;
    cin >> n;
    int t[n];
    ll total = 0;
    for (int i = 0; i < n; i++) {
        cin >> t[i];
        total += t[i];
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int p, x;
        cin >> p >> x;
        p--;
        cout << (total -t[p] + x) << endl;
    }



    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy3
# -*- coding: UTF-8 -*-

#n=int(input())
n,m=map(int,input().split())
a=set([])
b=set([])

for i in range(m):
    u,v=map(int,input().split())
    if u==1:
        a.add(v)
    if v==n:
        b.add(u)

    

print('POSSIBLE' if a&b else 'IMPOSSIBLE')

Measured memory_bytes: 57944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]){
        int N;
        int P[7] = {0};

        scanf("%d", &N);
        for(int i=1; i<=N; i++){
                char str[11] = {0};
                scanf("%s", str);
                char c = str[0];
                if(c == 'M'){ P[0]++; }
                else if(c == 'A'){ P[1]++; }
                else if(c == 'R'){ P[2]++; }
                else if(c == 'C'){ P[3]++; }
                else if(c == 'H'){ P[4]++; }
        }

        long long ans = 0;
        for(int b = 1; b < (1<<5); b++){
                int bitc = 0;
                long long tmp = 1;
                for(int j=0; j<5 && bitc<=3 ; j++){
                        if( b & (1<<j) ){
                                bitc++;
                                tmp = tmp * (long long)P[j];
                        }
                }
                if(bitc == 3){
                        ans += tmp;
                }
        }
        printf("%lld\n", ans);
        return 0;
}

Measured memory_bytes: 128
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N,K,S = I()
ruiseki = [0]*(N+1)
for i in range(N):
    if K:
        ruiseki[i+1] = ruiseki[i]+S
        K -= 1
    else:
        ruiseki[i+1] = 10**15
ans = [10**9]*N
if S == 10**9:
    ans = [10**9-17]*N
for i in range(N-1,-1,-1):
    if ruiseki[i+1] <= 10**14:
        ans[i] = ruiseki[i+1]-ruiseki[i]
print(*ans)


Measured memory_bytes: 85720
//121 B - Can you solve this? 2019/03/09

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n,m,c; cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n , vector<int>(m));
    rep(i ,m) cin >> b[i];
    rep(i ,n){
        rep(j ,m){
            cin >> a.at(i).at(j);
        }
    }
    int sum=c;int counter=0;
    rep(i ,n){
        rep(j ,m){
        sum+=a.at(i).at(j)*b.at(j);
        }
        if(sum>0) ++counter;
        sum=c;
    }
    cout << counter << endl;
}

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

int main() {
	long long n,a=10,d=0;
	cin>>n;
	while(n>=a){
		a*=10;
		d++;
	}
	if(d==0){
		cout<<n<<endl;
	}
	else{
		if((n+1)%(a/10)!=0){
		cout<<9*d+(10*n/a-1)<<endl;
		}
		else{
			cout<<9*d+(10*n)/a<<endl;
		}
	}
	
   
	return 0;
}

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

int main(){
	int N, Q, i;
	scanf("%d%d", &N, &Q);
	int *v = (int *)malloc(sizeof(int) * Q);
	int *w = (int *)malloc(sizeof(int) * Q);
	for(i = 0; i < Q; i++){
		scanf("%d%d", &v[i], &w[i]);
	}
	if(N == 1){
		for(i = 0; i < Q; i++){
			printf("%d\n", v[i]);
		}
	}
	else{
		for(i = 0; i < Q; i++){
			while(v[i] != w[i]){
				if(v[i] < w[i]){
					w[i] = (w[i] + N - 2) / N;
				}
				else{
					v[i] = (v[i] + N - 2) / N;
				}
			}
			printf("%d\n", v[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int n, m;
vector<int> sum;


int check(int x, int mid){
	int t = x;
	int mindif = INT_MAX;
	int minindex = -1;

	for(int k = 0; k < m; ++k){
		int u = upper_bound(sum.begin(), sum.end(), sum[t] + mid)
				 - sum.begin() - 1;

		if(mindif > u - t){
			mindif = u - t;
			minindex = t;
		}

		t = u;
		if(t - x >= n){
			return minindex;
		}
	}
	return -1;
}


int binsearch(int x, int left, int right){
	while(left < right){
		int mid = (left + right) / 2;
		if( check(x, mid) >= 0 ){
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	return left;
}


int main(){
	scanf("%d%d", &n, &m);
	vector<int> L(n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &L[i]);
	}

	sum.resize(3 * n + 1);
	int k = 0;
	for(int i = 0; i < 3; ++i)
	for(int j = 0; j < n; ++j){
		sum[k+1] = sum[k] + L[j];
		++k;
	}

	k = binsearch(0, 1, sum[n]);
	int upb = k;
	int from = check(0, upb);

	for(int i = from; sum[i] - sum[from] <= k; ++i){
		upb = binsearch(i, 1, upb);
	}
	
	printf("%d\n", upb);
}

Measured memory_bytes: 1796
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#define null NULL
///delta不能初始化为0，因为这里所有的是值要更新为delta，delta=0的时候也要更新
///此处和RAQ有差别，需要注意
#define maxn -1
#define inf (1<<31)-1
using namespace std;
/** 区间表示：[p->dl,p->dr]
 *  从0开始计数，[0,n-1]
 *  线段树RSQ
 *
 */

struct Node
{
    long long dl,dr,s,delta;
    Node *pl,*pr;
};
int n,q;

void build(Node *&p,int l,int r)
{
    p=(Node *)malloc(sizeof(Node));
    p->dl=l,p->dr=r,p->s=inf,p->delta=maxn;
    p->pl=null,p->pr=null;
    int mid=(l+r)/2;
    if(r>l)
    {
        build(p->pl,l,mid);
        build(p->pr,mid+1,r);
    }
}

void preorder(Node *p)
{
    if(p!=null)
    {
        printf("%lld %lld %lld %lld\n",p->dl,p->dr,p->s,p->delta);
        preorder(p->pl);
        preorder(p->pr);
    }
}
///在其他节点更新和查询的过程中都要向下延迟修改
void pushdown(Node *&p,int delta)
{
    p->pl->s = p->delta;
    p->pr->s = p->delta;
    p->pl->delta = p->delta;
    p->pr->delta = p->delta;
    ///注意delta的值，maxn表示不用下传
    p->delta=maxn;
}
///当前区间的更新只更新到某些节点，下边节点的更新需要下次延迟修改
void update(Node *&p,int l,int r,int data)
{
    ///[l,r]必然位于[p->dl,p->dr]子区间
    ///当前节点的所有数据都是正确的！！
    ///延迟修改-lazy-tag技术
    ///此处下行的是之前的数据
    if(p->delta!=maxn && p->dr>p->dl)
        pushdown(p,p->delta);

    if(p->dl==l && p->dr==r)
    {
        p->s=data;
        p->delta=data;
        return ;
    }
    int mid=(p->dl+p->dr)/2;
    if(r<=mid)
        update(p->pl,l,r,data);
    else if(l>mid)
        update(p->pr,l,r,data);
    else
        update(p->pl,l,mid,data),update(p->pr,mid+1,r,data);
    p->s=min(p->pl->s,p->pr->s);
}
///当前节点的所有数据都是正确的！！
///即使不正确，在进入到这个之前也被pushdown过了,，所以一定是正确的
long long query(Node *&p,int l,int r)
{
    ///一个查询区间最终必然被分成若干个小的区间和，最后一个定会完全和区间贴合
    if(p->delta!=maxn && p->dr>p->dl)
        pushdown(p,p->delta);

    if(p->dl==l &&p->dr==r)
        return p->s;
    int mid=(p->dl+p->dr)/2;
    ///判断查询区间与当前区间的位置关系
    //全部位于左侧
    if(r<=mid)
        return query(p->pl,l,r);
    //全部位于右侧
    else if(l>mid)
        return query(p->pr,l,r);
    //两个都有
    else
        return min(query(p->pl,l,mid),query(p->pr,mid+1,r));
}

int main()
{
    int i,type,tx,ty,x;
    Node *tree=null;
    scanf("%d%d",&n,&q);
    build(tree,0,n-1);
    for(i=0;i<q;i++)
    {
        scanf("%d",&type);
        if(type==0)
        {
            scanf("%d%d%d",&tx,&ty,&x);
            update(tree,tx,ty,x);
        }else
        {
            scanf("%d%d",&tx,&ty);
            long long ans=query(tree,tx,ty);
            printf("%lld\n",ans);
        }
    }
    return 0;
}



Measured memory_bytes: 15700
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class28
    {
        static void Main()
        {
            var HN = Console.ReadLine().Split();
            var H = int.Parse(HN[0]);
            var N = int.Parse(HN[1]);

            var DP = new long[H + 1];
            for (int i = 1; i <= H; i++) DP[i] = long.MaxValue;
            DP[0] = 0;

            for(int i = 0; i < N; i++)
            {
                var read = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int A = read[0];
                int B = read[1];

                for(int j = 0; j < H; j++)
                {
                    if (DP[j] !=long.MaxValue)
                    {
                        int k = Math.Min(H, j + A);
                        DP[k] = Math.Min(DP[k], DP[j] + B);
                    }
                }
            }
            Console.WriteLine(DP[H]);
        }
    }
}


Measured memory_bytes: 13352
// 5/22
// 過去問ガリガリ
#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>;
using Graph = vector<vector<int>>;

int main() {
    int K, X;
    cin >> K >> X;

    if (500 * K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> mV;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mV.push_back(x);
    }

    vector<int> fA(n);
    fA[n - 1] = 0;
    fA[n - 2] = abs(mV[n - 1] - mV[n - 2]);

    for (int i = n - 3; i >= 0; i--) {
        fA[i] = min(abs(mV[i] - mV[i + 1]) + fA[i + 1], abs(mV[i] - mV[i + 2]) + fA[i + 2]);

    }

    cout << fA[0] << endl;
    
}



Measured memory_bytes: 1144
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
bool cmp(string a,string b){
for(int i=0;i<a.size() && i<b.size();i++)
  if(i<b.size()&& a[i]!=b[i])
    {if(a[i]-'a'<b[i]-'a')
      return true;
     else
       return false;}
if(a.size()<b.size())
  return true;
else
  return false;
}
int main(){
string s;
int k;
cin>>s>>k;
map<string,bool> mp;
vector<string> a;
for(int i=0;i<s.size();i++)
  for(int j=1;j<=5;j++)
    if(i+j<=s.size() && !mp[s.substr(i,j)])
      {mp[s.substr(i,j)]=1;
       a.push_back(s.substr(i,j));}
sort(a.begin(),a.end(),cmp);
cout<<a[k-1];
system("pause");
return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> Ls(m), Rs(m);
    // int Ls[m], Rs[m];
    rep(i, 0, m){
        cin >> Ls[i] >> Rs[i];
    }

    int maxL = *max_element(Ls.begin(), Ls.end());
    int minR = *min_element(Rs.begin(), Rs.end());
    int ans = max(0, minR - maxL + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
int main()
{
    ios;
    ll n ;
    cin >> n ;
    vl v ;
    forn(i , 1 , n ) {
       ll x;
       cin >> x ;
       v.pb(x);
    }
    sort(all(v)) ;
    unordered_map<ll,ll> mpp ;
    mpp.cl ;
    forn(i, 0 , v.sz - 1){
      mpp[v[i]]++;
    }
    ll foo = 0 ;
    for(auto &x : mpp){
        ll cnt = x.se;
        ll xx = x.fi ;
       /// cout << "x is " << xx << " cnt is " << cnt << el ;
        if(cnt < xx){
           foo = foo + cnt ;
           con ;
        }
        else if(cnt == xx){
            con ;
        }
        else if(cnt > xx){
            ll diff = abs(cnt - xx ) ;
            foo = foo + diff ;
        }
    }
    cout << foo << el ;
    ro ;
}























Measured memory_bytes: 4980
#include <stdio.h>

int main(void)
{
	int mou[10];
	int hozon;
	int a, b;
	
	for (a = 0; a < 10; a++){
		scanf("%d", &mou[a]);
	}
	// {1, 2, 3, 4, 5}
	
	#if 0
	
	{1, 2, 3, 4, 5}
	
	{2, 1, 3, 4, 5}
	{2, 3, 1, 4, 5}
	{2, 3, 4, 1, 5}
	{2, 3, 4, 5, 1}
	
	{3, 2, 4, 5}
	{3, 4, 2, 5}
	{3, 4, 5, 2}
	
	{3, 4, 5}
	{4, 3, 5}
	{4, 5, 3}
	
	{4, 5}
	{5, 4}
	
	{5}
	
	{5, 4, 3, 2, 1}
	
	#endif
	
	for (a = 0; a < 10; a++){
		for (b = 9; b > 0; b--){
			if (mou[b] > mou[b - 1]){
			hozon = mou[b];
			mou[b] = mou[b - 1];
			mou[b - 1] = hozon;
			}
		}
	}
	
	printf("%d\n", mou[0]);
	printf("%d\n", mou[1]);
	printf("%d\n", mou[2]);
	
	return (0);
}

Measured memory_bytes: 596
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>

using namespace std;

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

int main(void){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		string now;
		cin>>now;
		
		rep(p,n){
			stringstream sst;
			int st = 0;
			while(1){
				for(int i=st; ;i++){
					if(i==now.size() || now[i]!=now[st]){
						sst<<(i-st)<<now[st];
						st = i;
						if(i==now.size())goto A;
						break;
					}
				}
			}
			A:;
			now = sst.str();
		}
		
		cout<<now<<endl;
	}
}

Measured memory_bytes: 1376
#include<stdio.h>
int main(){
    int H, W;

    while(1){
    scanf("%d %d",&H,&W);

	if(H==0 && W==0) break;

    for(int i=1;i<=H;i++){
        printf("#");
        for(int k=1;k<=W-1;k++){
            printf("#");
        }
        printf("\n");
    }
    printf("\n");
    }
}


Measured memory_bytes: 2036
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;


//ワーシャルフロイド
//頂点1からNの向きありグラフ
template< typename T >
void wf(T (&g)[1000][1000], T N) {
	repn(k,N) {
		repn(i,N) {
			repn(j,N) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
}


int main() {
	ll N, M, L;
	cin >> N >> M >> L;

	ll g[1000][1000];

	repn(i, N) repn(j, N) g[i][j] = INF;

	ll A, B, C;

	rep(i, M) {
		cin >> A >> B >> C;
		g[A][B] = C;
		g[B][A] = C;
	}
	
	wf(g, N);

	repn(i, N) {
		repn(j, N) {
			
			if (g[i][j] > L) { g[i][j] = INF; }
			else { g[i][j] = 1; }
		}
	}

	wf(g, N);

	int Q;
	cin >> Q;

	ll s, t;

	rep(i, Q) {
		cin >> s>> t;
		if (g[s][t] == INF) { cout << -1<<endl; }
		else { cout << g[s][t]-1<<endl; }
	}

	system("PAUSE");

}

Measured memory_bytes: 4096
n,x,y = list(map(int,input().split()))

ans = [0] * (n-1)

for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min((j-i),abs(i-x)+1+abs(j-y),abs(i-y)+1+abs(j-x))-1] += 1
        
for i in ans:
    print(i)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N;
  cin>>N;
  set<int>k;
  for(int i=0;i<N;i++){
    int d;
    cin>>d;
    k.insert(d);
  }
  cout<<k.size()<<endl;
  return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a<0){
    if(b<0){
      if((b-a)%2==0) cout<<"Negative"<<endl;
      else cout<<"Positive"<<endl;
    }
    else cout<<"Zero"<<endl;
  }
  else if(a==0) cout<<"Zero"<<endl;
  else cout<<"Positive"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b){
	swap(a,b);
	}
	if(b>c){
	swap(b,c);
	}
	if(a>b){
	swap(a,b);
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define MAX_N 200000
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-48);
}
int n, l, a[MAX_N+5], b[MAX_N+5];
lnt mx, sl[MAX_N+5], sr[MAX_N+5];
int main() {
	read(l), read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int i = 1; i <= n; i++) b[i] = l-a[n-i+1];
	for (int i = 1; i <= n; i++) sl[i] = sl[i-1]+a[i];
	for (int i = 1; i <= n; i++) sr[i] = sr[i-1]+b[i];
	for (int i = 0, c = n>>1; i < n; c = (n-++i)>>1)
		if ((c<<1) == n-i)
			mx = max(mx, ((sl[i+c]-sl[i])<<1)+(sr[c]<<1)+(a[i]<<1)-a[i+c]), 
			mx = max(mx, ((sr[i+c]-sr[i])<<1)+(sl[c]<<1)+(b[i]<<1)-b[i+c]);
		else
			mx = max(mx, ((sl[i+c]-sl[i])<<1)+(sr[c]<<1)+(a[i]<<1)+b[c+1]), 
			mx = max(mx, ((sr[i+c]-sr[i])<<1)+(sl[c]<<1)+(b[i]<<1)+a[c+1]);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 4992
import sys
import bisect
input()
arr = list(map(int, input().split()))
nq = int(input())
lines = sys.stdin.readlines()
ans = [None] * nq
for i in range(nq):
    ans[i] = str(bisect.bisect_left(arr, int(lines[i])))
print('\n'.join(ans))


Measured memory_bytes: 39688
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
    int N;
    cin >> N;
    double ans = 0;
    for (int i = 0; i < N; ++i) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        } else {
            ans += (x * 380000.0);
        }
    }
    cout << fixed << setprecision(5) << ans << endl;
}

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

#define int long long

int cnt[2019];

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

	string s;
	cin >> s;
	cnt[0] = 1;
	int p = 1, now = 0, ans = 0;
	for(int i=s.size()-1; i>=0; --i){
		now = (now + (s[i] - '0') * p) % 2019;
		ans += cnt[now];
		++cnt[now];
		p = (p * 10) % 2019;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3764
using System;

class Program
{
  /// <summary>
  /// ABC 081 B - Shift only
  /// </summary>
  static void Main(string[] args)
  {
    var min = Math.Pow(10, 9);
    int[] A = new int[210];
    var N = int.Parse(Console.ReadLine());
    string[] S = Console.ReadLine().Split(' ');
    for (int i = 0; i < N; ++i)
    {
      A[i] = int.Parse(S[i]);
    }
    int res = 0;
    while (true)
    {
      bool exist_odd = false; // A[i]がすべて偶数かどうかを判定するフラグ
      for (int i = 0; i < N; ++i)
      {
        if (A[i] % 2 != 0) exist_odd = true; // 奇数があったらフラグを立てる
      }

      if (exist_odd) break;

      for (int i = 0; i < N; ++i)
      {
        A[i] /= 2;
      }
      ++res;
    }
    Console.WriteLine(res);
    return;
  }
}


Measured memory_bytes: 27600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    map<string, int> M;
    int Max = 0;
    rep(i, N)
    {
        cin >> S[i];
        M[S[i]]++;
        Max = max(Max, M[S[i]]);
    }
    for (auto i : M)
    {
        if (i.second == Max)
            cout << i.first << endl;
    }
    return 0;
}

Measured memory_bytes: 25472
#include <stdio.h>
#include <math.h>

int main(int argc, char** argv){
	double x1,y1,x2,y2;
	
	// Input
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	// Calc & Output
	printf("%f\n", sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ));

	return 0;
}

Measured memory_bytes: 652
#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>;

const int MOD = 1e9 + 7;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

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

    Sieve sieve(1005);
    map<int,int> mp;
    for (int prime : sieve.primes) {
        if (n < prime) break;
        for (int p = prime; p <= n; p *= prime) {
            int m = n / p;
            mp[prime] += m;
        }
    }

    ll ans = 1;
    for (auto p : mp) {
        ans *= p.second + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int MAX_V = 102, INF = 1 << 30;
int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int V, E;

int prim() {
  for (int u = 0; u < V; ++u) {
    mincost[u] = INF;
    used[u] = false;
  }
  
  mincost[0] = 0;
  int res = 0;
  while (true) {
    int v = -1;
    rep (u,V) {
      if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
    }
    if (v == -1) break;    
    used[v] = true;
    res += mincost[v];
    
    rep (u,V) {
      mincost[u] = min(mincost[u], cost[v][u]);
    }
  }
  return res;
}

int solve() {
  int a, b, c;
  rep (i,V) rep (j,V) cost[i][j] = INF;
  rep (i,E) {
    cin >> a >> b >> c;
    cost[a][b] = cost[b][a] = c;
  }
  return prim();
}

int main() {
  while (cin >> V >> E, V|E) {
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    long long int ans = 1000;
    long long int c;
    long long int d = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (arr[i] > arr[i + 1])
        {
            if (d != 0)
            {
                ans = c + d * arr[i];
                d = 0;
            }
            continue;
        }
        else if (arr[i] <= arr[i + 1])
        {
            long long int k = ans/arr[i];
            d = max(d, k);
            if (d == k)
            {
                c = ans - d * arr[i];
                ans = c + d*arr[i+1];
            }
            if (i  == n - 2)
            {
                ans = c + d * arr[i + 1];
                break;
            }
        }
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 3768
#include<cstdio>
#define For(i,A,B) for(i=(A);i<=(B);++i)
typedef long long ll;
const int N=100050;
int a[N];
ll s[N];
inline ll Min(ll a,ll b){return a<b?a:b;}
int main(){
	int n,i;
	ll ans=0ll,ret=1ll;
	scanf("%d",&n);
	For(i,0,n)scanf("%d",a+i);
	for(i=n;~i;--i)s[i]=s[i+1]+a[i];
	For(i,0,n){
		if(ret<a[i]){
			puts("-1");
			return 0;
		}
		ans+=ret;
		ret=Min(ret-a[i]<<1,s[i+1]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2904
#include <stdio.h>
#include<string.h>

int main() {
    int k;
    char s[105];
    scanf("%d\n %s", &k, s);
    int len = strlen(s);
    
    if (strlen(s)>k) {
        s[k]='.';
        s[k+1]='.';
        s[k+2]='.';
        s[k+3]='\0';
    }
	printf("%s", s);
    return 0;
}


Measured memory_bytes: 3200
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, C = il()
    t = 0
    for n in range(B + 1):
        t = A * n
        if t % B == C:
            print('YES')
            exit()
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include <iostream>
#include <cassert>
#include <vector>

bool is_palindromic_number(int x){
    assert(10000 <= x);
    assert(x <= 99999);
    std::vector<int> d(5);
    for(int i = 0; i < 5; i++){
        d.at(i) = x % 10;
        x = x / 10;
    }
    return (d.at(4) == d.at(0) && d.at(3) == d.at(1));
}


int main(int argc, char **argv)
{
    int A, B;
    std::cin >> A >> B;

    assert(10000 <= A);
    assert(A <= B);
    assert(B <= 99999);

    int ans = 0;
    for(int i = A; i <= B; i++){
        if(is_palindromic_number(i)) ans++;
    }

    std::cout << ans << std::endl;    
}


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

using namespace std;

int main(){
	int n,k;
	int cnt=0;
	int h[100000];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
		if(h[i]>=k){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}	

Measured memory_bytes: 640