akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 4e5 + 5;
const ll maxm = 1e3 + 5;
ll n, m, k, l = 1, r = 1, tot = 0, cnt = 0;
ll a[maxn], b[maxn];
ll fa[maxn], fb[maxn];
int main(){
    cin >> n >> m >> k;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        fa[i] = fa[i - 1] + a[i];
    }
    for(int i = 1;i <= m;i++){
        cin >> b[i];
        fb[i] = fb[i - 1] + b[i];
    }
    for(int i = 0;i <= n;i++){
        ll l = 1, r = m, ans = 0;
        if(fa[i] > k){
            break;
        }
        while(l <= r){
            ll mid = (l + r) >> 1;
            if(fb[mid] <= k - fa[i]){
                ans = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        // cout << ans << endl;
        cnt = max(cnt, i + ans);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 9852
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define A first
#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
#define M 1005
const ll inf=1e17;
ll a[M],b[M],c[M],res,x[M],y[M],z[M];
vector<ll>Q;
int n,m;
bool cmp(ll a,ll b){
	return a>b;
}
void cl(int s){
	int i,j;
	ll d,sum=0;
	for (i=0;i<n;i++){
		if (s&1)a[i]=x[i];
		else a[i]=-x[i];
		if (s&2)b[i]=y[i];
		else b[i]=-y[i];
		if (s&4)c[i]=z[i];
		else c[i]=-z[i];
		d=a[i]+b[i]+c[i];
		Q.pb(d);	
	}
	sort(Q.begin(),Q.end(),cmp);
	for (i=0;i<m;i++){
		sum+=Q[i];
	}
	Q.clear();
	Max(res,sum);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	freopen("1.in","r",stdin);
	read(n); read(m);
	int i;
	for (i=0;i<n;i++){
		read(x[i]); read(y[i]); read(z[i]);
	}
	for (i=0;i<8;i++){
		cl(i);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>

using namespace std;


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

  int ans = max(A+B, A-B);

  ans = max(ans, A*B);


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
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;

int cal(int n, int ans, int data)
{
    if (n)
    {
        ans += data;
    }
    else
    {
        ans -= data;
    }
    return ans;
}

void pans(int i, int j, int k, int *data)
{
    cout << data[0];
    int op[4] = {0, i, j, k};
    for (int x = 1; x < 4; x++)
    {
        if (op[x])
        {
            cout << "+";
        }
        else
        {
            cout << "-";
        }
        cout << data[x];
    }
    cout << "=7";
    cout << endl;
}

int main()
{
    string s;
    int data[4];
    cin >> s;
    rep(i, 4)
    {
        data[i] = (int)(s[i] - '0');
    }

    rep(i, 2)
    {
        rep(j, 2)
        {
            rep(k, 2)
            {
                int ans = data[0];
                ans = cal(i, ans, data[1]);
                ans = cal(j, ans, data[2]);
                ans = cal(k, ans, data[3]);
                if (ans == 7)
                {
                    pans(i, j, k, data);
                    return 0;
                }
            }
        }
    }
}

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

int array[100][100];		//??????
int linevec[100];			//???????????????
int ans;

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> array[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> linevec[i];
	}
	for (int i = 0; i < n; i++) {
		ans = 0;
		for (int j = 0; j < m; j++) {
			ans += array[i][j] * linevec[j];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
s={}
t={}
num=0
n=input()
for i in range(int(n)):
  a=input()
  if a in s.keys():
    s[a]+=1
  else:
    s[a]=1
m=input()
for j in range(int(m)):
  b=input()
  if b in t.keys():
    t[b]+=1
  else:
    t[b]=1
for x in s.keys():
  y=s[x]
  if x in t.keys():
    y-=t[x]
  if y>num:
    num=y
print(str(num))



Measured memory_bytes: 3064
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }

    if a+b>=c {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 2168
#include <iostream>

int main()
{
  int A, B, aux;

  std::cin >> A >> B;
  aux = A;
  if((A+B) > (A-B) & (A+B) > (A*B)){
     aux = A+B;
    }else{
      if((A-B) > (A+B) & (A-B) > (A*B)){
        aux = A-B;
      }else{
        if((A*B) > (A+B) & (A*B) > (A-B)){
          aux = A*B;
  }}}
        
  std::cout << aux <<std::endl;

  return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var result;
    const N = parseInt(input.shift());
    const SP = [];
    for (var i = 0; i < N; i++) {
        SP.push({
            I: i+1,
            S: input[i*2],
            P: parseInt(input[i*2+1])
        })
    }
    
    SP.sort((a,b) => {
        var stComp = a.S.localeCompare(b.S);
        if(stComp == 0) {
            return -a.P + b.P;
        }
        return stComp;
    })
    SP.forEach(value => console.log(value.I));
}

// 1行入力の場合
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

// 改行で分割
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

int main() {
    long long n,k;
    cin >> n >> k;
    long long a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    long long mod=1000000007;
    long long b=0,c=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i]>a[j]) b++;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j]) c++;
        }
    }
    long long ans;
    long long d=(k*(k-1)/2LL)%mod;
    ans=(c*k+b*d)%mod;
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(string, S, N);
    set<string> A;
    FOR(s, S)
    {
        A.insert(s);
    }
    OUT(A.size());
}

Measured memory_bytes: 24988
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ld w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(9)<<w*h/2;
    if(x==w/2&&y==h/2) cout<<" "<<1;
    else cout<<" "<<0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main()
{
       int n,d,x,c=0,s;
       cin>>n>>d>>x;
       for(int i=0;i<n;i++){
        cin>>s;
        for(int j=1;j<=d;j++)
            if((s*j+1)<=d)
            c++;
       }
       cout<<c+n+x;
    return 0;
   }

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

constexpr int MOD = 1e9+7;

constexpr int COMB_MAX = 2e6+10;
ll fac[COMB_MAX], finv[COMB_MAX], inv[COMB_MAX];

void initComb(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COMB_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;
    }
}

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

int main(void){
  Cin(int, x, y);
  int s = 2*y-x, t = 2*x-y;
  if(s < 0 || t < 0 || s % 3 != 0 || t % 3 != 0) Return(0);
  s /= 3, t /= 3;
  initComb();
  Cout(comb(s+t, s));
}


Measured memory_bytes: 47232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int n, m, dp[100005];
vector <int> inv[100005];

int dfs(int x){
	int &ret = dp[x];
	if(ret != -1)
		return ret;
	ret = 0;
	for(vector <int>::iterator i = inv[x].begin() ; i != inv[x].end() ; ++i){
		int o = *i;
		ret = max(ret, dfs(o) + 1);
	}
	return ret;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 0 ; i < m ; ++i){
	int x, y;
	cin >> x >> y;
	inv[y].push_back(x);
}
memset(dp, -1, sizeof(dp));
for(int i = 1 ; i <= n ; ++i){
	if(dp[i] == -1){
		dfs(i);
	}
}
cout << *max_element(dp + 1, dp + n + 1) << endl;

return 0;
}



Measured memory_bytes: 9088
# coding: utf-8
# Your code here!

N, M = map(int, input().split(" "))
A = {}
B = {}

for i in range(N):
    a, b = map(int, input().split(" "))
    A[i] = a
    B[i] = b

cost = 0
for k, v in sorted(A.items(), key=lambda x: x[1]):
    if M - B[k] > 0:
        M -= B[k]
        cost += v * B[k]
    else:
        cost += v * M
        break

print(cost)

Measured memory_bytes: 33424
package main

import "fmt"

func main() {
	// Code for C - Step
	var N int
	fmt.Scanf("%d", &N)

	A := make([]float64, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%f", &A[i])
	}

	var ans float64
	var temp float64 = A[0]
	for i := 1; i < N; i++ {
		if A[i]-temp < 0 {
			ans += -(A[i] - temp)
			//fmt.Println(i, -(A[i] - temp))
			temp = A[i] - (A[i] - temp)
		} else {
			temp = A[i]
		}
	}

	fmt.Println(int(ans))
}


Measured memory_bytes: 6492
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanLines)
	area := 0
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		area = 0

		for i := 1; i < 600/n; i++ {
			area += n * (n * i) * (n * i)
		}

		fmt.Println(area)

	}
}


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

int main() {
   int a, b, c, d;
   cin >> a >> b >> c >> d;

   cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define INF 1e99
#define EPS 1e-6

typedef complex<double> P;
typedef const P &rP;
typedef pair<P,P> P2;
typedef pair<double,double> pdd;
typedef pair<double,bool> pdb;

double dot(rP va, rP vb){
	return real(va) * real(vb) + imag(va) * imag(vb);
}

P2 intersectcircle(rP p1, double r1, rP p2, double r2){
	double d = abs(p2 - p1);
	double phi = arg(p2 - p1);

	double theta = acos((d * d + r1 * r1 - r2 * r2) / (2.0 * d * r1));
	return P2(p1 + polar(r1, phi + theta), p1 + polar(r1, phi - theta));
}

pdd intersectlc(rP p1, rP p2, rP pc, double r){
	P v12 = p2 - p1;
	P v1c = pc - p1;
	
	vector<P> ret;

	double a = norm(v12);
	double b = -dot(v12, v1c);
	double c = norm(v1c) - r * r;

	double D = b * b - a * c;
	if( D < 0.0 ){
		return pdd(INF, INF);
	}

	double t1 = (-b - sqrt(D)) / a;
	double t2 = (-b + sqrt(D)) / a;
	return pdd(t1, t2);
}

int n;
P pc[105];
double r[105];
P intr[105][2];
double dp[105][2];

bool reachable(int a, int k1, int b, int k2){
	vector<pdb> v;
	
	for(int i = a; i <= b + 1; ++i){
		pdd p = intersectlc(intr[a][k1], intr[b][k2], pc[i], r[i]);
		v.push_back( pdb(p.first, false) );
		v.push_back( pdb(p.second, true) );
	}
	
	sort(v.begin(), v.end());
	
	int c = 0;
	for(int i = 0; i < v.size(); ++i){
		if( v[i].first > EPS && c == 0 ) return false;
		if( v[i].first > 1.0 - EPS ) return true;

		if( v[i].second ){
			--c;
		}
		else{
			++c;
		}
	}
	
	return true;
}

int main(){
	double x, y;
	while( scanf("%d", &n), n != 0 ){
		for(int i = 1; i <= n; ++i){
			scanf("%lf%lf%lf", &x, &y, &r[i]);
			pc[i] = P(x, y);
		}
		
		pc[0] = pc[1];
		r[0] = r[1];
		pc[n + 1] = pc[n];
		r[n + 1] = r[n];
		
		for(int i = 1; i <= n - 1; ++i){
			P2 p = intersectcircle(pc[i], r[i], pc[i+1], r[i+1]);
			intr[i][0] = p.first;
			intr[i][1] = p.second;
		}
		
		intr[0][0] = intr[0][1] = pc[1];
		intr[n][0] = intr[n][1] = pc[n];
		
		fill(*dp, *dp + sizeof(dp) / sizeof(double), INF);
		dp[0][0] = dp[0][1] = 0.0;
		
		for(int i = 0; i < n; ++i)
		for(int j = i + 1; j <= n; ++j)
		for(int k1 = 0; k1 < 2; ++k1)
		for(int k2 = 0; k2 < 2; ++k2){
			if( reachable(i, k1, j, k2) ){
				double d = abs(intr[i][k1] - intr[j][k2]);
				dp[j][k2] = min(dp[j][k2], dp[i][k1] + d);
			}
		}
		
		printf("%f\n", dp[n][0]);
	}
}

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

void CountingSort(int*, int*, int);
int n;
main() {
  int i,*A,*B;
  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n+1);
  B = (int *)malloc(sizeof(int) * n+1);
  if(A == NULL) {
    printf("メモリが確保できません\n");
    exit(EXIT_FAILURE);
  }
  if(B == NULL) {
    printf("メモリが確保できません\n");
    exit(EXIT_FAILURE);
  }

  for(i = 1; i <= n; i++) {
    scanf("%d",&A[i]);
  }

  CountingSort(A, B,10000);

  for(i = 1; i <= n; i++) {
    if(i > 1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  free(A);
  free(B);

  return 0;
}

void CountingSort(int *A,int *B, int k) {
  int i,j;
  int C[10001];
  for(i = 0; i < k; i++) {
    C[i] = 0;
  }

/* C[i]にiの出現数を記録する。 */
  for(j = 1; j < n+1; j++) {
    C[A[j]]++;
  }

/* C[i]にi以下の数の出現数を記録する */
  for(i = 1; i < k; i++) {
    C[i] = C[i] + C[i-1];
  }

  for(j = n; j > 0; j--) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16056
from fractions import gcd
from functools import reduce
def lcm_base(x,y):
    return (x*y)//gcd(x,y)
def lcm(numbers):
    return reduce(lcm_base,numbers,1)
n=int(input())
t=[0]*n
for i in range(n):
  t[i]=int(input())
print(lcm(t))

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
vvint graph;
int N;
map<int,vint> dist;
void dfs(int start,int cur,int prev = -1,int d = 0)
{
    chmin(dist[start][cur],d);
    for (auto &&i : graph[cur])
    {
        if(i == prev)
        continue;
        dfs(start,i,cur,d+1);
    }
    
}
int main()
{
    cin>>N;
    graph.resize(N);
    dist[0].resize(N);
    fill_v(dist[0],INT_MAX);
    dist[N-1].resize(N);
    fill_v(dist[N-1],INT_MAX);
    for (size_t i = 0; i < N-1; i++)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(0,0);
    dfs(N-1,N-1);
/*    for (size_t i = 0; i < N; i++)
    {
        cout<<i<<" : "<<dist[0][i]<<endl;
    }
    cout<<endl;
    for (size_t i = 0; i < N; i++)
    {
        cout<<i<<" : "<<dist[N-1][i]<<endl;
    }*/
    int b=0,w=0;
    for (size_t i = 0; i < N; i++)
    {
        if(dist[0][i] <= dist[N-1][i])
        {
            w++;
        }
        else
        {
            b++;
        }
        
    }
    if(w > b)
    cout<<"Fennec";
    else
    {
        cout<<"Snuke";
    }
    


    return 0;
}

Measured memory_bytes: 17240
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

vector<int> len;
vector<map<int, int> > value;

int dfs(string s, int& k)
{
    if(isdigit(s[k])){
        int ret = 0;
        while(k < s.size() && isdigit(s[k])){
            ret *= 10;
            ret += s[k] - '0';
            ++ k;
        }
        return ret;
    }

    char c = s[k];
    k += 2;
    int a = dfs(s, k);
    ++ k;

    if(a == -1 || value[c].find(a) == value[c].end())
        return -1;
    else
        return value[c][a];
}

bool substitute (string& s)
{
    char a=s[0];
    int eq=s.find('='),idx=0;
    int i=dfs(s.substr(2,eq-3),idx);
    if(i==-1 || len[a]<=i) return false;
 
    idx=0;
    int res=dfs(s.substr(eq+1),idx);
    if(res == -1)
        return false;
    value[a][i]=res;
    return true;
}

int solve(vector<string>& s)
{
    len.assign(128, 0);
    value.assign(128, map<int, int>());

    int n = s.size();
    for(int i=0; i<n; ++i){
        if(s[i].find('=') == string::npos){
            int k = 2;
            len[s[i][0]] = dfs(s[i], k);
        }else{
            if(!substitute(s[i]))
                return i + 1;
        }
    }

    return 0;
}

int main()
{
    for(;;){
        vector<string> s;
        for(;;){
            string t;
            cin >> t;
            if(t == ".")
                break;
            s.push_back(t);
        }

        if(s.empty())
            return 0;

        cout << solve(s) << endl;
    }
}

Measured memory_bytes: 1340
#include<iostream>
using namespace std;
int main()
{int n,m,x,i,y,z,a;
cin>>n>>m>>x;
z=0,y=0;
for(i=0;i<m;i++){
scanf("%d",&a);
if(a<x)z++;
else y++;}
printf("%d\n",min(z,y));
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;

int power(int x,int n){
  if(x==0) return 0;
  if(n==0) return 1;
  if(n==1) return x;
  int res = power(x,n/2);
  res = (res*res)%mod;
  if(n%2) return (res*x)%mod;
  return res;
}

int nCr(int n, int r)
{ 
    if (r == 0) 
        return 1; 
    vector <int> f(n + 1); 
    f[0] = 1; 
    for (int i = 1; i <= n; i++) 
        f[i] = (f[i-1]*i)%mod; 
  
    return ((f[n]*power(f[r],mod-2))%mod * power(f[n-r],mod-2))%mod; 
} 
  

int32_t main(){
     int n; cin>>n;
     int count=0;
     int ans = 0;
     while(n--){
        int x,y; 
        cin>>x>>y;
        if(x==y) {count++;}
        else count=0;
        ans = max(ans,count);
     }
       ans>=3 ? cout<<"Yes\n" : cout<<"No\n";
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;
int n, ans;

bool f(int l) {
	if(l % 2 != 0) { return false; }
	inc(i, l / 2) {
		if(s[i] != s[l / 2 + i]) { return false; }
	}
	return true;
}

int main() {
	cin >> s;
	
	n = s.size();
	dec(i, n) {
		if(f(i)) { ans = i; break; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
a.sort(reverse=True)
b=[0]
for i in a:
    b.append(i+b[-1])
ans=1
for i in range(1,n):
    if b[i]-b[i-1]<=2*(b[-1]-b[i]):
        ans+=1
    else:break
print(ans)

Measured memory_bytes: 14320
n=int(input())
d={}
a=list(map(int,input().split()))
for ii in a:
    d[ii]=d.get(ii,0) + 1
ans=0
for i in d:
    ans+=(d[i]*(d[i]-1))//2
for i in a:
    p=(d[i]*(d[i]-1))//2
    q=((d[i]-1)*(d[i]-2))//2
    print(ans -p+q)
    

Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b;
	cin >> a >> b;
  	
  	int ans = 0;
  	rep(i, 2){
		if(a > b){
			ans += a;
          	a--;
        }
      	else{
			ans += b;
          	b--;
        }
    }

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


Measured memory_bytes: 256
n = int(input())
# graph = [[-1]*n]*n この初期化の仕方はよくない。すべてが同じ要素だと判断されて一個要素を変えるとすべてに反映される
graph = [[-1]*n for _ in range(n)]
for i in range(n):
  a = int(input())
  for _ in range(a):
    x, y = map(int, input().split())
    graph[i][x-1] = y
    
ans = 0
# n人が正直or不親切の場合を全探索
for i in range(2**n):
  honesty = [0]*n
  for j in range(n):
    if ((i >> j) & 1):
      honesty[j] = 1 # 0~n-1までの2進数表記

  ok = True # 矛盾しないかのフラッグok
  for j in range(n): # 一人ずつ証言と矛盾しないか確かめる
    if honesty[j]: # 正直の時は証言は確実でなければならない
      for k in range(n): # その人の他の人(自分も含める-1だから関係ないけど)への証言
        if graph[j][k] == -1: continue
        if graph[j][k] != honesty[k]: ok = False # 証言の有向グラフと仮定のhonestyが違ったらこれは矛盾している
  if ok: # 矛盾せずにここまでこれたbitの中でフラグが一番多いのが勝ち
    ans = max(ans, honesty.count(1))

print(ans)


Measured memory_bytes: 44380
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数s 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(alll(v));
  return v;
}

int main() {
    ll n,m,l;
    cin>>n>>m;
    ll a = 0, b = 1000000;
    rep(i, m) {
        ll x,y;
        cin>>x>>y;
        a = max(a,x);
        b= min(b,y);
    }
    pr(max((ll)0,b-a+1));
    return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define MOD 1000000007

void solveB()
{
    int H, W;
    cin >> H >> W;

    if (H == 1 or W == 1)
    {
        cout << 1 << endl;
        return;
    }
    int h = H / 2, w = W / 2;
    int hh = H % 2, ww = W % 2;
    ll ans = (ll)h * w * 2 + hh * w + h * ww + hh * ww;
    cout << ans << endl;
}

int main()
{
    solveB();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <limits>
#define ll long long
using namespace std;
int main(){
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    for(ll i=0;i<K;i++){
        if(A>=B&&A>=C){
            A = A*2;
        }else if(B>=C&&B>=A){
            B*=2;
        }else{
            C*=2;
        }
    }
    cout << A+B+C << endl;
}

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

vector<int> prime(100005, 1);

void prime_number(){
    for (int i=2; i * i < 100005; i++){
        if(prime[i]){
            for (int j = i * 2; j < 100005; j += i){
                prime[j] = 0;
            }
        }
    }
}

signed main(void){
    int q; cin >> q;
    prime_number();
    // 
    
    vector<int> num_list(100004, 0);
    for (int i=1; i<100004; i++){
        if (i%2 == 1 && prime[i] && prime[(i + 1) / 2]) num_list[i] = 1;
        else num_list[i] = 0;
    }
    num_list[1] = 0;
    // for (int i=1; i< 54; i++) if(num_list[i]) cout << i << " ";
    // cout << endl;
    vector<int> s(100005, 0);
    for (int i=1; i<100005; i++){
        s[i] = s[i-1] + num_list[i];
    }
    for (int i=0;i <q; i++){
        int l, r;
        cin >> l >> r;
        cout << s[r] - s[l-1] << endl;
        // if (l == r){
        //     // if (num_list[l]) cout << 1 << endl;
        //     cout << s[r] - s[l-1] << endl;
        // }else{
        //     cout << s[r] - s[l-1] << endl;
        // }
        
    }
}


Measured memory_bytes: 5556
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n,d;

	cin>>d>>n;

	if(n==100){
		n++;
	}
	rep(i,d){
		n=n*100;
	}
	cout<<n<<endl;
	return 0;

}


Measured memory_bytes: 256
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template
//   Address :
//   Date    :   2020/08/15
// =====================================================

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

//#define rep(i, a, b) for (int i = (a); i < int(b); ++i)
typedef long long LL;

const int MOD = 1e9+7;

LL gcd (LL a, LL b) {
    if (b == 0)
        return a;
    return gcd(b, a%b);
}

LL g[3005][3005] = {};
LL dp[3005][3005][4] = {};
void solve() {
    int R, C, K;
    cin >> R >> C >> K;
    for (int i = 0; i < K; ++i) {
        int r, c;
        LL v;
        cin >> r >> c >> v;
        g[r][c] = v;
    }
    for (int i = 1; i <= R; ++i) {
        for (int j = 1; j <= C; ++j) {
            LL pre_max = dp[i-1][j][0];
            for (int k = 1; k < 4; ++k) {
                pre_max = max(pre_max, dp[i-1][j][k]);
            }
            dp[i][j][0] = max(pre_max, dp[i][j-1][0]);
            dp[i][j][1] = max({pre_max+g[i][j], dp[i][j-1][0]+g[i][j], dp[i][j-1][1]});
            for (int k = 2; k < 4; ++k)
                dp[i][j][k] = max(dp[i][j-1][k-1]+g[i][j], dp[i][j-1][k]);
        }
    }
    LL ans = dp[R][C][0];
    for (int i = 1; i < 4; ++i)
        ans = max(ans, dp[R][C][i]);
    cout << ans << endl;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
//#define LOCAL
#ifdef LOCAL
freopen("data.in", "r", stdin);
while (!feof(stdin)) {
#endif // LOCAL

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

#ifdef LOCAL
}
printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 355560
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef pair<string,int> SI;
typedef long long ll;
typedef unsigned long long ull;
const int d[4] = {-2,-8,+2,+8};

string::size_type zero_finder(string s){
  string::size_type index = s.find("0");
  return index == string::npos?-1:index;
}

inline
bool range_check(string s,int dir,int pos){
  int new_pos = pos+d[dir];
  assert(new_pos%2 == 0);
  assert(pos%2 == 0);
  if(!(0<= new_pos && new_pos <= 14))return false;
  bool pis_top,npis_top;
  if(0<= pos && pos <=6)pis_top = true;
  else if(8<= pos && pos <=14)pis_top = false;
  else assert(false);

  if(0<= new_pos && new_pos <= 6)npis_top = true;
  else if(8<= new_pos && new_pos <= 14)npis_top = false;
  else assert(false);

  if(pis_top != npis_top && (dir == 0 || dir == 2))return false;
  return true;
}

inline
void s_swap(string &s,int a,int b){
  char store = s[a];
  s[a] = s[b];
  s[b] = store;
}

int main(){
  string input;
  map<string,int> ans;

  ans["0 1 2 3 4 5 6 7"] = 0;

  queue<SI> que;

  que.push(SI("0 1 2 3 4 5 6 7",0));

  bool first_time = true;

  while(!que.empty()){
    SI si = que.front(); que.pop();
    if(ans[si.F] != 0 && !first_time)continue;

    ans[si.F] = si.S;
    first_time = false;    
    rep(i,4)
      {
	
	int pos = zero_finder(si.F);
	int n_pos = pos+d[i];

	assert(pos != -1);

	if(!range_check(si.F,i,pos))continue;

	string next_s = si.F;
	s_swap(next_s,pos,n_pos);    
	que.push(SI(next_s,si.S+1));
      }
  }
  
 while(getline(cin,input))
  {
    cout << ans[input] << endl;
  }
  return 0;
}

Measured memory_bytes: 3524
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        LinkedList<Integer> list = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }

        int max = list.stream().max((o1, o2) -> o1 - o2).get();
        int min = list.stream().min((o1, o2) -> o1 - o2).get();

        if (max == min) {
            System.out.println(0);
        } else {
            if (min >= 0) {
                System.out.println(n - 1);
                for (int i = 1; i < n; i++) {
                    System.out.println(i + " " + (i + 1));
                }
            } else if (max <= 0) {
                System.out.println(n - 1);
                for (int i = n; i > 1; i--) {
                    System.out.println(i + " " + (i - 1));
                }
            } else {
                if (Math.abs(min) <= Math.abs(max)) {
                    int p = list.indexOf(max) + 1;

                    System.out.println(2 * (n - 1));
                    for (int i = 1; i <= n; i++) {
                        if (p == i) {
                            continue;
                        }
                        System.out.println(p + " " + i);
                    }
                    for (int i = 1; i < n; i++) {
                        System.out.println(i + " " + (i + 1));
                    }
                } else {
                    int p = list.indexOf(min) + 1;

                    System.out.println(2 * (n - 1));
                    for (int i = 1; i <= n; i++) {
                        if (p == i) {
                            continue;
                        }
                        System.out.println(p + " " + i);
                    }
                    for (int i = n; i > 1; i--) {
                        System.out.println(i + " " + (i - 1));
                    }
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


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

int main() {
	
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	rep(i, n-2){
		if(s[i]=='A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
f=1
if s[-1]=="1":
  f=0
if s[0]=="0":
  f=0
for i in range(n-1):
  if s[i]!=s[-2-i]:
    f=0
    break
    
s=s[:-1]+"1"
if f:
  k=0
  for i in range(n):
    if s[i]=="1":
      for j in range(k,i):
        print(j+1,i+1)
      k=i
else:
  print(-1)

Measured memory_bytes: 74920
<?php
$input = explode(' ', trim(fgets(STDIN)));
$row_cnt = $input[0];
$col_cnt = $input[1];

$sheets = [];
for ($i=0; $i < $row_cnt; $i++) {
  $nums = explode(' ', trim(fgets(STDIN)));
  $nums[] = array_sum($nums);
  $sheets[] = $nums;
  echo implode(' ', $nums)."\n";
}
$sum = 0;
for ($i=0; $i < $col_cnt; $i++) {
  $num = 0;
  for ($j=0; $j < $row_cnt; $j++) {
    $num += $sheets[$j][$i];
  }
  $sum += $num;
  echo $num.' ';
}
echo $sum."\n";



Measured memory_bytes: 10964
#include<iostream>
#include<string>
#include<map>
#include<stack>
using namespace std;
int main()
{
  int n,k,a;
  int ans=0; 
  cin>>n>>k;
  for(int i=0;i<n;i++)
  {
  	scanf("%d",&a);
  	ans+=2*min(k-a,a);
  }
  cout<<ans<<endl;
}

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

int main() {
  int N; cin >> N;
  vector<pair<int, int>> p(N);
  rep(i, N) {
    int A; cin >> A;
    p[i] = make_pair(A, i+1);
  }
  sort(p.begin(), p.end());
  rep(i, N) {
    cout << p[i].second;
    if (i != N-1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
long long A[200];
int N;

int main(void){
	//IO("test.in", "test.out");
	scanf("%d", &N);
	for(int i = 0; i <= N; i++)
		if(i == 0) A[i] = 2;
		else if(i == 1) A[i] = 1;
		else A[i] = A[i - 1] + A[i - 2];
	printf("%lld\n", A[N]);
}

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

int main(){
  int c = 0;
  vector<char> p(3);
  vector<char> r(3);
  
  for(int i;i<3;i++)
    cin >> p.at(i);
  for(int i;i<3;i++)
    cin >> r.at(i);
  
  for(int i;i<3;i++){
    if(p.at(i) == r.at(i))
      c++;
  }
  cout << c <<endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int n;
    cin >> n;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    int t = a[0];
    ll ans = 0;
    for(int i = 1; i < n; i++) {
        if(t > a[i])
            ans += t - a[i];
        else 
            t = a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
N = int(input())
p = list(map(int, input().split()))

import numpy as np
a = np.arange(1, N + 1)
b = np.arange(N, 0, -1)

cmax = 1 + N
for i in range(1,N):
    idx = p[i] - 1
    diff = cmax - (a[idx] + b[idx]) + 1
    a[idx:N] += diff
    b[0:idx + 1] += diff
    cmax = a[idx]+b[idx]

for i in range(N):
    print(a[i], end=" ")

print()  

for i in range(N):
    print(b[i], end=" ")

print()  



Measured memory_bytes: 15768
#include <iostream>

using namespace std;

int main() {
    long long int N;
    int M;
    cin >> N >> M;
    
    long long int ans;
    ans = 1900*M + 100*(N-M);
    
    for(int m=0; m<M; m++) {
        ans *= 2;
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <stdlib.h>
using namespace std;
typedef long long int lld;
typedef long double ld;

int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d",max(0,a-2*b));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n;
  cin >> n;
  int last = -1;
  int state = 0;
  int ans = 0;
  rep(i, n) {
    int a;
    cin >> a;
    if (last == -1) {
      last = a;
      ans++;
    } else if (state == 0) {
      if (a > last) state = 1;
      else if (a < last) state = -1;
      last = a;
    } else if (state == 1) {
      if (a >= last) last = a;
      else {
        last = a;
        state = 0;
        ans++;
      }
    } else if (state == -1) {
      if (a <= last) last = a;
      else {
        last = a;
        state = 0;
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  int i;
  for(i=0;i<m;i++){
    cin >> l[i] >> r[i];
  }
  sort(l.begin(),l.end());
  sort(r.begin(),r.end());
  int ans=0;
  if(l[m-1] <= r[0]){
    ans= r[0] - l[m-1] +1;
  }
  cout << ans << endl;
}
  

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

int id;
double weight, height;
double bmi;
bool flag;

template<class T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<class T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<class T> inline bool semige(T x, T y){ return x - y > -EPS; }
template<class T> inline bool semile(T x, T y){ return y - x > -EPS; }

int main()
{
  while(scanf("%d,%lf,%lf", &id, &weight, &height) != EOF){
    if(semige(weight / (height * height), 25.0)){
      flag = true;
      cout << id << endl;
    }
  }

  if(!flag) cout << endl;

  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n;
    cin >> n;
    map<string, int> vote;

    int v_max = 0;
    rep(i, n){
        string s;
        cin >> s;
        ++vote[s];
        if(vote[s]>v_max){
            v_max = vote[s];
        }
    }

    vector<string> res;
    // for (const auto& [key, value]: vote){
    //     if(value==v_max) res.push_back(key);
    // }
    for(auto iter = vote.begin(); iter != vote.end(); ++iter){
        if(iter->second == v_max) cout << iter->first << endl;
    }

    // sort(res.begin(), res.end());

    // for(const auto& s: res){
    //     cout << s << endl;
    // }



    return 0;
}

Measured memory_bytes: 23936
x,n = (int(x) for x in input().split())
p = [int(x) for x in input().split()]

result = 100

l = list(range(0,102))



if len(p) == 0:
    kotae = x
else:
    for i in range(len(p)):

        l[p[i]] = ""



    for i in reversed(range(len(l))):
     
        if l[i] != "":

            if result >= abs(l[i] - x):
                result = abs(l[i] - x)
               
                kotae = l[i]          
            
print(kotae)


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

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

    while (K > 0) {
        if (C <= A) {
            C *= 2;
            K--;
        } else {
            break;
        }
    }


    while (K > 0) {
        if (B <= A) {
            B *= 2;
            K--;
        } else {
            break;
        }
    }

    while (K > 0) {
        if (C <= B) {
            C *= 2;
            K--;
        } else {
            break;
        }
    }
    if (K >= 0 && A < B && B < C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    
    return 0;
}


Measured memory_bytes: 3632