akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll n, k;
    cin >> n >> k;
    vll p(n);
    rep(i, n) cin >> p[i];

    set<ll> s;
    ll st = 0;
    ll last = -1;
    ll st_count = 0;
    rep(i, k){
        s.insert(p[i]);
        if(last<p[i]) ++st;
        else st = 1;
        last = p[i];
        if(st>=k) ++st_count;
    }
    ll count = 1;
    REP(i, k, n){
        if(last<p[i]) ++st;
        else st = 1;
        last = p[i];
        ll pmin = *(s.begin());
        ll pmax = *(s.rbegin());
        if(p[i-k]>pmin || p[i]<pmax){
            if(st<k || st_count==0) ++count;
            if(st>=k) ++st_count;
        }
        s.erase(p[i-k]);
        s.insert(p[i]);
    }
    cout << count << endl;
}


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

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

  if(((n[0]==n[1])&&(n[1]==n[2])) || ((n[1]==n[2])&&(n[2]==n[3]))) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import math

X = int(input())

if(X < 100):
    print(0)
    exit
else:
    if (int(str(X)[-2])*10 + int(str(X)[-1])*1) % 5 == 0:
        if math.floor((int(str(X)[-2])*10 + int(str(X)[-1])*1) / 5) > math.floor(X / 100):
            print(0)
        else:
            print(1)
    else:
        if math.floor((int(str(X)[-2])*10 + int(str(X)[-1])*1) / 5) + 1 > math.floor(X / 100):
            print(0)
        else:
            print(1)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  int i;

  int n, k;
  scanf("%d%d", &n, &k);

  char s[n+1];
  scanf(" %s", s);

  int dif=1;
  for(i=1; i<n; i++){
    if(s[i] != s[i-1]) dif++;
  }

  if(dif - 2*k <= 1){
    printf("%d\n", n-1);
  }else{
    printf("%d\n", n-dif+2*k);
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int a[1200000];
int main()
{
	long long int sum=0;
	scanf("%lld",&sum);
	long long int minn=9999999999999;
	for(int i=1;i<=sqrt(sum)+100;i++){
		if(sum%i==0){
			minn=min(i+(sum/i),minn);
		}
	}
	printf("%lld\n",minn-2);
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
int n;
cin>>n;
V<ll> a(n);
bool ok=true;
for(int i=0;i<n;i++){
   cin>>a[i];
   if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0)ok=false;
   }
}
if(ok)cout<<"APPROVED"<<endl;
else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a;
  int A[100];
  int j,i;
  int tmp;
  int count;
  scanf("%d",&a);
  for(i = 0;i < a;i++){
    scanf("%d",&A[i]);
  }

  for(i = 0;i < a;i++){
    for(j = a-1;j >= 1;j--){
      if(A[j-1] > A[j]){
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	count++;
      }
    }
  }

  for(i = 0;i < a-1;i++){
    printf("%d",A[i]);
    if(i <= a-2){
      printf(" ");
    }
  }
  printf("%d\n",A[a-1]);
  printf("%d\n",count);
  return 0;
}



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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

/*
int	gcd(int A, int B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}

long	gcd(long A, long B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}

long	lcm(long A, long B) {
	long G=gcd(A, B);
	return A/G*B;
}

long	GCD(vector<long> &A) {
	long B=A.at(0);
	for (long i=1; i<A.size(); i++)
		B =gcd(B, A.at(i));
	return B;
}

long	LCM(vector<long> &A) {
	long B=A.at(0);
	for (long i=1; i<A.size(); i++)
		B =lcm(B, A.at(i));
	return B;
}
*/

int	main() {
	int N, M;
	cin >>N >>M;
	if (N==M)
		cout <<"Yes" <<endl;
	else
		cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 256
N,Y = list(map(int, input().split()))
a = [-1,-1,-1]

while(True):
    for i in range(N+1):
        for j in range(N-i+1):
            if 10000*i + 5000*j + 1000*(N-i-j) == Y:
                a[0] = i
                a[1] = j
                a[2] = N-i-j
                break
    break

print(' '.join([str(n) for n in a]))

        

Measured memory_bytes: 3060
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

mons = inputs[1]
wars = inputs[2]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p mons
  p wars
end

sum = 0
rem = mons[-1]
for i in 0..wars.size-1
  ii = wars.size-1-i
  sum += [rem + mons[ii], wars[ii]].min
  if rem > wars[ii]
    rem = mons[ii]
  else
    rem = [rem + mons[ii] - wars[ii], 0].max
  end
  #pd "rem=#{rem}"
end

puts sum


Measured memory_bytes: 21524
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<cstring>

using namespace std;

typedef long long ll;

ll max(ll a,ll b)
{
    return a>b?a:b;
}

ll min(ll a, ll b)
{
    return a<b?a:b;
}

ll abs(ll a)
{
    return a>0?a:-a;
}


int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;   
}


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

using namespace std;

int main(){
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++){
		a[i]=0;
	}
	for(int i=1;i<=k;i++){
		int d,x;
		cin>>d;
		for(int j=1;j<=d;j++){
			cin>>x;
			a[x]=1;
		}
	}
	int s=0;
	for(int i=1;i<=n;i++){
		if(a[i]==0) s++;  
	}
	cout<<s<<'\n';
	return 0; 
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            total += arr[i];
        }
        Arrays.sort(arr);
        int target = arr[n - m];
        if (target * 4 * m < total) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a, b, ans = 0; cin >> a >> b;
  if(a > 1 && b >= a) ans = a;
  else if(a == 1) ans = 1;
  else ans = a-1;
  cout << ans << endl;
  system("pause");
}


Measured memory_bytes: 504
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int a=in(),b=in()*2+1;
    cout<<(a+b-1)/b<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=1e9;
const int magic=348;

int n,m;
int a[348][348];
vector<int> v[348];
priority_queue<Pair> q;
int cur[348];
bool used[348];

bool check(int cmp)
{
	if (cmp==n) return true;
	int i,j;
	for (i=1;i<=n;i++) cur[i]=1;
	for (i=1;i<=m;i++) v[i].clear();
	for (i=1;i<=n;i++) v[a[i][1]].pb(i);
	//for (i=1;i<=m;i++) cout<<v[i].size()<<' ';
	//cout<<endl;
	for (i=1;i<=m;i++) used[i]=true;
	for (i=1;i<=m;i++)
	{
		int maxn=-1,max_pos;
		for (j=1;j<=m;j++)
		{
			int len=v[j].size();
			//cout<<j<<' '<<v[j].size()<<' '<<maxn<<' '<<used[j]<<endl;
			if (used[j]==true && len>maxn)
			{
				//cout<<"#";
				//cout<<j<<' '<<v[j].size()<<endl;
				maxn=v[j].size();
				max_pos=j;
			}
		}
		if (maxn<=cmp) return true;
		if (i==m) return false;
		used[max_pos]=false;
		for (j=0;j<v[max_pos].size();j++)
		{
			int x=v[max_pos][j];
			cur[x]++;
			while (!used[a[x][cur[x]]]) cur[x]++;
			v[a[x][cur[x]]].pb(x);
		}
	}
	return false;
}

int main ()
{
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	int l=1,r=n,mid,ans;
	while (l<=r)
	{
		mid=(l+r)>>1;
		if (check(mid))
		{
			ans=mid;
			r=mid-1;
		}
		else
			l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14,5) << endl;
}


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

int main(){

  string S;
  cin >> S;
  
  S += 'E';

  stack<char> tower;
  int count = 0;

  for(int i=0; i<S.size()-1; i++){
    
    if( S.at(i) != S.at(i+1) && S.at(i+1) != 'E' ){
      count+=2;
      i++;
    }else{
      
      if(tower.empty()){
        //タワーが空の時、単に追加
        tower.push(S.at(i));
      
      }else{
        //タワーの値と比較
        if( S.at(i) != tower.top() ){
          count+=2;
          tower.pop();
        }else{
          tower.push(S.at(i));
        }

      }

    }
    
  }
  
  cout << count << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

ll modfac(ll x,ll y,ll MOD) {
  if(x==y) {
    return y;
  }
  return (x * modfac(x-1,y,MOD) % MOD ) % MOD;
}

ll modpow(ll a, ll n,ll MOD) {
  ll res = 1;
  while(n>0){
    if(n&1) res = res * a % MOD;
    a = a * a % MOD; // a を 2乗したものに置き換える。（2進数だと1桁上がる）
    n >>= 1; // 2進数で1桁下げる
  }
  return res;
}

int main(void) {
  const int MOD=pow(10,9)+7;
  int n,a,b;cin>>n>>a>>b;
  ll xa=modfac(n,n-a+1,MOD);
  ll xb=modfac(n,n-b+1,MOD);
  ll ya=modpow(modfac(a,1,MOD),MOD-2,MOD);
  ll yb=modpow(modfac(b,1,MOD),MOD-2,MOD);
  ll nCa=(xa*ya)%MOD;
  ll nCb=(xb*yb)%MOD;
  pr((modpow(2,n,MOD)-nCa-nCb-1+2*MOD)%MOD);
  return 0;
}


Measured memory_bytes: 6528
# 二つの長方形があります。
# 一つ目の長方形は、縦の辺の長さがa、横の辺の長さがbです。
# 二つ目の長方形は、縦の辺の長さがc、横の辺の長さがdです。
# この二つの長方形のうち、面積の大きい方の面積を出力してください。
# なお、二つの長方形の面積が等しい時は、その面積を出力してください。

# 情報を取得
input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i
c = input[2].to_i
d = input[3].to_i

# 二つの長方形の面積を計算
rectangle1 = a * b
rectangle2 = c * d

# 面積の大きい方のそれを出力
if rectangle1 > rectangle2
  puts rectangle1
else
  puts rectangle2
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	int x;

	cin >> x;

	vector<int> Power;
	int j = 2;
	int temp = 0;
	Power.push_back(1);
	for (int i = 2; i < 33; i++)
	{
		while (temp <= 1000) {
			temp = pow(i, j);
			Power.push_back(temp);
			j++;
		}
		j = 2;
		temp = 0;
	}
	
	sort(ALL(Power), greater<int>());

	for (int p : Power)
	{
		if (p <= x) {
			cout << p << endl;
			return 0;
		}
	}



}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll M;
    cin >> M;
    vector<P> items(M);
    rep(i, M) cin >> items[i].first >> items[i].second;
    ll d_sum = 0;
    ll d_cnt = 0;
    rep(i, M) {
        ll d = items[i].first;
        ll c = items[i].second;
        d_sum += d * c;
        d_cnt += c;
    }
    cout << (d_sum - 1) / 9 + d_cnt - 1 << '\n';
}

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


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    int x, n;
    cin >> x >> n;
    //vector<int> p(n);
    int tmp;
    vector<int> a(101);//あるかどうか
    //vector<int> b(101);

    int resmin = 999;
    int resmax = 999;
    int minflag = 999;
    int maxflag = 999;
    for(int i = 0; i <= 100; i++){
        a.at(i) = 1;
    }

    for(int i = 0; i < n; i++){
        cin >> tmp;
        a.at(tmp) = 0;
    }

    for(int i = x; i >= 0; i--){
        if(a.at(i) == 1){
            minflag = abs(x - i);
            resmin = i;
            break;
        }
    }

    for(int i = x; i <= 100; i++){
        if(a.at(i) == 1){
            maxflag = abs(x - i);
            resmax = i;
            break;
        }
    }

    if(minflag == 999){
        minflag = abs(x - (-1));
        resmin = -1;
    }
    if(maxflag == 999){
        maxflag = abs(x - 101);
        resmax = 101;
    }


    if(n == 0){
        cout << x << endl;
    }else if(maxflag == minflag){
        cout << resmin << endl;
    }else{
        if(minflag < maxflag){
            cout << resmin << endl;
        }else{
            cout << resmax << endl;
        }
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int n,a[200000],b[200000];
long long r;
int main (){
	cin >> n;
	for (int i=0;i<n;++i){
		cin >> a[i];
		b[i]=a[i]-i;
	}
	sort(b,b+n);
	for (int i=0;i<n;++i){
		r+=abs(b[i]-b[(n-1)/2]);
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    vector<int> pqr(3);
    for(int i=0;i<3;i++){
        cin>>pqr[i];
    }
    int sum=0;
    for(int i=0;i<3;i++){
        sum+=pqr[i];
    }
    sort(pqr.begin(),pqr.end());
    cout<<sum-pqr.back()<<endl;
    
    return 0;
}

Measured memory_bytes: 256
N,K=[int(thing) for thing in input().split(" ")]
A_list=[int(i) for i in input().split(" ")]

def get_inv_num(l):
    l=list(l)
    ret=0
    for ind in range(len(l)):
        char=l[ind]
        for s_ind in range(len(l))[ind:]:
            if int(l[s_ind])<int(char):
                ret=ret+1
    return ret

def get_inv_external(l):
    import collections
    l=list(l)
    l_count=collections.Counter(l)
    ret=0
    memo={}
    for num in l:
        if str(num) in memo:
            ret=ret+memo[str(num)]
        else:
            ret_tmp=0
            for suuji in l_count:
                if int(suuji)<int(num):
                    ret_tmp=ret_tmp+l_count[suuji]
            memo[str(num)]=ret_tmp
            ret=ret+ret_tmp
    return ret
internal=get_inv_num(A_list)
external=get_inv_external(A_list)
n,ret=divmod(internal*K+external*(K-1)*K//2,10**9+7)
print(ret)

Measured memory_bytes: 3572
N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]

ng = 0
ok = sum([-(-h // A) for h in H])

while (ok - ng) > 1:
    mid = (ok + ng) // 2
    cnt = 0
    for h in H:
        if h <= B * mid:
            continue
        cnt += -(-(h - B * mid) // (A - B))
    if cnt <= mid:
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 11028
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>

using ld = long double;
using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	/* constant */
	constexpr double epsilon = std::numeric_limits<double>::epsilon();

	/* math */
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }

	/* algorithm */
	ul gcd(const ul &a,const ul &b) { return (!b) ? a : gcd(b,a%b); } // NOTE: a > b
	
	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

// std::cout << std::fixed << std::setprecision(15) << std::endl;

int main(int argc,char *argv[])
{
	ll n;
	std::cin >> n;

	std::vector<ul> a(n,0);
	for(ll i = 0;i < n;++i) std::cin >> a[i];

	std::sort(a.begin(),a.end(),std::less<>());
	if(a[0] == 0) { std::cout << 0 << std::endl; return 0; }

	constexpr ul x = 1000000000000000000;
	ul ans = 1;
	for(ll i = 0;i < n;++i)
	{
		if(a[i] <= x/ans) ans *= a[i];
		else
		{
			std::cout << -1 << std::endl;
			return 0;
		}
	}

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

Measured memory_bytes: 4044
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	int n;
	cin >> n;
	map<string, int> ma;
	for (int i = 0; i < n; ++i) {
		string str;
		cin >> str;
		sort(str.begin(), str.end());
		int before_size = ma.size();
		ma[str];
		if (ma.size() == before_size) {
			ma[str]++;
		}
	}
	auto ans = accumulate(ma.begin(), ma.end(), 0LL, [](llong acc, auto itr) {return acc + static_cast<llong>(itr.second) * (itr.second + 1) / 2; });
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;
#define NIL -1
#define fi first
#define sec second
#define MAX INT_MAX
#define INF 99999999
#define ll long long
#define PI acos(-1.0)
#define MOD 1000000007
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define ull unsigned long long
#define triplell pair<pair<ll,ll> , ll>
#define triple pair<pair<int,int> , int>
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Forn(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define forba(i,a,b) for(int i=(int)b;i>=(int)a;i--)

int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */
    
    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;
    
    string s,s1,s2;
    cin>>s;
    l=s.size();
    
    s1=s2="";
    while(s1.size()<=l)
    {
    	s1+="10";
    	s2+="01";
	}
	
	int ans = INT_MAX;
	
	int cnt = 0;
	for(i=0;i<l;i++)
	{
		if(s[i]!=s1[i])
			cnt++;
	}
	
	ans = min(ans,cnt);
	
	cnt = 0;
	for(i=0;i<l;i++)
	{
		if(s[i]!=s2[i])
			cnt++;
	}
	
	ans = min(ans,cnt);
	
	cout<<ans<<endl;
	
//	main();

    return 0;
}

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

int debug = 0;

const int N = 2e5 + 10;

namespace modul {

    int mod = 1e9 + 7;
    int fac[N], fre[N];

    int add(int a, int b) {
        a += b;
        while (a >= mod) a -= mod;
        return a;
    }

    int sub(int a, int b) {
        a -= b;
        while (a < 0) a += mod;
        return a;
    }

    int mul(int a, int b) {
        return a * b % mod;
    }

    int pw(int x, int p) {
        if (p == 0) return 1;
        if (p % 2) return pw(x, p - 1) * x % mod;
        int pp = pw(x, p / 2);
        return pp * pp % mod;
    }

    int rev(int a) {
        return pw(a, mod - 2);
    }

    int div(int a, int b) {
        return mul(a, rev(b));
    }

    void precalc() {
        fac[0] = 1;
        rep(i, 1, N) {
            fac[i] = mul(fac[i - 1], i);
        }
        fre[N - 1] = rev(fac[N - 1]);
        for (int i = N - 2; i >= 0; --i) {
            fre[i] = mul(fre[i + 1], i + 1);
        }
    }

    int C(int nn, int k) { /// O(1)
        if (nn - k < 0) return 0;
        return mul(fac[nn], mul(fre[k], fre[nn - k]));
    }

    int P(vector <int> sizes) {
        int cursum = 0, res = 1;
        for (int i : sizes) {
            cursum += i;
            res = mul(res, C(cursum, i));
        }
        return res;
    }
}

using namespace modul;

int n;
vector <int> g[N];
int dp1[N], dp2[N], sz[N], ans[N];

void dfs1(int v, int par = -1) {
    vector <int> s;
    int res = 1;
    sz[v] = 1;
    for (int u : g[v]) if (u != par) {
        dfs1(u, v);
        sz[v] += sz[u];
        s.push_back(sz[u]);
        res = mul(res, dp1[u]);
    }
    res = mul(res, P(s));
    dp1[v] = res;
    if (debug) {
        cerr << " v: " << v << " dp1: " << dp1[v] << '\n';
    }
}

void dfs2(int v, int par = -1) {
    vector <int> s;
    int all = 1, sum = 0;
    if (par == -1) {
        all = 1;
        dp2[v] = 1;
    } else {
        all = dp2[v];
        s.push_back(n - sz[v]);
        sum += n - sz[v];
    }
    for (int u : g[v]) if (u != par) {
        all = mul(all, dp1[u]);
        s.push_back(sz[u]);
        sum += sz[u];
    }
    int coeff = P(s);
    all = mul(all, coeff);
    for (int u : g[v]) if (u != par) {
        dp2[u] = div(all, mul(dp1[u], C(sum, sz[u])));
        dfs2(u, v);
    }

    int res = 1;
    for (int u : g[v]) if (u != par) {
        res = mul(res, dp1[u]);
    }
    if (par != -1) {
        res = mul(res, dp2[v]);
    }
    res = mul(res, coeff);
    ans[v] = res;
    if (debug) {
        cerr << " v: " << v << " dp2: " << dp2[v] << '\n';
        cerr << " P(s): " << coeff << '\n';
    }
}

main() {
    precalc();
    cin >> n;
    rep(i, 0, n - 1) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs1(0, -1);
    dfs2(0, -1);

    rep(k, 0, n) {
        cout << ans[k] << '\n';
    }
}


Measured memory_bytes: 26296
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        while (true) {
            
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            
            if (n==0 && x==0) { break; }
            
            // n x   1...n -> a, b, c -> a + b + c = x
            
            int count = 0;
            for (int i=1; i<=n-2; i++) {
                for(int j=i+1; j<=n-1; j++) {
                    for(int k=j+1; k<=n; k++) {
                        if (i+j+k == x){
                            count++;
                        }
                    }
                }
            }
            
            System.out.println(count);
            
            
        }
    }
}


Measured memory_bytes: 26772
#include <cstdio>
#include <vector>

struct ST
{
  int at;
  int len;
};

int c[100000];

int main()
{
  char s[100001];
  scanf("%s", s);
  
  std::vector<ST> v;
  char last = 'R';
  char *p;
  for (p = s; *p;)
  {
    ST st;
    char *q = p;
    st.at = p - s;
    while (*p == last)
    {
      ++p;
    }
    last = *p;
    st.len = p - q;
    v.emplace_back(st);
  }
  
  for (int i = 0; i < v.size(); i += 2)
  {
    c[v[i].at + v[i].len - 1] += (v[i].len + 1) / 2;
    c[v[i].at + v[i].len] += v[i].len / 2;
    
    c[v[i + 1].at] += (v[i + 1].len + 1) / 2;
    c[v[i + 1].at - 1] += v[i + 1].len / 2;
  }
  
  for (int i = 0; i < p - s; ++i)
  {
    printf("%d ", c[i]);
  }
  return 0;
}
       

Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-9
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define siz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
#define fir first
#define sec second
#define endl '\n'
typedef pair<int,int> pii;
typedef unsigned long long ull;
const long long linf=1LL<<62;
const int iinf=1000000009;
const double dinf=1e15;
const int Mod=1e9+9;
const int base=228;
typedef long long ll;
typedef long double ld;
struct Solver {
	ll cnt=1,crt=1;
	ll n,k;
	ll len[55],num[55];
	void cal(int x) {
		len[x]=cnt;num[x]=crt;
		cnt=cnt*2+3;crt=crt*2+1;
		if(x==n) return ;
		cal(x+1);
	}
	ll dfs(int x,ll xx) {
		ll res=0;
		if(xx==0) return 0;
		if(x==0) return 1;
		if(len[x]<=xx) return num[x];
		if(xx<=len[x]/2) return dfs(x-1,xx-1);
		if(xx==len[x]/2+1) return num[x]/2+1;
		if(xx>len[x]/2+1) return num[x]/2+1+dfs(x-1,xx-len[x]/2-1);
	}
	void solve(){
		iossy;
		cin>>n>>k;cnt=1;
		cal(0);
		cout<<dfs(n,k)<<endl;
	}
};
int main(){
//	p[0]=1;
//	For(i,1,500005) p[i]=p[i-1]*base;
//	while(scanf("%d",&n)!=EOF) solve();
	int t=1;
	Solver solver;
	solver.solve();
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> a(N);

  for (int i =0;i<N;i++) {
	cin >> get<0>(a[i]) >> get<1>(a[i]);
    get<1>(a[i]) = get<1>(a[i])*-1;
    get<2>(a[i])=i+1;
  }
    sort(a.begin(), a.end());
  for (int i =0;i<N;i++) {
	cout << get<2>(a[i]) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii; 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main() {

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    //int t; cin>>t; while(t--) 
	int n; cin>>n;
	if(n%10==3) cout<<"bon";
	else if(n%10==1 || n%10==8 || n%10==0 || n%10==6) cout<<"pon";
	else cout<<"hon";
	
    return 0 ;  
}

Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	string S;
	cin >> S;
	if (S[0] == S[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include <string>


using namespace std;

int main(){
    int ans=0;
    int N;

    cin>>N;

    vector<tuple<string,int,int>> pairs;

    for(int i=0;i<N;i++){
        string S;
        int P;
        cin >> S>>P;
        pairs.emplace_back(S,-P,i);
    }

    sort(pairs.begin(),pairs.end());

    //cout<<ans<<endl;

    for(int i=0;i<N;i++){
        cout<<get<2>(pairs[i])+1<<endl;
    }

    return 0;
}

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

int main() {
  char s[4];
  cin >> s;
  if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int count(int x){
    if(x == 0) return 0;
    return count(x >> 1) + (x & 1);
}

void solve(){
    int n;
    cin >> n;
    int a[20],x[20][20],y[20][20];
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        for(int j = 1; j <= a[i]; ++j){
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bit = 1; bit < (1 << n); ++bit){
        bool check = true;
        for(int i = 1; i <= n; ++i){
            if(!((bit >> (i - 1)) & 1)) continue;
            for(int j = 1; j <= a[i]; ++j){
                if(((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) check = false;
            }
        }
        if(check) ans = max(ans,count(bit));
    }

    cout << ans << endl;

    return ;
}

int main(){
    solve();

    return 0;
}

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

typedef long long ll;

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;

#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
 
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
    return out <<  "(" << a.first << ", " << a.second << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {			
    out << "[";
    for (auto it = a.begin(); it != a.end(); ++it) {
        if (it != a.begin())
            out << ", ";
        out << *it;
    }
    return out << "]";
}

void solve(){
    ll a,b,d;
    cin >> a >> b >> d;
    cout<<b/d - (a-1)/d<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
   // cin >> t;
    while(t--){
        solve();
    }

	return 0;
}


Measured memory_bytes: 3656
w,h,n=map(int,raw_input().split())
l=[['.' for i in range(w)] for j in range(h)]
for i in range(n):
    x,y,a=map(int,raw_input().split())
    if a==1:
        for i in range(h):
            for j in range(x):
                l[i][j]='#'
    elif a==2:
        for i in range(h):
            for j in range(x,w):
                l[i][j]='#'
    elif a==3:
        for i in range(y):
            l[i]=['#' for j in range(w)]
    else:
        for i in range(y,h):
            l[i]=['#' for j in range(w)]

ans=chk=0
for i in l:
    ans+=i.count('.')
print ans

Measured memory_bytes: 2696
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#define N 100005
using namespace std;

int n, T, A, mx, h[N], v[N];
vector<int> a[N];
void f(int p, int q) {
	int i;
	if (h[p] != -1) return;
	h[p] = q;
	for (i = 0; i < a[p].size(); i++) {
		f(a[p][i], q + 1);
	}
}

void g(int p, int q) {
	int i;
	if (q > h[p]) return;
	if (v[p]) return;
	v[p] = 1;
	mx = max(mx, h[p]);
	for (i = 0; i < a[p].size(); i++) {
		g(a[p][i], q + 1);
	}
}

int main()
{
	int i, t1, t2;
	cin >> n >> T >> A;
	for (i = 0; i < n - 1; i++) {
		scanf ("%d %d", &t1, &t2);
		a[t1].push_back(t2);
		a[t2].push_back(t1);
	}
	memset(h, -1, sizeof(h));
	f(A, 0);
	g(T, 0);
    cout << mx - 1 << endl;
    return 0;
}


Measured memory_bytes: 10368
S = list(input())

zenhan = []
kouhan = []
result1 = True
result2 = True
result3 = True


for i in range(len(S)//2):
    zenhan.append(S[i])

for i in range(len(S)//2+1,len(S)):
    kouhan.append(S[i])

for i in range(len(S)//2-1):
    if S[i] != S[len(S)-i-1]:
        result1 = False
        break

for i in range(len(zenhan)//2):
    if zenhan[i] != zenhan[len(zenhan)-i-1]:
        result2 = False
        break

for i in range(len(kouhan)//2):
    if kouhan[i] != kouhan[len(kouhan)-i-1]:
        result3 = False
        break
#print(zenhan)
#print(kouhan)
#print(result1,result2,result3)

if result1 and result2 and result3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    long k = Long.parseLong(sc.next());
    long ans = 0;
    int n = s.length();
    String c[] = new String[n+1];
    int ren = 1;
    int stock = 0;
	int first = 1;
    int last = 1;
    
    for(int i= 0; i < n; i++) {
      c[i] = s.substring(i, i+1);
    }
    c[n] = "0";

    // all pat
    for(int i=1; i<n; i++) {
      if(c[i].equals(c[i-1])) {
        ren++;
      }
    }
    
    if (ren == n) {
      if ((long)n * k % 2 == 0) {
        System.out.println(((long)n * k)/2);
      } else {
        System.out.println(((long)n * k - 1)/2);
      }
      return;
    }
    
    ren = 1;
    
    // FIRST not equal LAST
    if(!c[0].equals(c[n-1])) {
      for(int i=1; i<n+1; i++) {
        if(c[i].equals(c[i-1])) {
          ren++;
        } else {
          if(ren%2 == 0) {
            stock += ren/2;
          } else {
            stock += (ren-1)/2;
          }
          ren = 1;
        }
      }
      ans = stock * k;
      System.out.println(ans);
      return;
      
    } else { // equal
      
      // look F & L
      for(int i=1; i<n; i++) {
        if(c[i].equals(c[i-1])) {
          ren++;
        } else {
          first = ren;
          ren = 1;
          break;
        }
      }
      for(int i=1; i<n; i++) {
        if(c[n-i-1].equals(c[n-i])) {
          ren++;
        } else {
          last = ren;
          ren = 1;
          break;
        }
      }
      
      long conn = first + last;
      long aconn = 0;
      if(conn%2 == 0) {
        aconn = conn/2;
      } else {
        aconn = (conn-1)/2;
      }
      
      for(int i=first; i<n-last+1; i++) {
        if(c[i].equals(c[i-1])) {
          ren++;
        } else {
          if(ren%2 == 0) {
            stock += ren/2;
          } else {
            stock += (ren-1)/2;
          }
          ren = 1;
        }
      }
      
      int af = 0;
      int al = 0;
      if(first>1){
        if(first%2==0){
          af = first / 2;
        } else {
          af = (first-1) / 2;
        }
      }
      if(last>1){
        if(last%2==0){
          al = last / 2;
        } else {
          al = (last-1) / 2;
        }
      }
      
      ans = (long)stock * k + aconn * (k-1) + af + al;
      System.out.println(ans);

    }
    
  }
}


Measured memory_bytes: 22996
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }


void main() {
    int n = readint();
    int[] a = readints();

    int m = a.reduce!max;
    int mid = m / 2;
    int md = 1145141919, r = 0;
    
    foreach (i; a) if (i != m) {
        int d = abs(mid - i);
        if (d < md) {
            md = d;
            r = i;
        }
    }

    writeln(m, " ", r);
}

Measured memory_bytes: 4472
#input 
n = int(input())

numbers =[]
for i in range(n):
    numbers.append(int(input()))

max_value = max(numbers)

count_max = numbers.count(max_value)
index_max = numbers.index(max_value)

numbers_second = numbers
del numbers_second[index_max]
second_max_value = max(numbers_second)

if count_max >= 2:
    for i in range(n):
        print(max_value)

else:
    for i in range(n):
        if i == index_max:
            print(second_max_value)
        else:
            print(max_value)


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

using namespace std;

int main() {	
	while (true) {
		int e;
		int ans = 1e+9;
		cin >> e;
		if (e == 0) {
			break;
		}
		
		for (int z = 100; z >= 0; z--) {
			for (int y = 1000; y >= 0; y--) {
				int x;
				if (e >= z * z * z + y * y) {
					x = e - z * z * z - y * y;
					ans = min(ans, x + y + z);
				}
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

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

const int maxn = 2e5 + 10;

int n,k;
double p[maxn];

int main()
{
	
	//std::ios::sync_with_stdio(false);cin.tie(0);
	scanf("%d %d",&n,&k);
	for(int i = 1; i <= n; i++){
		scanf("%lf",&p[i]);
		p[i] = (1.0 + p[i]) / 2.0;
	}	
	double ans = 0, now = 0;
	for(int l = 1, r = 0; l <= n;){
		while(r - l < k - 1 && r < n) now += p[++r];
		//cout << now << endl;
		if(r - l == k - 1) {
			ans = max(ans,now);
			now -= p[l++];
		}
		else break;
		
	}
	printf("%.6f",ans);
	return 0;
}

Measured memory_bytes: 1792
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto lr = readln.split.to!(long[]);
    auto L = lr[0];
    auto R = lr[1]+1;

    if (R-L >= 2019L) {
        writeln(0);
        return;
    }

    long x = long.max;
    foreach (l; L..R) {
        foreach (r; l+1..R) {
            x = min(x, (l*r)%2019L);
        }
    }
    writeln(x);
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000000

int main() {
	int i, a[N], r[N], k, n, cnt = 0;

	scanf("%d", &n);

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

	for (i = 0; i <n; i++) {
		r[a[i] - 1] = i;
	}

	for (i = 0; i < n; i++) {
		printf("%d ", r[i] + 1);
	}

	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int a = 753;
    int N = s.size();
    int ans = inf;
    rep(i, N-2){
        int b = 0;
        b += 100*(s[i]-'0');
        b += 10*(s[i+1]-'0');
        b += s[i+2]-'0';
        ans = min(ans, abs(a-b));
    }
    cout << ans << endl;
}

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

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    priority_queue<int> give;
    ll recv = 0, just = 0;
    if (accumulate(all(a),0LL) < accumulate(all(b),0LL)) {
        cout << -1 << endl;
        return 0;
    }
    rep(i,n) {
        if (a[i]>b[i]) give.push(a[i]-b[i]);
        if (a[i]<b[i]) recv += (b[i]-a[i]);
        if (a[i]==b[i]) just++;
    }
    while(recv>0) {
        recv -= give.top(); give.pop();
    }
    cout << n-just-(int)give.size() << endl;
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	ll a[N];
	rep(i, 0, N) cin >> a[i];

	ll res = 0, sum = 0;
	int right = 0;
	rep(left, 0, N) {
		while(right < N and ((sum ^ a[right]) == sum + a[right])) {
			sum += a[right];
			right++;
		}

		res += (right - left);

		if(left == right) right++;
		else sum -= a[left];
	}

	cout << res << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	long long int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)
	{
		cout << "No" << endl;
		return 0;
	}
	if (4 * a * b < c * c + (a + b) * (a + b) - 2 * (a + b) * c)cout << "Yes" << endl;
	else cout << "No" << endl; 
}


Measured memory_bytes: 3624
// </> : towhid1zaman
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) (v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 1e18;



int main(){
        _
        int n; cin >> n;
        cpp_int a[n];
        cpp_int res = 1;
        rep(i,n){
            cin >> a[i];
        }
        sort(a, a+n);
        rep(i,n){
            cin >> a[i];
            res = res*a[i];
            if(res > 1000000000000000000)
            {
                cout << -1 << endl;
                return 0;
            }
        }
        cout << res << endl;


return 0;
}




Measured memory_bytes: 6856
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

int r[] = {1,4,1,4,1,2,1,2,1,4,1,4,1,2,1,2};

int main(){
	int p[8];
	while(1){
		for(int i = 0;i < 8;i++){
			if(!(cin >> p[i])) return 0;
		}
		int mi = 1e+9,m;
		for(int i = 0;i < 8;i++){
			int cnt = 0;
			for(int j = 0;j < 8;j++){
				cnt += max(0,p[j] - r[i + j]);
			}
			if(mi > cnt){
				int tmp = 0;
				for(int k = 0;k < 8;k++) tmp = tmp * 10 + r[i + k];
				m = tmp;
				mi = cnt;
			}else if(mi == cnt){
				int tmp = 0;
				for(int k = 0;k < 8;k++) tmp = tmp * 10 + r[i + k];
				m = min(tmp,m);
			}
		}
		vector<int> v;
		for(int i = 0;i < 8;i++) v.push_back((m / (int)pow(10.0,i)) % 10);
		for(int i = 7;i >= 1;i--) cout << v[i] << " ";
		cout << v[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A+3);
	if(A[0] * A[1] * A[2] % 2 == 0){
		cout << 0 << endl;
	}
	else{
		cout << A[0] * A[1] << endl;
	}
}

Measured memory_bytes: 256
from collections import deque

N, M, *L = map(int, open(0).read().split())
AB, VDC = L[:2 * M], L[2 * M + 1:]

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

colors = [0] * (N + 1)
visited = [-1] * (N + 1)

for v, d, c in reversed(tuple(zip(*[iter(VDC)] * 3))):
    Q = deque([(d, v)])
    while Q:
        cnt, v = Q.popleft()
        if visited[v] >= cnt:
            continue
        if colors[v] == 0:
            colors[v] = c
        visited[v] = cnt
        if cnt > 0:
            Q.extend((cnt - 1, u) for u in E[v])

for c in colors[1:]:
    print(c)


Measured memory_bytes: 51776
#include <iostream>
#include <algorithm>
using namespace std; 
int n;
long long la, lb, k;
void solve() {
	int a, b;
	cin >> n;
	la = lb = 1;
	for(int i = 0; i < n; ++i)
	{
		cin >> a >> b;
		k = (la + a - 1) / a;
		k = max(k, (lb + b - 1) / b);
		la = a * k;
		lb = b * k;
	}
}



int main() {
	solve();
	cout << la + lb << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define FOR(i,a,b) for( ll i=(a) ; i<=(b) ; ++i)
#define FORR(i,a,b) for( ll i=(a) ; i>=(b) ; --i)
#define RD(v,n) for(ll i =0;i<n;i++ ) cin>>v[i]
#define bolt ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
	bolt;
	ll t;
	cin>>t;
	string s;
	cin>>s;
	string dp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	ll n = s.length();
	for( ll i=0;i<n;i++ ){
		cout<< dp[  (((s[i]-'A')+t)%26) ] ;
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define FOR(i,k,n) for(int(i)=(k);(i)<(n);(i)++)
using namespace std;

int main()
{
  // long long A,B;
  string A,B;
  cin >> A >> B;
  string s;

  int lenA, lenB;
  lenA = A.length();
  lenB = B.length();

  if (lenA > lenB) s = "GREATER";
  else if (lenA < lenB) s = "LESS";
  else {
    s = "EQUAL";
    FOR(i,0, lenA) {
      if (A[i] > B[i]) {
        s = "GREATER"; break;
      } else if (A[i] < B[i]) {
        s = "LESS"; break;
      }
    }
  }

  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, l, s;
    int[] m, n;
    m = new int[12]; n = new int[12];
    for(;;){
      l = sc.nextInt(); if(l == 0)break;
      for(i = 0;i < 12;i++){
        m[i] = sc.nextInt(); n[i] = sc.nextInt();
      }
      s = 0;
      for(i = 0;i < 12;i++){
        s += (m[i] - n[i]);
        if(s >= l){
          out.println(i + 1); break;
        }
      }
      if(i == 12)out.println("NA");
    }

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

Measured memory_bytes: 43256