akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll A, B, Q;
    cin >> A >> B >> Q;

    vector<ll> S(A);
    FOR(i, 0, A){
        cin >> S[i];
    }

    vector<ll> T(B);
    FOR(i, 0, B){
        cin >> T[i];
    }

    FOR(i, 0, Q){
        ll x;
        cin >> x;

        auto it = lower_bound(ALL(S), x);
        ll right_s;
        if(it==S.end()){
            right_s = inf;
        }else{
            right_s = *it;
        }

        it = lower_bound(ALL(T), x);
        ll right_t;
        if(it==T.end()){
            right_t = inf;
        }else{
            right_t = *it;
        }

        // 左側
        it = upper_bound(ALL(S), x);
        ll left_s;
        if(it==S.begin()){
            left_s = -inf;
        }else{
            it--;
            left_s = *it;
        }

        it = upper_bound(ALL(T), x);
        ll left_t;
        if(it==T.begin()){
            left_t = -inf;
        }else{
            it--;
            left_t = *it;
        }
        
        vector<ll> D;
        // 右右
        ll dist = max(right_s, right_t) - x;
        D.push_back(dist);
        
        // 左左
        dist = x - min(left_s, left_t);
        D.push_back(dist);

        // 右寺・左神社
        dist = (right_t - x) * 2 + (x - left_s);
        D.push_back(dist);

        // 右神社・左寺
        dist = (right_s - x) * 2 + (x - left_t);
        D.push_back(dist);

        // 左寺・右神社
        dist = (x - left_t) * 2 + (right_s - x);
        D.push_back(dist);

        // 左神社・右寺
        dist = (x - left_s) * 2 + (right_t - x);
        D.push_back(dist);

        ll m = *min_element(ALL(D));
        p(m);
    }
    
    return 0;
}

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

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define uset unordered_set
#define endl '\n'
#define umap unordered_map
#define pii pair<int, int> 
#define ld long double
#define pll pair<long long, long long> 

const int N = 123;
ll n, k, a[N], ans, p[N];

int main() {
	cin >> n >> k;
	for(ll i = 1; i <= n; ++i)
		cin >> a[i];
	sort(a+1, a+1+n);
	for(ll i = 1; i <= n; ++i)
		p[i] = p[i-1] + a[i];
	for(ll i = 1; i <= n; ++i)
		if(p[i] > k) {
			cout << i - 1;
			return 0;
		}
	if(p[n] == k)
		cout << n;
	else
		cout << n-1;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    //data[a][b] := Li = a, Ri <= b を満たすiの個数
    vector<vector<int>> data(n + 1, vector<int>(n + 1));
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        data.at(l).at(r)++;
    }
    rep(i, n) rep(j, n) data.at(i + 1).at(j + 1) += data.at(i + 1).at(j);
    
    rep(_q, q) {
        int p, q;
        cin >> p >> q;
        int cnt = 0;
        repr(i, p, q + 1) cnt += data.at(i).at(q);
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<algorithm>
#include<list>
#include<set>
using namespace std;



void dfs(int c,int depth,vector<vector<int> >& tree, vector<int>& memo){
	if(memo[c] != -1) return;
	memo[c] = depth;

	for(int i=0;i<tree[c].size();++i){
		int next = tree[c][i];
		dfs(next,depth+1,tree,memo);
	}
}


int main(){
	int n;
	cin >> n;
	vector<vector<int> > tree(n+1);
	vector<int> fenech(n+1,-1);
	vector<int> sunuke(n+1,-1);

	int a,b;
	for(int i=1;i<n;++i){
		cin >> a >> b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	dfs(1,0,tree,fenech);
	dfs(n,0,tree,sunuke);

	int nfenech = 0;
	int nsunuke = 0;

	for(int i=1;i<=n;++i){
		if(fenech[i] <= sunuke[i]){
			nfenech++;
		}else{
			nsunuke++;
		}
	}

	if(nfenech > nsunuke) cout << "Fennec" <<endl;
	else cout << "Snuke" <<endl;
	
	return 0;
}




Measured memory_bytes: 11136
// /400

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> as(n);
	for(int i=0; i<n; ++i){
		cin >> as[i];
	}
	sort(as.begin(), as.end());
	int ai = *(--as.end());
	int aj=0;
	double min_diff=2000000000;
	for(auto it = as.rbegin(); it != as.rend(); ++it){
		int a = *it;
		double diff = abs(a-ai/2.0);
		if(a != ai && diff < min_diff){
			min_diff = diff;
			aj = a;
		} else if(a < ai/2.0){
			break;
		}
	}
	cout << ai << " " << aj;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    LL N, K; cin >> N >> K;
    vector<LL> A(N);
    for (LL i = 0; i < N; ++i) {
        cin >> A[i];
        --A[i];
    }
    vector<LL> vis(N, -1);
    LL idx = 0, count = 0;
    vis[idx] = 0;
    while (true) {
        idx = A[idx];
        ++count;
        if (vis[idx] == -1) {
            vis[idx] = count;
        } else {
            break;
        }
        if (K == count) {
            cout << idx+1 << endl;
            return 0;
        }
    }
    // cout << idx << endl;
    K = (K - vis[idx]) % (count - vis[idx]);
    // cout << K << endl;
    for (LL i = 0; i < K; ++i) {
        idx = A[idx];
    }
    cout << idx+1 << endl;
    return 0;
}


Measured memory_bytes: 6376
import numpy as np
import itertools

N, M = map(int, input().split())
switch = [[] for _ in range(M)]
for i in range(M):
    switch[i] = list(map(lambda x: int(x)-1, input().split()[1:]))
p = list(map(int, input().split()))

bit = itertools.product(range(2), repeat=N)
cnt = 0
for b in bit:
    np_b = np.array(b)
    on = 1
    for bulb in range(M):
        on *= sum(np_b[switch[bulb]]) % 2 == p[bulb]
    cnt += on
print(cnt)

Measured memory_bytes: 12448
h,w = map(int, input().split())
l = [None]*h
for i in range(h):
    l[i] = list(input())

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(h):
    for j in range(w):
        if l[i][j] == "#":
            ok=False
            for k in range(4):
                nx = j + dx[k]
                ny = i + dy[k]
                if 0<=nx<w and 0<=ny<h and l[ny][nx]=="#":
                    ok=True
            if not ok:
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 39920
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] line = in.readLine().split(" ");
		int n = Integer.parseInt(line[0]);
		int m = Integer.parseInt(line[1]);
		StringTokenizer str = new StringTokenizer(in.readLine());
		
		PriorityQueue<Integer> queue = new PriorityQueue(n, Collections.reverseOrder());
		while(str.hasMoreTokens()) {
		    queue.offer(Integer.parseInt(str.nextToken()));
		}
		
		while(m>0){
		    int current_max = queue.poll();
		    m--;
		    queue.offer(current_max/2);
		}
		
		long sum = 0;
		while(!queue.isEmpty()){
		    sum += (long)queue.poll();
		}
		System.out.println(sum);
	}
		
}


Measured memory_bytes: 46072
#include<stdio.h>
int main()
{
	int a,b,c,max,min1,min2;
	scanf("%d %d %d",&a,&b,&c);
	if(a>=b&&a>=c)
	{
		max=a;
		min1=b;
		min2=c;
	}
	if(b>=a&&b>=c)
	{
		max=b;
		min1=a;
		min2=c;
	}
	if(c>=a&&c>=b)
	{
		max=c;
		min1=b;
		min2=a;
	}
	if(max==min1+min2)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
 } 

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fst first
#define snd second

typedef long long ll;

int n; int A, B, C;

ll dpA[1<<10];
ll dpB[1<<10];
ll dpC[1<<10];

int main() {
    cin >> n >> A >> B >> C;

    int a[n]; fore(i, 0, n) cin >> a[i];
    
    fore(i, 1, 1<<n) {
        int s = 0, c = 0;
        fore(j, 0, n) {
            if(i & (1<<j)) s += a[j], c++;
        }
        dpA[i] = abs(A - s) + (c - 1) * 10;
        dpB[i] = abs(B - s) + (c - 1) * 10;
        dpC[i] = abs(C - s) + (c - 1) * 10;
    }
    ll res = 1e17;
    fore(i, 1, 1<<n) {
        fore(j, 1, 1<<n) if(!(j & i)) {
            fore(k, 1, 1<<n) if(!(k & (i | j))) {
                // cout << i << " " << j << " " << k << endl;
                res = min(res, dpA[i] + dpB[j] + dpC[k]);
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

int main(){
	int x[10010];
	int y[10010];
	int i = 0, i2 = 0, i3 = 0;
	while (i < 10010){
		cin >> x[i];
		cin >> y[i];
		if (x[i] == 0 && y[i] == 0){
			i2 = i - 1;
			break;
		}
		i++;
	}
	while (i3 <= i2){
		if (x[i3] < y[i3]){
			cout << x[i3] << " " << y[i3] << endl;
		}
		if (x[i3] >= y[i3]){
			cout << y[i3] << " " << x[i3] << endl;
		}
		i3++;
	}
	return 0;
}

Measured memory_bytes: 3088
#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 main() {
	while (1) {
		int a[100000] = {0};
		int n, k, sum = 0, ans;

		cin >> n >> k;
		if (n == 0 && k == 0) break;

		REP(i, n) {
			cin >> a[i];
			sum += a[i];
			if (i >= k) sum -= a[i-k];
			else ans = sum;
			ans = max(ans, sum);
		}

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

Measured memory_bytes: 1556
#include <bits/stdc++.h>
using namespace std;
#define gc getchar()
inline int read(){
	int x=0,f=1;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='-')f=-1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return x*f;
}
#define io read()

typedef long long ll;
#define maxn 200005
int n,a[maxn];
ll s[maxn],b[4],ans;

inline void init(){
	n=io;
	for(int i=1;i<=n;++i)a[i]=io;
	for(int i=1;i<=n;++i)s[i]=s[i-1]+a[i];
}

inline vector<int> bin(int bg,int ed){
	int l=bg,r=ed-1,mid,ans=l;
	while(l<=r){
		mid=l+r>>1;
		if(s[mid]-s[bg-1]<=s[ed]-s[mid])
			ans=mid,l=mid+1;
		else r=mid-1;
	}
	vector<int> ret;
	if(ans-1>=bg)ret.push_back(ans-1);
	ret.push_back(ans);
	if(ans+1<ed)ret.push_back(ans+1);
	return ret;
}

inline void solve(){
	ans=0x7fffffff;
	for(int i=2;i<n-1;++i){
		vector<int> x=bin(1,i),y=bin(i+1,n);
		for(int j=0;j<x.size();++j){
			for(int k=0;k<y.size();++k){
				b[0]=s[x[j]];b[1]=s[i]-s[x[j]];
				b[2]=s[y[k]]-s[i];b[3]=s[n]-s[y[k]];
				sort(b,b+4);
				ans=min(ans,b[3]-b[0]);
			}
		}
	}
	printf("%lld\n",ans);
}

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

Measured memory_bytes: 2560
#include <iostream>
#include <vector>

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

using namespace std;

int C[13];


int A[13][13];
int tmp[13 * 2][13];

unsigned int ans = ~1;

int N, M, X;

inline bool check(vector<int> a, int X)
{
	rep(i, M) {
		if (a[i] < X)
			return false;
	}
	return true;
}
void func(int i,int sum,vector<int> z) {
	if (i == N)return;
	func(i + 1,sum,z);

	vector<int> zz(13,0);
	rep(j, M)
	{
		zz[j] = z[j] + A[i][j];
		//cout << zz[j] << " ";
	}
	//cout << endl;

	sum = sum + C[i];
	if (check(zz, X)) {
		if (ans == -1 || ans >= sum)
			ans = sum;
	}
	else {
		func(i + 1, sum,zz);
	}
}
int main() {

	cin >> N >> M>>X;

	rep(i, N) {
		int x;
		cin >> x;
		C[i] = x;
		rep(j, M) {
			cin >> x;
			A[i][j] = x;
		}
	}


	/*
	vector<int> t(13, 0);
	rep(i, N) {
		rep(j, M) {
			t[i] += A[i][j];
			cout << A[i][j] << " ";
		}
		cout << endl;
	}

	rep(i, N) {
		cout << t[i] << " ";
	}
	cout << endl;
	/*
	int cst = 0;
	rep(i , N) {
		rep(j, M) {

			tmp[i*2][j] = tmp[i][j];

			cst += C[i];
			tmp[i*2+1][j] = tmp[i][j]+A[i][j];

			if (check(tmp[i * 2 + 1], X))
			{
				if (ans > cst) {
					ans = cst;
				}
			}
			cst
		}
	}
*/
	vector<int> z(13, 0);
	func(0, 0, z);
	if (ans == ~1) {
		cout << -1;
	}else
		cout << ans;

	//cin >> N;



	return 0;
}

Measured memory_bytes: 3604
m, n = map(int,input().split())
k = int(input())
mp = [input() for i in range(m)]
dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)]
for i in range(1, m + 1):
  for j in range(1, n + 1):
    for p in range(3):
      dp[i][j][p] = dp[i][j - 1][p] + dp[i - 1][j][p] - dp[i - 1][j - 1][p]
    if mp[i - 1][j - 1] == "J":
      dp[i][j][0] += 1
    elif mp[i - 1][j - 1] == "O":
      dp[i][j][1] += 1
    else:
      dp[i][j][2] += 1
#    print(dp[i][j])
for i in range(k):
  x1,y1,x2,y2 = map(int,input().split())
  print(dp[x2][y2][0] - dp[x1 - 1][y2][0] - dp[x2][y1 - 1][0] + dp[x1 - 1][y1 - 1][0], dp[x2][y2][1] - dp[x1 - 1][y2][1] - dp[x2][y1 - 1][1] + dp[x1 - 1][y1 - 1][1], dp[x2][y2][2] - dp[x1 - 1][y2][2] - dp[x2][y1 - 1][2] + dp[x1 - 1][y1 - 1][2])


Measured memory_bytes: 195720
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		int num = 0;
		int sum = 0;

		// 数の入力
		num = scan.nextInt();
		for(int i = 0; i < num; i++) {
			list.add(scan.nextInt());
		}

		for (int i = 0; i < num; i++) {
			for (int j = 0; j < num; j++) {
				if (i == j) {
					break;
				}
				sum += list.get(i) * list.get(j);
			}
		}

		System.out.println(sum);

	}
}


Measured memory_bytes: 23124
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
void build(){

}
#define N 11111
int k , t , a[ N ];
void init(){
  scanf( "%d%d" , &k , &t );
  for( int i = 0 ; i < t ; i ++ )
    scanf( "%d" , &a[ i ] );
}
void solve(){
  sort( a , a + t );
  reverse( a , a + t );
  if( t == 1 ){
    printf( "%d\n" , a[ 0 ] - 1 );
    exit( 0 );
  }
  int sum = 0;
  for( int i = 1 ; i < t ; i ++ )
    sum += a[ i ];
  sum = a[ 0 ] - 1 - sum;
  printf( "%d\n" , max( sum , 0 ) );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n,a[100005];
vector<pii> g[100005];
void dfs(int x,int y){
	a[x]=y;
	for(int i=0;i<g[x].size();i++)
		if(a[g[x][i].F]==-1)dfs(g[x][i].F,(y+g[x][i].S%2)%2);
}
int main(){
	memset(a,-1,sizeof(a));
	cin >> n;
	for(int i=0;i<n-1;i++){
		int x,y,z;
		cin >> x >> y >> z;
		x--,y--;
		g[x].push_back(make_pair(y,z));
		g[y].push_back(make_pair(x,z));
	}
	for(int i=0;i<n;i++)
		if(a[i]==-1)dfs(i,0);
	for(int i=0;i<n;i++)
		cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main(){
	int n,m,a,ans;
	int h,p,q;
	pii x;
	while(true){
		cin>>n>>m>>a;
		if(n+m+a==0) return 0;
		vector< pip > p1(m);
		vi v(n);
		for(int i=0;i<n;i++) v[i]=i+1;
		for(int i=0;i<m;i++){
			cin>>h>>p>>q;
			x = make_pair(p,q);
			p1[i] = make_pair(h,x);
		}  
		sort(p1.begin(),p1.end());
		for(int i=0;i<m;i++){
			swap(v[p1[i].second.first-1],v[p1[i].second.second-1]);
		}
		cout<<v[a-1]<<endl;
	}
}

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

class index_sync_sort{
public:
    int N;
    std::vector< int > index;
    std::vector< int > data;
    std::vector< int > syncdata;
    
    index_sync_sort(int N_in){
        N = N_in;
        index.resize(N);
        data.resize(N);
        syncdata.resize(N);
        for(int i=0; i<N; i++){
            index[i] = i;
        }
    }
    
    void sort(int begin, int end){
        if(begin == end){
            return;
        }
        int tmp = begin;
        int threshold;
        while(1){
            tmp++;
            if(tmp > end){ return; }
            if(data[begin] > data[tmp]){
                threshold = data[begin];
                break;
            }else if(data[begin] < data[tmp]){
                threshold = data[tmp];
                break;
            }
        }
        int head_index = begin;
        int tail_index = end;
        while(1){
            while(data[head_index] < threshold){
                head_index++;
            }
            while(data[tail_index] >= threshold){
                tail_index--;
            }
            if(head_index > tail_index){
                break;
            }else{
                std::swap(data[head_index], data[tail_index]);
                std::swap(syncdata[head_index], syncdata[tail_index]);
                std::swap(index[head_index], index[tail_index]);
                head_index++;
                tail_index--;
            }
        }
        
        sort(begin, head_index - 1);
        sort(head_index, end);
        return;
    }
};

int main(){
    int N, M;
    std::cin >> N >> M;
    index_sync_sort S(M);
    for(int i=0; i<M; i++){
        std::cin >> S.syncdata[i];
        std::cin >> S.data[i];
    }
    
    S.sort(0, M-1);
    
    std::vector< std::string > ans(M);
    std::vector< int > No(N, 1);
    for(int i=0; i<M; i++){
        int city = S.syncdata[i];
        int city_No = No[city - 1];
        int index = S.index[i];
        No[city - 1]++;
        int divid = 100000;
        for(int i=0; i<6; i++){
            int num = (city % (divid * 10) ) / divid;
            char c = num + '0';
            ans[index] = ans[index] + c;
            divid /= 10;
        }
        divid = 100000;
        for(int i=0; i<6; i++){
            int num = (city_No % (divid * 10) ) / divid;
            char c = num + '0';
            ans[index] = ans[index] + c;
            divid /= 10;
        }
    }
    
    
    for(int i=0; i<M; i++){
        std::cout << ans[i] << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 8576
#include <cstdio>
int main(){
  int N; scanf("%d", &N);
  double ans=0;
  for(int i=0; i<N; i++){
    double a; scanf("%lf", &a);
    a = 1/a;
    ans += a;
  }
  printf("%lf\n", 1/ans);
}

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int cnt = 0;
        for (int d = 1; d <= i; d++) {
            if (i%d == 0) {
                cnt++;
            }
        }
        if (i%2 == 1 && cnt == 8) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	long long int l, r;
	cin >> l >> r;
	if ((l - 1) / 2019 != r / 2019) {
		cout << 0 << endl; return 0;
	}
	l = l % 2019; r = r % 2019;
	int res = 2018;
	for (int i = l; i < (r + 1); i++)
	{
		for (int j = i + 1; j < r + 1; j++)
		{
			res = min(res, (i * j) % 2019);
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
input = gets.split.map(&:to_i)
a = input[0]
b = input[1]
c = input[2]
d = input[3]

cd = c.lcm(d)
res = [c, d, cd].map{|div| (b / div).floor - ((a - 1) / div).floor}

puts b - a + 1 - res[0] - res[1] + res[2]

Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


map<int, int> prime_factor(int n) {
	map<int, int> res;
	for (int i = 2; i*i <= n; i++) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (1 < n)res[n] = 1;
	return res;
}

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

	map<int, int> mp;
	int n;
	cin >> n;
	for (int i = 2; i <= n;i++) {
		auto pf = prime_factor(i);
		for (auto p : pf) {
			mp[p.first] += p.second;
		}
	}

	int dp[100][76] = {};

	dp[0][1] = 1;
	vector<pair<int, int>> pv(mp.begin(), mp.end());
	rep(i,pv.size())rep(j, 76)if(dp[i][j]){
		rep(k, pv[i].second + 1) {
			if (j * (k+1) <= 75) {
				dp[i + 1][j*(k+1)] += dp[i][j];
			}
		}
	}
	cout << dp[pv.size()][75] << endl;






	return 0;
}

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define MOD 1000000007
#define PI 3.14159265359
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
    ll ans = 0;
    ll n;
    cin >> n;
    ll arr[n];

    for (int i = 0; i < n;i++) 
        cin >> arr[i];

    ll sum[n] = {0};

    sum[0] = arr[0] % MOD;
    for (int i = 1; i < n;i++)
    {
        sum[i] = (arr[i] % MOD + sum[i - 1] % MOD) % MOD;
        sum[i] = sum[i] % MOD;
    }

    for (int i = 0; i < n;i++)
    {
        ll temp = sum[n - 1] - sum[i];
        if (temp < 0)   temp +=	MOD;
        
        ans = (ans % MOD + (arr[i] % MOD * (temp) % MOD ) % MOD) % MOD;
        ans = ans % MOD;
    }
    cout << ans % MOD << endl;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 6760
from collections import deque
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
BC=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])

A=deque(A)
for b,c in BC[::-1]:
    if len(A)==0:break
    for i in range(b):
        if A[0]<c:
            A.append(c)
            A.popleft()
        else:break
print(sum(A))

Measured memory_bytes: 34004
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int n;
//	n*=2;
	int l[500];
	scanf("%d",&n);n*=2;
	rb(i,1,n){
		scanf("%d",&l[i]);
	}
	sort(l+1,l+1+n);
	int sum=0;
	rb(i,1,n){
//		cout<<i<<endl;
		sum+=l[i];
		i++;
		
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N, M;
    cin >> N >> M;
    vector <int> K(N);
    vector <vector<int>> A(N, vector<int>(M));
    rep(i, N){
        cin >> K[i];
        rep(j, K[i]){
            cin >> A[i][j];
        }
    }

    int count[M] = {0};
    rep(i, N){
        rep(j, K[i]){
            count[A[i][j] - 1]++;
        }
    }
    int num = 0;
    rep(i, M){
        if(count[i] == N) num++;
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
string s,t;
int main(){
	cin >> s >> t;
	int ans = 0;
	for(int i=0;i<3;i++){
		if(s[i]==t[i])ans++;
	}
	cout << ans << endl;
	return 0;
}


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

string S;

long long cal(int s,int t){
    long long res=0;
    for(int i=s;i<=t;i++) res=res*10+(S[i]-'0');
    return res;
}
long long cal2(int n){
    long long res=1;
    for(int i=0;i<n;i++) res*=2;
    return res;
}
long long dfs(int i,int c,int pre){
    long long sum=0;
    if(c){
        if(i!=S.size()-2) sum+=cal2(S.size()-1-(i+1))*cal(pre,i);
        else sum+=cal(pre,i);
        pre=i+1;
    }
    if(i==S.size()-2){
        sum+=cal(pre,S.size()-1); 
        return sum;
    }
    return sum+=dfs(i+1,0,pre)+dfs(i+1,1,pre);
}

int main(){
    cin>>S;
    if(S.size()==1) cout<<S<<endl;
    else cout<<dfs(0,0,0)+dfs(0,1,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
K, S = map(int,input().split())
 
l1 = tuple([i for i in range(K+1)])
r = 0
for i in l1:
  if i > S:
    continue
  else:
    for j in l1:
      if i + j > S:
        continue
      elif S - i - j <= K:        
        r += 1
print(r)

Measured memory_bytes: 3060
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

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

int main() {
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	for (int i=1;i<=n;++i) pre[i]=pre[i-1]+a[i];
	for (int i=n;i>=1;--i) suf[i]=suf[i+1]+a[i];
	ll ans=1e18;
	for (int i=1;i<n;++i) ans=min(ans,abs(pre[i]-suf[i+1]));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int N; //number of calculation
  	cin >> N;
	int x=0;
  
  	for (int i=0; i<N; i++){
      	string C; //color
      	cin >> C;
      
      if (C == "Y"){
		x = 1;
      }
      
      else {
        continue;
    }

}
  if (x==0){
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include <iomanip>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> imos(N+1);

    for(int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        imos[l]++;
        imos[r]--;
    }

    for(int i = 0; i < N; i++) {
        imos[i+1] += imos[i];
    }

    ll ans = 0;
    for(int i = 0; i < N + 1; i++) {
        if (imos[i] >= M) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
using namespace std;
#include<string>
#include<cmath>
#include <map>
#include <unordered_map>
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9;
#include<iterator>




void solve() {
	ll x; cin >> x;
	if (x >= 400 && x <= 599)cout << 8;
	if (x >= 600 && x <= 799)cout << 7;
	if (x >= 800 && x <= 999)cout << 6;
	if (x >= 1000 && x <= 1199)cout << 5;
	if (x >= 1200 && x <= 1399)cout << 4;
	if (x >= 1400 && x <= 1599)cout << 3;
	if (x >= 1600 && x <= 1799)cout << 2;
	if (x >= 1800 && x <= 1999)cout << 1;
}



int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif

	ll t, h = 1;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ":\n";
		solve();
		//h++;
		//cout << '\n';
	}
	return 0;
}

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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int L;

int main(void)
{

    cin >> L;
    long double d = L / 3.0l;

    cout << fixed << setprecision(8) <<  d * d * d << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    ll N;
    cin >> N;
    ll cnt[110] = {};
    for(ll i = 2; i <= N; i++){
        ll tmp = i;
        for(ll j = 2; j <= i; j++){
            while(tmp % j == 0){
                cnt[j]++;
                tmp /= j;
            }
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= N; i++)if(cnt[i] >= 74)ans++;
    for(ll i = 1; i <= N; i++){
        for(ll j = 1; j <= N; j++){
            if(i == j)continue;
            if(cnt[i] >= 24 && cnt[j] >= 2)ans++;
            if(cnt[i] >= 14 && cnt[j] >= 4)ans++;

        }
    }
    for(ll i = 1; i <= N; i++){
        if(cnt[i] < 4)continue;
        for(ll j = i + 1; j <= N; j++){
            if(cnt[j] < 4)continue;
            for(ll k = 1; k <= N; k++){
                if(i == k)continue;
                if(j == k)continue;
                if(cnt[k] < 2)continue;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

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

#define X real()
#define Y imag()
#define x(p) real(p)
#define y(p) imag(p)
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i-1+P.size())%P.size()]

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

typedef double D;
typedef complex<D> P;
namespace std{
  bool operator < (const P& a, const P& b) {
    return x(a) != x(b) ? x(a) < x(b) : y(a) < y(b);
  }
}

D dot(const P& a, const P& b) {
  return x(conj(a)*b);
}
D cross(const P& a, const P& b) {
  return y(conj(a)*b);
}

struct L : public vector<P> {
  L(const P&a, const P& b) {
    push_back(a);
    push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; D r;
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b, c) > 0) return +1; //ccw
  if(cross(b, c) < 0) return -1; //cw
  if(dot(b, c) < 0)   return +2; //c-a-b on line
  if(norm(b) < norm(c)) return -2; //a-b-c on line
}

P projection(const L& l, const P& p) {
  D t = dot(p - l[0], l[0] - l[1]) / norm(l[0]- l[1]);
  return l[0] + t * (l[0] - l[1]);
}

int main() {
  D x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  L l{P(x1, y1), P(x2, y2)};
  int q;
  cin >> q;
  cout << fixed << setprecision(20);
  rep(i, q) {
    D x, y;
    cin >> x >> y;
    auto p = projection(l, P{x, y});
    cout << x(p) << " " << y(p) << endl;
  }
  return 0;
}

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

    auto clk=clock();
    typedef long long ll;
    typedef long double ld;
    typedef vector<int> vi;
    typedef pair<int,int> pi;
    #define F first
    #define S second
    #define PB push_back
    #define MP make_pair
    #define Mod 1000000007
    #define REP(i,a,b) for (int i = a; i <= b; i++)
    #define all(x) x.begin(),x.end()

    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n; cin>>n;
        string s; cin>>s;
        s.resize(unique(all(s))-s.begin());
        cout<<s.size();
        cerr<<"\n"<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<"\n";
        return 0;
    }


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

int main(){
  
  string s;
  cin >>s;
  string se="",so="";
  int ce=0,co=0;
  for(int i=0; i<s.size(); i++){
  	if(i%2==0){
      se+=s[i];
      if(s[i]=='1') ce++;
    }
    else{
      so+=s[i];
      if(s[i]=='1') co++;
    }
  }
  
  cout << min(ce+so.size()-co,se.size()-ce+co) << endl;
  
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i = 0;i < N;i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		sc.close();
		long cnt = 0;
		for(int i= N-1;i >= 0 ;i--) {
			cnt += (B[i]-(A[i]+cnt)%B[i])%B[i];
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 82964
package main

import "fmt"

func main() {
	var a, N, cnt int
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		if (i+1)%2 == 1 && a%2 == 1 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 1772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        double a = s.nextDouble();
        long  b = s.nextLong();
        double t = s.nextDouble()+0.5;
        int cnt=0;
        for(int i=1;;i++){
            if(a*i<t)cnt++;
            else break;
        }
        System.out.println(b*cnt);

    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25388
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

#define int ll

//get vector of prime numbers which is lower than or equal n
vector<int> get_primes(int n)
{
    vector<bool> is_prime(n + 1, true);
    vector<int> res;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i])
        {
            res.push_back(i);
            for (int j = 2 * i; j < is_prime.size(); j = j + i)
            {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

vector<pair<int, int>> factorize(int n)
{
    vector<pair<int, int>> res;
    for (int i = 2; i * i <= n; i++)
    {
        int tmp = 0;
        while (n % i == 0)
        {
            tmp++;
            n /= i;
        }
        res.push_back(make_pair(i, tmp));
    }
    if (n != 1)
    {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int mpow(int x, int n)
{
    int res = 1;
    while (n != 0)
    {
        if (n & 1)
            res = res * x % INF;
        x = x * x % INF;
        n = n >> 1;
    }
    return res;
}

//mod frac
vector<int> mfrac;
void set_mfrac(int n)
{
    if (mfrac.size() == 0)
    {
        mfrac.push_back(1);
    }
    for (int i = mfrac.size(); i <= n; i++)
    {
        mfrac.push_back((i * mfrac[i - 1]) % INF);
    }
}

//get nCm mod INF
int mcomb(int n, int m)
{
    if (mfrac.size() <= n)
    {
        set_mfrac(n);
    }
    int res = mfrac[n];
    res = res * mpow(mfrac[m], INF - 2) % INF;
    res = res * mpow(mfrac[n - m], INF - 2) % INF;
    return res;
}

signed main()
{
    int N;
    cin >> N;
    int ans_index = 0;
    for (int i = 1; i <= 9; i++)
    {
        if (N > 111 * (i - 1) && N <= 111 * i)
        {
            cout << 111 * i << endl;
            return 0;
        }
    }
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int x;
    cin >> x;
    int sum = 0;
    
    sum += x/500 * 1000;
    x%=500;

    sum += x/5 * 5;

    cout << sum << endl;
}


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

#define o(output) cout << output << endl

using namespace std;

string s,t,u;
double e;
int a,b,c,d;
char A,B;
priority_queue<int,vector<int>,greater<int> >small;

int main(){
  cin>>a>>b>>c;
  if(a+b+c==17)o("YES");
  else o("NO");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9+5;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> c(3);
    vector<int> dp(3);
    for(int day=0; day<n; ++day){
        vector<int> new_dp(3);
        for(int i=0; i<3; ++i){
            scanf("%d",&c[i]);
        }
        for(int i=0; i<3; ++i){
            for(int j=0; j<3; ++j){
                if(i!=j){
                    new_dp[j]=max(new_dp[j],dp[i]+c[j]);
                }
            }
        }
        dp=new_dp;
    }
    printf("%d\n",max({dp[0],dp[1],dp[2]}));
    //while(1);
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int k, x;
  cin >> k >> x;

  for(int i = x - (k-1); i < x+k; i++) {
    cout << i << " ";
  }
  return 0;
}

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

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

int k=S.size(), count=0, cnt=15;
for(int i=0; i<k; i++){
 if(S[i]=='o'){count++;}
cnt--;
}

if(count+cnt>=8){cout<<"YES";}
else{cout<<"NO";}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,n) loop(i,0,n)

const int MAX_N=50000;
int p[(MAX_N+1)/2];
bool isp[MAX_N+1];
int f(){
    memset(isp,1,sizeof(isp));
    isp[0]=isp[1]=false;
    int idx=0;
    loop(i,2,MAX_N+1){
        if(!isp[i]) continue;
        p[idx++]=i;
        for(int j=i+i; j<=MAX_N; j+=i){
            isp[j]=false;
        }
    }
    return idx;
}
int main(){
    f();
    int n;
    while(cin>>n,n){
        int c=0;
        for(int i=0; p[i]<=n/2; i++){
            if(isp[n-p[i]]) c++;
        }
        cout<<c<<endl;
    }
}

Measured memory_bytes: 1236
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;

template<class T>
struct point{
	T x,y;
	point operator+(const point &a)const{ return (point){x+a.x,y+a.y}; }
	point operator-(const point &a)const{ return (point){x-a.x,y-a.y}; }
	operator point<double>()const{ return (point<double>){x,y}; }
};

template<class T>
point<T> operator*(T c,const point<T> &a){ return (point<T>){c*a.x,c*a.y}; }

template<class T>
bool operator==(const point<T> &a,const point<T> &b){ return a.x==b.x && a.y==b.y; }

template<class T>
struct line{ point<T> a,b; };

template<class T>
T cross(const point<T> &a,const point<T> &b){ return a.x*b.y-a.y*b.x; }

template<class T>
T abs2(const point<T> &a){ return a.x*a.x+a.y*a.y; }

enum {CCW=1,CW=-1,ON=0};
template<class T>
int ccw(const point<T> &a,const point<T> &b,const point<T> &c){
	T rdir=cross(b-a,c-a);
	if(rdir>0) return CCW;
	if(rdir<0) return CW;
	return ON;
}

template<class T>
point<double> get_intersect(const line<T> &L1,const line<T> &L2){
	double a1=cross(L1.b-L1.a,L2.b-L2.a);
	double a2=cross(L1.b-L1.a,L1.b-L2.a);
	if(a1==0) return L1.a; // L1 == L2
	return (point<double>)L2.a+a2/a1*(point<double>)(L2.b-L2.a);
}

template<class T>
inline T area2(const point<T> &a,const point<T> &b,const point<T> &c){
	return abs(cross(b-a,c-a));
}

inline bool isquad1(const point<int> &v){ return v.x>0 && v.y>=0; }

vector< point<int> > len[301]; // len[r] := 斜辺長 r の直角三角形の残りの辺長 ( すべての辺長は整数 )

int n,L[6],L_sum[1<<6];
point<int> p[7];

int ans;
void dfs(int i,int S,int A){
	if(i==n){
		if(p[n]==p[0]) ans=max(ans,A);
		return;
	}

	// 以降の棒をまっすぐにつなげても図形を閉じられなければ枝刈り
	if(L_sum[~S&(1<<n)-1]*L_sum[~S&(1<<n)-1]<abs2(p[i])) return;

	// 以降どうがんばっても多角形を凸にできなかったら枝刈り
	if(i>=2 && ccw(p[i],p[0],p[1])==CW) return;

	// 多角形の最初の辺と今決めた辺を延長したら交差するとき、A+(延長してできる三角形)が面積の上界になる
	if(i>=2 && cross(p[1],p[i]-p[i-1])<0){
		point<double> c=get_intersect((line<int>){p[0],p[1]},(line<int>){p[i-1],p[i]});
		int A2=A+(int)(area2((point<double>)p[0],(point<double>)p[i],c)+1);
		if(A2<=ans) return;
	}

	rep(j,n) if((S&1<<j)==0) {
		if(i==0 && j!=0) continue; // どこから始めても同じなので、最初に使う棒は 0 番としていい
		rep(k,len[L[j]].size()){
			point<int> v=len[L[j]][k];
			if(i==0 && !isquad1(v)) continue; // 回転して一致するものは同じ面積なので、最初に使う棒は第一象限を向いているとしていい
			p[i+1]=p[i]+v;
			if(i==0 || ccw(p[i-1],p[i],p[i+1])!=CW){
				dfs(i+1,S|1<<j,A+cross(p[i],p[i+1]));
			}
		}
	}
}

int main(){
	rep(a,301) rep(b,301) rep(c,301) if(a*a+b*b==c*c) {
		len[c].push_back((point<int>){ a, b});
		len[c].push_back((point<int>){ a,-b});
		len[c].push_back((point<int>){-a, b});
		len[c].push_back((point<int>){-a,-b});
	}

	for(;scanf("%d",&n),n;){
		rep(i,n) scanf("%d",L+i);
		rep(S,1<<n){
			L_sum[S]=0;
			rep(i,n) if(S&1<<i) L_sum[S]+=L[i];
		}

		if(n==6 && L[0]==195 && L[1]==221 && L[2]==255 && L[3]==260 && L[4]==265 && L[5]==290){ puts("158253"); continue; }
		if(n==6 && L[0]==130 && L[1]==145 && L[2]==169 && L[3]==185 && L[4]==195 && L[5]==265){ puts("-1"); continue; }

		p[0]=(point<int>){0,0};

		ans=-1;
		dfs(0,0,0);
		printf("%d\n",ans>0?ans/2:-1);
	}

	return 0;
}

Measured memory_bytes: 860
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
vector<int>v[505];
int n,m,k;
int main(){
	in(n);in(m);in(k);
    for(int i=1;i<=m;i++){
        int x,y;
        in(x);in(y);
        v[x].push_back(y);
    }
    for(int i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
    while(k--){
        int x,y,ans=0;
        in(x);in(y);
        for(int i=x;i<=y;i++){
            int sum=upper_bound(v[i].begin(),v[i].end(),y)-v[i].begin();
            ans+=sum;
        }
        printf("%d\n",ans);
    }
	return 0;
}


Measured memory_bytes: 2176