akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int ue(int a, int b) { return (a + b - 1) / b; }

int main() {
	int n, k;
	cin >> n >> k;
	VI a(n); rep(i, n)cin >> a[i];

	cout << ue(n - 1, k - 1) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> rain(N);
  int S = 0;
  for(int i = 0;i < N;i++){
    cin >> rain.at(i);
    S += rain.at(i);
  }
  int X = S;
  for(int i = 1;i <= N - 1;i++){
    X = X - 2*rain.at(i);
    i++;
  }
  cout << X;
  int XX;
  for(int i = 1;i < N;i++){
    XX = 2*rain.at(i - 1) - X;
    cout << " " << XX;
    X = XX;
  }
  cout << endl;
}


Measured memory_bytes: 3732
#include<iostream>
using namespace std;
int main() {
    int m, n, x, y;
    cin >> n >> m;
    int a[n][m] = {};
    int c[n]={};
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            cin >> x;
            a[i][j] = x;
        }
    }
    for (int k=0; k<m; k++) {
        cin >> y;
        for (int l=0; l<n; l++) {
            a[l][k] = a[l][k] * y;
        }
    }
    
    for (int o=0; o<n; o++) {
        for (int p=0; p<m; p++) {
            c[o] += a[o][p];
        }
        cout << c[o] << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  string s,t;
  cin >> s >> t;
  bool ok = s.size()+1==t.size() && s==t.substr(0,s.size());
  cout << (ok?"Yes":"No") << endl;
}


Measured memory_bytes: 3628
#include<cstdio>
int a[10][10],ans=0,vis[10],n;
void dfs(int k)
{
	vis[k]=1;
	int f=1;
	for(int i=1;i<=n;i++)
	if(!vis[i]) f=0;
	if(f) {ans++;return;}
	for(int i=1;i<=n;i++)
	if(!vis[i]&&a[k][i])
	{
		dfs(i);
		vis[i]=0;
	}
}
int main()
{
	int m,x,y;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		a[x][y]=a[y][x]=1;
	}
	dfs(1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
unittest
{
	assert( [ "4 12 20" ].parse.expand.solve == 3 );
	assert( [ "14 14 14" ].parse.expand.solve == -1 );
	assert( [ "454 414 444" ].parse.expand.solve == 1 );
	
	assert( [ "3 3 3" ].parse.expand.solve == 0 );		// 追加ケース
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = input.front.split.to!( long[] );
	return tuple( abc[ 0 ], abc[ 1 ], abc[ 2 ] );
}

auto solve( long a, long b, long c )
{
	if( a % 2 == 0 && b % 2 == 0 && c % 2 == 0 && a == b && b == c ) return -1;
	
	auto ans = 0L;
	while( a % 2 == 0 && b % 2 == 0 && c % 2 == 0 )
	{
		auto aa = b / 2 + c / 2;
		auto bb = a / 2 + c / 2;
		auto cc = a / 2 + b / 2;
		a = aa;
		b = bb;
		c = cc;
		ans++;
	}
	return ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;
const string sp = " ";

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

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

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

class unionfind {
private:
	int par[200010], rankth[200010], sizeth[200020];
public:
	void init(int n) {
		rep(i, n) {
			par[i] = i;
			rankth[i] = 0;
			sizeth[i] = 1;
		}
	}
	int root(int x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rankth[x] < rankth[y]) {
			par[x] = y;
			sizeth[y] += sizeth[x];
		}
		else {
			par[y] = x;
			if (rankth[x] == rankth[y]) rankth[x]++;
			sizeth[x] += sizeth[y];
		}
	}
};


signed main() {
	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy" << endl;
	else if (s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0)break;
		vector<int> A(n);
		for(int i = 0; i < n; i ++)cin >> A[i];
		int ans = 0;
		for(int i = 0; i < n - 1; i ++){
			for(int j = i + 1; j < n; j ++){
				if(A[i] + A[j] <= m)ans = max(ans, A[i] + A[j]);
			}
		}
		if(ans == 0)cout << "NONE" << endl;
		else cout << ans << endl;
	}

	return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << c <<" "<< a <<" "<< b << endl;
}



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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }

const long long INF = 1LL << 60;


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

    int ans =1;
    repr(i,1,X){
        repr(j,2,10){
            int num =i;
            rep(k,j-1){
                num *= i;
            }
            if(num <= X)ans = max(ans,num);
        }
    }

    cout << ans << endl;



}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int l[51];
  for (int i = 0; i < N; i++) cin >> l[i];
  
  sort(l, l + N, greater<int>());
  
  int total_length = 0;
  
  for (int i = 0; i < K; i++) total_length += l[i];
  
  cout << total_length << endl;
}

Measured memory_bytes: 3628
from statistics import median

N = int(input())
A = list(map(int, input().split()))

A_star = [a - (i + 1) for i, a in enumerate(A)]

def calc_score(b):
    score = 0
    for a in A_star:
        score += abs(a - b)
    return score

def decide_direction(b):
    score0 = calc_score(b)
    score1 = calc_score(b + 1)
    if score0 > score1:
        return 1
    else:
        return -1

b = int(median(A_star))
direction = decide_direction(b)
pre_score = calc_score(b)

while True:
    b += direction
    score = calc_score(b)
    if score >= pre_score:
        print(pre_score)
        break
    else:
        pre_score = score






Measured memory_bytes: 27232
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N;
	cin>>N;
	vector<int> A(N),B(N);
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	for(int i=0;i<N;++i){
		cin>>B[i];
	}
	long long a=0,b=0;
	for(int i=0;i<N;++i){
		if(A[i]>B[i]){
			b+=A[i]-B[i];
		}else if(A[i]<B[i]){
			if((B[i]-A[i])&1){
				++B[i];
				++b;
			}
			a+=(B[i]-A[i])/2;
		}
	}
	cout<<(a>=b?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}
LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}
LL mcomb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = mfrac(n) * mpower(mfrac(r), MOD - 2) % MOD;
    res *= mpower(mfrac(n - r), MOD - 2) % MOD;

    return res;
}

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

    vector<LL> a(S.size() + 1);
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == '<') {
            a[i + 1] = max(a[i + 1], a[i] + 1LL);
        }
    }

    for(int i = S.size() - 1; i >= 0; i--) {
        if(S[i] == '>') {
            a[i] = max(a[i], a[i + 1] + 1LL);
        }
    }

    cout << accumulate(ALL(a),0LL) << endl;

    return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, l;
    cin >> n >> l;
    vll a(n);
    ll k = 0, tmp = 1e10;
    REP(i, n){
        a[i] = l + i;
        if(abs(a[i]) < tmp){
            tmp = abs(a[i]);
            k = i;
        }
    }
    ll res = 0;
    REP(i, n){
        if(i != k) res += a[i];
    }
    cout << res << endl;
    return 0;
}

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

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

  int n;
  cin >> n;

  vector<ll> a(n), s(n+1, 0);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) s[i+1] += s[i] + a[i];

  ll ans = 1e18;
  for (int i = 1; i < n; ++i) ans = min(ans, abs(s[i] - (s[n] - s[i])));

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 6372
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <deque>

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
        cout << 'x';
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,m;
	cin>>n>>m;
	int ans = m*(m-1)/2;
	ans += n*(n-1)/2;
	cout<<ans<<endl;
	return 0;
}



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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll l, r;
    cin >> l >> r;
    if (r - l >= 673) {
        cout << 0 << ln;
    } else {
        ll ans = 2019;
        FOR(i, l, r - 1)FOR(j, i + 1, r) {
            ans = min((ll)i * (ll)j % 2019, ans);
        }
        cout << ans << ln;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,c,n) for(int i=c;i<n;i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

int main(){
  ios::sync_with_stdio(false);
	cin.tie(0);
  int a[3];
  int b[3];
  int count[4] = {0};
  r(i,3) cin >> a[i] >> b[i];
  r(i,3){
    count[a[i]-1] ++;
    count[b[i]-1] ++;
  }
  int cn1=0,cn2=0;
  r(i,4){
    if(count[i]==1) cn1 ++;
    if(count[i]==2) cn2 ++;
  }
  if (cn1==2&&cn2==2) cout << "YES" <<endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val array = Array(3) { IntArray(3) }
    for (i in 0..2) {
        val list = readLine()!!.split(" ").map { it.toInt() }
        for (j in 0..2) {
            array[i][j] = list[j]
        }
    }
    val n = readLine()!!.toInt()
    for (a in 0 until n) {
        val c = readLine()!!.toInt()
        for (i in 0..2) {
            for (j in 0..2) {
                if (array[i][j] == c) {
                    array[i][j] = 0
                }
            }
        }
    }
    var isBingo = false
    for (i in 0..2) {
        if (array[1][1] == 0 && array[0][0] == array[1][1] && array[2][2] == array[1][1]) {
            isBingo = true
            break
        } else if (array[1][1] == 0  && array[0][2] == array[1][1] && array[2][0] == array[1][1]) {
            isBingo = true
            break
        } else if ((array[i][0] == array[i][1] && array[i][1] == array[i][2] && array[i][0] == 0) || (array[0][i] == array[1][i] && array[1][i] == array[2][i] && array[0][i] == 0)) {
            isBingo = true
            break
        }
    }
    if(isBingo) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 37624
n = int(input())

def wa(a, n, d):
   return (n * (2*a + (n-1) * d)) // 2

ans = 0
for i in range(1, n+1):
   last = n - (n % i)
   num = (last - i) // i + 1
   ans += wa(i, num, i)
print(ans)

Measured memory_bytes: 64092
def power(a, e, m):
  s = 1
  while e>0:
    if e % 2 == 1:
      s = s * a % m
    a = a * a % m
    e = int(e / 2 % m)
  return s

n = int(input())
print((power(10, n, 1000000007) + power(8, n, 1000000007) - power(9, n, 1000000007)*2) % 1000000007)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string a,b;
  cin>>a;
  cin>>b;
  int c;
  int i=0;
  int flag=0;
  c=a.size();
  while(i<c){
    if(a.at(i)!=b.at(i)){
      flag=1;
    }
    i++;
  }
  if(flag==1){
    cout<<"No";
  }else{
    cout<<"Yes";
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
int mp[N][N];//,cntr[N],cntc[N];
int main()
{
    int r,c,a,b;
    while(~scanf("%d%d%d%d",&r,&c,&a,&b)){
        int tmp;
        memset(mp, 0, sizeof mp);
        for(int i=1;i<=r;i++){
            if(i&1){
                for(int j=1;j<=a;j++){
                    mp[i][j] = 1;
                }
            }
            else{
                for(int j=a+1;j<=c;j++){
                    mp[i][j] = 1;
                }
            }
        }
        /*for(int i=1;i<=r;i++){
            for(int j=1;j<=c;j++){
                printf("%d",mp[i][j]);
            }puts("");
        }puts("");*/
        if(b < r/2){
            for(int i=1;i<=r/2-b;i++){
                for(int j=1;j<=a;j++){
                    mp[i*2][j] = 1;
                }
                for(int j=a+1;j<=c;j++){
                    mp[i*2][j] = 0;
                }
            }
        }
        for(int i=1;i<=r;i++){
            for(int j=1;j<=c;j++){
                printf("%d",mp[i][j]);
            }puts("");
        }
    }
}


Measured memory_bytes: 5120
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  vi a(n);
  vector<pair<int, int>> p(n);
  REP(i,n){
    cin>>a[i];
    p[i].first=a[i];
    p[i].second=i;
  }


sort(p.begin(), p.end());
//sort(ar.begin(), ar.end(),greater<int>());

//配列結果REP cout
  for (auto elem : p) {
    cout<<(elem.second+1)<<" ";
  }





//sort(p.begin(),p.end());//, compare_by_b
/*
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
*/


  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli a, b;
    cin >> a >> b;
    if((a+b)%2 != 0) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
}

Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*/


#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#define ll long long int
#define dd double
using namespace std;

int main()
{
   ll b,c,i,s=0,ans=0,r;
   string a;
   bool f=1;
   
   cin>>a;
   s=0;
   r=a.length()-1;
   while(s<r)
   {
     if(a[s]!=a[r])
     {
       f=0;
       break;
     }
     s++,r--;
   }
      if(f==0)
  {cout<<"No"<<endl;
   return 0;}
  else
   {
     s=0;
     r=(a.length()-1)/2;
     r--;
       while(s<r)
   {
     if(a[s]!=a[r])
     {
       f=0;
       break;
     }
      s++,r--;
   }
   if(f==0)
  {cout<<"No"<<endl;
   return 0;}
   s=(a.length()+3)/2;
   s--;
   r=a.length()-1;
      while(s<r)
   {
     if(a[s]!=a[r])
     {
       f=0;
       break;
     }
      s++,r--;
   }
      if(f==0)
  {cout<<"No"<<endl;
   return 0;}
   }
   cout<<"Yes"<<endl;


    

}
//Apna Time Aayega :)

Measured memory_bytes: 3628
// https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_c
// +build ignore

package main

import "fmt"

func main() {
	var k, a, b, biscuits, yen int
	biscuits = 1
	fmt.Scanf("%d %d %d", &k, &a, &b)
	if (b - a) <= 2 {
		fmt.Println(k + 1)
		return
	}
	for i := 0; i < k; i++ {
		if i < k-1 && biscuits >= a {
			biscuits -= a
			yen += 1
			yen -= 1
			biscuits += b
			i++
		} else {
			biscuits += 1
		}

	}
	fmt.Println(biscuits)
}

Measured memory_bytes: 512
n=int(input())
A=list(map(int,input().split()))
S=sum(A)
x=A[0]
y=S-x
xy_min=abs(x-y)
for i in range(1,n-1):
  x+=A[i]
  y=S-x
  xy=abs(x-y)
  if xy<xy_min:
    xy_min=xy
print(xy_min)

Measured memory_bytes: 30664
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    v = list(map(int, input().split()))
    if len(set(v)) == 1:
        print(n//2)
    else:
        a, b = [], []
        for i in range(n):
            if i%2 == 1:
                a.append(v[i])
            else:
                b.append(v[i])
        c = Counter(a)
        c = c.most_common()
        d = Counter(b)
        d = d.most_common()
        if c[0][0] != d[0][0]:
            print(n-c[0][1]-d[0][1])
        else:
            if len(c) == 1:
                if c[0][1]+d[1][1] > d[0][1]:
                    print(n-c[0][1]-d[1][1])
                else:
                    print(n-d[0][1])
            elif len(d) == 1:
                if d[0][1]+c[1][1] > c[0][1]:
                    print(n-d[0][1]-c[1][1])
                else:
                    print(n-c[0][1])
            else:
                if c[0][1]+d[1][1] > d[0][1]+c[1][1]:
                    print(n-c[0][1]-d[1][1])
                else:
                    print(n-c[1][1]-d[0][1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 21148
#include <cstdlib>

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	int H, W;
	int ax, ay;
	string s;
	vector<vector<int>> map;

	const int dx[4] = { 1, 0, -1 ,0 };
	const int dy[4] = { 0, 1, 0, -1 };
	const int sharp = -1;
	const int black = 1;
	const int space = 0;

	cin >> H >> W;

	map.resize(H);
	rep(i, H)
	{
		map[i].resize(W);
	}

	rep(i, H)
	{
		cin >> s;
		rep(j, W)
		{
			if (s.at(j) == '#') {
				map.at(i).at(j) = sharp;
			}
			else {
				map.at(i).at(j) = space;
			}
		}
	}

	rep(i, H)
	{
		rep(j, W)
		{
			if (map.at(i).at(j) != space)
			{
				bool draw = false;
				for (int d = 0; d < 4; ++d)
				{
					ax = j + dx[d];
					ay = i + dy[d];

					if (ax < 0 or ax >= W) continue;
					if (ay < 0 or ay >= H) continue;
					if (map.at(ay).at(ax) == black)
					{
						draw = true;
					}
					if (map.at(ay).at(ax) == sharp)
					{
						map.at(ay).at(ax) = black;
						draw = true;
					}
				}
				if (draw) map.at(i).at(j) = black;
			}
		}
	}

	bool solve = true;
	rep(i, H)
	{
		rep(j, W)
		{
			if (map.at(i).at(j) == -1) solve = false;
		}
	}

	if (solve)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

int main() {
	// your code goes here
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin >> n;
	cout << a[n-1];
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

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

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

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

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////
int root = 0;

vector<int> ko;
vector<vector<int>>G;

int f(int pos) {
	int ans = 0;
	int len = G[pos].size();
	for (int i = 0; i < len; ++i) {
		int ter = G[pos][i];
		int res = f(ter);
		ans += res;
	}
	ko[pos] = len;//直属を数えている。
	return ans+1;
}
void solve() {
	int N;
	cin >> N;
	vector<int> A(N);
	G = vector<vector<int>>(N);
	ko = vector<int>(N, 0);
	for (int i = 1; i < N; ++i) {
		cin >> A[i];
		--A[i];
		G[A[i]].push_back(i);
	}
	//f(root);
	for (int i = 0; i < N; ++i) {
		cout << G[i].size() << endl;
		//cout << ko[i] << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int n,k;
int c[5010],p[5010];
long long ans=-1e18,sum[5010];
vector<int> cycle[5010];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>p[i];
	for(int i=1;i<=n;i++)
		cin>>c[i];
	for(int i=1;i<=n;i++){
		for(int j=p[i];;j=p[j]){
			cycle[i].push_back(c[j]);
			sum[cycle[i].size()]=sum[cycle[i].size()-1]+c[j];
			if(j==i)
				break;
		}
		int sz=cycle[i].size();
		int round=k/sz;
		long long cnt=-1e18;
		for(int j=1;j<=min(sz,k);j++){
			if(sum[sz]>0)
				ans=max(ans,sum[j]+(k-j)/sz*sum[sz]);
			else
				ans=max(ans,sum[j]);
		}
		ans=max(ans,cnt);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 121168
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n; cin >> n;
  vector<P> robots(n);
  rep(i, n) {
    int x,l; cin >> x >> l;
    robots[i].first = x + l;
    robots[i].second = max(0, x - l);
  }
  sort(robots.begin(), robots.end());

  int ans = 1;
  int prev = 0;
  rep1(i, n - 1) {
    if(robots[prev].first <= robots[i].second) {
      ++ans;
      prev = i;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    int d[N];
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    sort(d, d+N, greater<int>());

    int count = 0;
    int now = 1000;
    for (int i = 0; i < N; i++){
        if(now > d[i]){
            count++;
            now = d[i];
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

struct BIT{
    // 1-origin
    vector<int> v;
    int n;

    BIT(int _n):
        v(vector<int>(_n+1, 0)), n(_n) {}

    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= lsb(i);
        }
        return s;
    }
    
    int sum(int l, int r){
        return sum(r) - sum(l-1);
    }

    void add(int i, int x){
        while(i <= n){
            v[i] += x;
            i += lsb(i);
        }
    }

private:
    // least significant bit
    int lsb(int i){
        return i & -i;
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    vector<int> b = a;
    sort(b.begin(), b.end());
    auto f = [&](int val)->int{
        return lower_bound(b.begin(), b.end(), val)-b.begin();
    };
    BIT bit(n);
    ll ret = 0;
    for(int i = 0; i < n; i++){
        ret += i-bit.sum(f(a[i])+1);
        bit.add(f(a[i])+1, 1);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 5288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; ++i)

main() {
    int k, n;
    cin >> k >> n;
    vector <int> a(n, 0);
    rep(i, 0, n) {
        cin >> a[i];
    }
    int mx = 0;
    rep(i, 1, n) mx = max(mx, a[i] - a[i - 1]);
    mx = max(mx, a[0] - a[n - 1] + k);
    cout << k - mx << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n, a[1000];
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(j == 0) cout << a[j];
			else cout << " " << a[j];
		} cout << endl;
		int v = a[i];
		int j = i-1;
		while(j >= 0 && a[j] > v) {
			a[j+1] = a[j];
			j--;
			a[j+1] = v;
		}
	}
	for(int j = 0; j < n; j++) {
		if(j == 0) cout << a[j];
		else cout << " " << a[j];
		} cout << endl;
	return 0;
}

Measured memory_bytes: 1164
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc = new FastScanner();
		long X=sc.nextLong();
		long K=sc.nextLong();
		long D=sc.nextLong();
		X=Math.abs(X);
		if (X>=D) {
			long q=Math.min(K,X/D);
			X-=q*D;
			K-=q;
		}
		K%=2;
		if (K==1) {
			X=Math.abs(X-D);
		}
		System.out.println(X);
	}
	
	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    int n; cin >> n;
    vi p(n);
    rep(i, n) {
        int t; cin >> t;
        p[i] = t - 1;
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(i == p[i]){
            ans++;
            swap(p[i], p[i+1]);
        }
    }

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

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

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

  if(m % 2 ==0 && 2 * n <= m && m <= 4 * n)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
	int A, B;
  	cin >> A >> B;
  
  	if (A >= 13){
    	cout << B;
    }
  	else if ( A >=6 and A <=12){
      	cout << B/2;  
    }
  	else{
        cout << 0;
    }

}

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

Measured memory_bytes: 2492
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	vector<int>v(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> M;
		v[M]++;
	}
	vector<int>box;
	for (int i = 1; i <= N; i++) {
		if (v[i]) {
			box.push_back(v[i]);
		}
	}
	sort(box.begin(), box.end());
	if (box.size() <= K) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	for (int i = 0; i < box.size() - K; i++) {
		ans += box[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;
  vector<tuple<int, int, int>> trains;
  for (int i = 0; i < n - 1; i++) {
    int c, s, f;
    cin >> c >> s >> f;
    trains.push_back({c, s, f});
  }

  for (int i = 0; i < n; i++) {
    int t = 0;
    int cur = i;
    while (cur < n - 1) {
      auto [c, s, f] = trains[cur];
      if (t <= s) {
        t += (s - t);
      } else {
        int r = (t - s) % f;
        if (r != 0)
          t += f - r;
      }
      t += c;
      cur++;
    }
    cout << t << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
use std::io::*;
use std::str::FromStr;

fn main() {
    let n:u32 = read();
    let k:u32 = read();

    println!("{}", k * (k - 1).pow(n - 1));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4476
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	char str1[50];
	char str2[50];
	char str[100];

	int n;
	cin >> n;

	for (int c = 0;c < n;c++) {
		cin >> str[c];
	}
	
	if (n % 2 != 0) {
		cout << "No\n";
	}
	else {
		int a = n / 2;
		for (int i = 0; i < a; i++) {
			str1[i] = str[i];
		}
		for (int j = a; j < n; j++) {
			str2[j - a] = str[j];
		}

		string result = "Yes";
		for (int k = 0; k < a;k++) {
			if (str1[k] != str2[k]) {
				result = "No";
				break;
			}
		}
		cout << result << "\n";
	}

	return 0;

	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;

int par[100010]; //親
int siz[100010]; //根ノードiの木に含まれる要素数。iが根ノード出ない場合無意味な値となる。

int par2[100010];
int siz2[100010];

//n要素で初期化
void init(int n) {
	for(int i = 0;i < n;i++) {
		par[i] = i;
		siz[i] = 1;
	}
}

//木の根を求める
int find(int x) {
	if(par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

//ｘとｙの属する集合を併合
void unite(int x,int y) {
	x = find(x);
	y = find(y);
	if(x == y) {
		return;
	}
	if(siz[x] < siz[y]) {
		swap(x,y);
	}
	par[y] = x;
	siz[x] += siz[y];
}

//ｘとｙが同じ集合に属するか否か
bool same(int x,int y) {
	return find(x) == find(y);
}

int size(int x) {
	return siz[find(x)];
}

int main() {
    int N,M,K;
    cin >> N >> M >> K;
    init(N);
    vector<int> vec(100010);
    for(int i = 0;i < M;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        vec.at(A)++;
        vec.at(B)++;
        unite(A,B);
    }
    vector<int> ret(N);
    for(int i = 0;i < N;i++) {
        ret.at(i) = size(i) - 1 - vec.at(i);
    }
    for(int i = 0;i < K;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        if(same(A,B) == true) {
            ret.at(A)--;
            ret.at(B)--;
        }
    }
    for(int i = 0;i < N;i++) {
        cout << ret.at(i) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2432
#include <cstdio>
#include <cctype>
#include <utility>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template<typename T>
#define _HT template<typename H,typename... T>
_T _DEF(T,in,int c){T n{};int m{1};while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
_T _SCAN(T &n){int c{gcu()};return c==EOF?false:(n=in<T>(c),true);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
_OUT(string s){for(char c:s)pcu(c);}
#endif
_OUT(const char *s){while(*s)pcu(*s++);}
_T _OUT(T n){static char b[20];char *p{b};T m=n<0?pcu('-'),-1:1;if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{int e,b{0},s{1};range(int _b,int _e,int _s):e(_e),b(_b),s(_s){}range(int _b,int _e):e(_e),b(_b){}range(int _e):e(_e){}
	struct it{int v,s;it(int _v,int _s):v(_v),s(_s){}operator int()const{return v;}operator int&(){return v;}int operator*()const{return v;}it& operator++(){v+=s;return *this;}};
	it begin(){return{b, s};}it end(){return{e,s};}bool inner(int n){return b<=n&&n<e;}};

template<int N>
struct sieve {
	bool s[N];
	int v[N], l = -1;
	constexpr sieve() : s(), v() {
		s[2] = true;
		for (int i = 3; i < N; i += 2)
			s[i] = true;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
		for (int i = 2; i < N; i++)
			if (s[i])
				v[++l] = i;;
	}
};

int main() {
	constexpr int M = sqrt(100000000);
	constexpr sieve<M> s;
	for (int n; (n = in());) {
		vector<pair<int, int>> a;
		for (int i {}, t {n}; t != 1; i++)
			if (s.v[i] * s.v[i] < t)
				while (t % s.v[i] == 0) {
					t /= s.v[i];
					if (a.size() && a.back().first == s.v[i])
						a.back().second++;
					else
						a.push_back({s.v[i], 1});
				}
			else {
				a.push_back({t, 1});
				break;
			}
		vector<int> r = {1};
		for (auto p: a) {
			size_t i = 0;
			while (p.second--) {
				size_t e = r.size();
				for (; i < e; i++)
					r.push_back(r[i] * p.first);
			}
		}
		int S = accumulate(begin(r), end(r), -n);
		outl(S == n ? "perfect number" : S < n ? "deficient number" : "abundant number");
	}
}


Measured memory_bytes: 2648
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;
    
    public static void main(String[] args) {
        int n = ni();
        R[] rs = new R[n];
        for (int i = 0; i < n; i++) {
            rs[i] = new R(ns(), ni(), i+1);
        }
        Arrays.sort(rs);
        for (R r: rs) {
            so.println(r.num);
        }
    }
    
    static class R implements Comparable<R>{
        String s;
        int p;
        int num;
        
        public R(String s, int p, int num) {
            this.s = s;
            this.p = p;
            this.num = num;
        }
        @Override
        public int compareTo(R that) {
            if (this.s.equals(that.s)) {
                return that.p - this.p;
            }
            return (this.s).compareTo(that.s);
        }
        
        @Override
        public String toString() {
            return this.num + " " + this.s + " " + this.p;
        }
    }

    
    private static int ni() {
        return sc.nextInt();
    }

    private static long nl() {
        return sc.nextLong();
    }

    private static String ns() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0);
    }

    private static long[] nlongs(int n, int padding) {
        long[] a = new long[padding + n];
        for (int i = 0; i < n; i++)
            a[padding + i] = ni();
        return a;
    }
}


Measured memory_bytes: 21972
#include <iostream>

using namespace std;

typedef long long ll;

int n;
ll k, w[105], vr[105], dp[1000005];
const int MAX = (int)1e6;
const ll inf = 1e15;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for(int i = 1 ; i <= n ; ++i){
	cin >> w[i] >> vr[i];
}
for(int i = 1 ; i <= MAX ; ++i){
	dp[i] = inf;
}
for(int i = 1 ; i <= n ; ++i){
	for(int j = MAX - vr[i] ; j >= 0 ; --j){
		dp[j + vr[i]] = min(dp[j + vr[i]], dp[j] + w[i]);
	}
}
for(int i = MAX ; i >= 0 ; --i){
	if(dp[i] <= k){
		cout << i << endl;
		return 0;
	}
}


return 0;
}



Measured memory_bytes: 8064
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

string s ,t ;
deque<long long> pos[128] ;
long long add[128] ;
int main(){
    cin >> s >> t ;
    for(int i=0;i<s.size();++i) pos[s[i]].push_back(i) ;
    for(char ch:t) if(!pos[ch].size()) return cout << -1,0 ;
    long long ans = 0 ;
    for(char ch:t){
        long long st = 0 ,en= 1e12 ;
        while(st<en){
            long long mid = (st+en)/2;
            long long to = pos[ch].back() + add[ch] + mid*s.size() ;
            if(to >= ans) en = mid ;
            else st = mid+1 ;
        }
        add[ch] += st*s.size() ;

        st=0 ,en = pos[ch].size()-1 ;
        while(st<en){
            long long mid = (st+en)/2 ;
            if(pos[ch][mid] + add[ch] >=ans) en = mid ;
            else st = mid+1 ;
        }
        ans = pos[ch][st] + add[ch] + 1 ;
    }
    cout << ans ;
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, P;
    cin >> A >> P;

    cout << (A*3 + P) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
from math import floor

A, B, N = map(int, input().split())

def f(x):
    return floor(A * x / B) - A * floor(x / B)

result = 0
for x in range(min(A + 1, N + 1)):
    result = max(result, f(x))

if B > A:
    for i in range(10 ** 20):
        x = (i * B + A - 1) // A
        if x > N:
            break
        result = max(result, f(x))

print(result)


Measured memory_bytes: 9228