akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
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, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
tree=[[] for i in range(n)]
for i in range(n-1):
    a,b=MI()
    a-=1
    b-=1
    tree[a].append(b)
    tree[b].append(a)
dis1=[-1 for i in range(n)]
dis2=[-1 for i in range(n)]
dis1[0]=0
dis2[-1]=0

def dfs1(x,l):
    for i in tree[x]:
        if dis1[i]>=0:
            continue
        else:
            dis1[i]=l+1
            dfs1(i,l+1)
dfs1(0,0)
#print(dis1)
def dfs2(x,l):
    for i in tree[x]:
        if dis2[i]>=0:
            continue
        else:
            dis2[i]=l+1
            dfs2(i,l+1)
dfs2(n-1,0)
#print(dis2)
count=0
for i in range(n):
    if dis1[i]<=dis2[i]:
        count+=1
    else:
        count-=1
if count<=0:
    print("Snuke")
else:
    print("Fennec")
    

        
        
        
            
        

                

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

long long a[100000+20]={0};

int main ()
{
	int i,n;
	cin>>n;
	for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
	sort(a,a+n);
	long long n1=1,bj=0;
	for(i=n-1;i>0;i--)
	{
		if(a[i]==a[i-1])
		{
			n1=a[i]*n1;
			a[i-1]=0;
			bj++;
		}
		if(bj>=2)
			break;
	}
	if(bj<2)
		cout<<"0"<<endl;
	else
		cout<<n1<<endl;
	return 0;
} 

Measured memory_bytes: 1024
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int dp[k+1];
  dp[0] = 0;
  for(int i=1;i<k+1;i++){
    dp[i] = 0;
    for(int j=0;j<n;j++){
      if(i-a[j]>=0 && dp[i-a[j]] == 0) dp[i] = 1;
    }
  }
  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	char ch=getchar();int o=0,f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') o=(o<<3)+(o<<1)+(ch^48),ch=getchar();
	return f*o;
}
int n,m,a[100];
char c,tmp='*';
int main(){
	n=read();
	for(register int i=1;i<=n;i++) {
		cin>>c;
		if(c!=tmp){
			tmp=c;
			m++; 
		}
	}
	cout<<m<<endl;
	return 0;
}

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

int main(){
  long long n; cin>>n;
  int ans=0;
  bool flag=true;
  while(n!=0){
    if(n/10==0){
      ans+=n-1;
      n=0;
    }else{
      if(n%10!=9) flag = false;
      n/=10;
      ans+=9;
    }
  }if(flag) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{
   int n;cin>>n;
   int dp[n+1][3]={{0}};
   for(int i=1;i<=n;i++)
   {
       int a;int b;int c;cin>>a>>b>>c;
       dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
       dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
       dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
   }
   cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}
int32_t main()
{
    rapido;
    int t;t=1;
    while(t--)
    solve();
}

Measured memory_bytes: 5900
#include<stdio.h>
int main(void)
{
    int w,n,i;
    scanf("%d %d",&w,&n);
    int W[w];
    int a[n],b[n],c[n];
    char z;
    for(i = 0; i < w; i++){
        W[i] = i+1;
    }
    for(i = 0; i < n; i++){
        scanf("%d%c%d",&a[n],&z,&b[n]);
        c[n] = W[a[n]-1];
        W[a[n]-1] = W[b[n]-1];
        W[b[n]-1] = c[n];
    }


    for(i = 0; i < w; i++) printf("%d\n",W[i]);

    return 0;
}

Measured memory_bytes: 596
import sys
from collections import deque
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    A = list(readnums())
    b = 1000
    s = 0
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            s += b // A[i]
            b %= A[i]
        elif A[i] > A[i + 1]:
            b += A[i] * s
            s = 0

    if A[-1] >= A[-2]:
        b += A[-1] * s
        s = 0

    print(b)
    # d = deque(A)
    # d.appendleft(201)
    # d.append(0)
    # # ans = 1000 + (max(A) - min(A)) * (1000 // min(A))
    # il = []
    # for i in range(N):
    #     if d[i] <= d[i + 1] and d[i + 1] > d[i + 2]:
    #         il.append(i)
    #     elif d[i] >= d[i + 1] and d[i + 1] < d[i + 2]:
    #         il.append(i)

    # # print(il)
    # if len(il) <= 1:
    #     print(1000)
    # else:
    #     b = 1000
    #     s = 0
    #     if A[il[0]] < A[il[1]]:
    #         for i, v in enumerate(il):
    #             if not i % 2:
    #                 s += b // A[v]
    #                 b -= s * A[v]
    #             else:
    #                 b += s * A[v]
    #                 s = 0
    #             # print(b, s)
    #     else:
    #         for i, v in enumerate(il):
    #             if i % 2:
    #                 s += b // A[v]
    #                 b -= s * A[v]
    #             else:
    #                 b += s * A[v]
    #                 s = 0
    #             # print(b, s)
    #     if s:
    #         b = A[il[-1]] * s

    #     print(max(b, 1000))


if __name__ == "__main__":
    main()


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

using namespace std;

int main(int argc, char const *argv[])
{
    unordered_map<char,int> count;
    string s;
    cin >> s;
    for(char i : s)
        count[i] += 1;
    if(count.size() !=2)
    {
        cout << "No";
        return 0;
    }   
    bool flag = true;
    for(auto i : count)
    {
        if(count[i.first]!=2)
        {
            cout << "No";
            flag = false;
            break;
        }
    }
    if(flag)
        cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
import math
import string
import fractions
import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random




def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    n,m = map(int, input().split())
    l = sorted(list(map(int, input().split())))
    
    l_diff = [(l[i+1] - l[i]) for i in range(len(l)-1)]
    # eprint(l)
    # eprint(l_diff)
    l_diff.sort()
    # eprint(l_diff)

    for i in range(min(n-1,len(l_diff))):
        l_diff.pop()
    print(sum(l_diff))
    # for i in range(0,n-1):
    #     sum += l[i+1] -l[i]

if __name__ == '__main__':
    main()


Measured memory_bytes: 83236
S = []

for i in input().split():
    if i.isdigit():
        S.append(int(i))
    elif i == "+":
        b = S.pop()
        a = S.pop()
        S.append(a + b)
    elif i == "-":
        b = S.pop()
        a = S.pop()
        S.append(a - b)
    elif i == "*":
        b = S.pop()
        a = S.pop()
        S.append(a * b)

ans = S.pop()
print(ans)


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

int main() {
  int n; cin >> n;
  vector<string> s(n);
  for(int i = 0; i < n; i++){
    cin >> s.at(i);
  }
  sort(s.begin(), s.end());
  vector<string> out;
  int max = 0;
  int ind = 1;
  for(int i = 1; i < n; i++){
    if(s.at(i) == s.at(i-1)){
      ind++;
    }else{
      if(ind > max){
        if(out.size() >= 1){
          while(!out.empty()){
            out.pop_back();
          }
        }
        max = ind;
        out.push_back(s.at(i - 1));
        ind = 1;
      }else if(ind == max){
        out.push_back(s.at(i - 1));
        ind = 1;
      }else{
        ind = 1;
      }
    }
    if(i == s.size() - 1){
      if(ind > max){
        if(out.size() >= 1){
          while(!out.empty()){
            out.pop_back();
          }
        }
        max = ind;
        out.push_back(s.at(i));
        ind = 1;
      }else if(ind == max){
        out.push_back(s.at(i));
        ind = 1;
      }else{
        ind = 1;
      }
    }
  }
  sort(out.begin(), out.end());
  for(int i = 0; i < out.size(); i++){
    cout << out.at(i) << endl;
  }
}

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    string S;
    cin >> S;
    bool r, l;
    r = l = true;
    for (int i = 0; i < S.length(); i++)
    {
        if ((i % 2 == 0) && S[i] == 'L')
        {
            r = false;
        }
        if ((i % 2 == 1) && S[i] == 'R')
        {
            l = false;
        }
    }
    if (r && l)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

using namespace std;

signed main() {
    int A, B, C;
    cin >> A >> B >> C;
    if( C > B/A){
      cout << (B/A) << endl;
    }else{
      cout << C << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  ll a, b, c, d;
  in(s);
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  rep(i, s.size()){
    if(s[i] == 'N')
      a++;
    if(s[i] == 'S')
      b++;
    if(s[i] == 'E')
      c++;
    if(s[i] == 'W')
      d++;
  }
  bool h = true;
  if(a != 0 && b == 0)
    h = false;
  if(a == 0 && b != 0)
    h = false;
  if(c != 0 && d == 0)
    h = false;
  if(c == 0 && d != 0)
    h = false;
  if(h)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1000000000; 
const ll mod = 1e9+7;

ll powmod(ll x,ll y){
  if(y == 0){
    return 1;
  }
  if(y == 1){
    return x%mod;
  }
  if(y%2 == 0){
    return (powmod(x,y/2)*powmod(x,y/2))%mod;
  }
  else{
    return (x*((powmod(x,y/2)*powmod(x,y/2)%mod)))%mod;
  }
}

int main(){
  ll n,k;
  cin >> n >> k;
  ll d[k+1];
  for(ll i=k; i>0; i--){
    ll a = k/i;
    d[i] = powmod(a,n);
    for(ll j=2*i; j<=k; j+=i){
      d[i]-=d[j];
      if(d[i] <0){
        d[i]+=ll(1e9+7);
      }
    }
  }
  ll ans = 0;
  for(ll i=1; i<=k; i++){
    //cout << d[i] << endl;
    ans += d[i]*i;
    ans %= ll(1e9+7);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 172, task a, 2020/06/26
//ms,
/*
*/

int main(void){
  int a;
  cin >>a;
  cout <<a+a*a+a*a*a;
  return 0;
}
/*
*/


Measured memory_bytes: 3632
/*
 * 	Just close your eyes
 * 		The sun is going down
 * 			You'll be alright...
 * 				No one can hurt you now
 * 					Come, morning light...
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
//#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const ll inf=1e18;
const int mod=1e9+7;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve()
{
	int n,x,y;
	cin>>n;
	vector<pii> ans;
	for(int i=0; i<n; i++) {
		cin>>x>>y;
		ans.pb({x,y});
	}
	sort(all(ans),[](pii &a,pii &b)-> bool {
		return a.fi+a.se<b.fi+b.se;
	});
	reverse(all(ans));
	ll an=0;
	for(int i=0; i<n; i++) {
		if((i&1)==0)
			an+=ans[i].fi;
		else
			an-=ans[i].se;
	}
	cout<<an<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(void){
	
	int n,i,ii,ca[4][13]={0},num;
	char ma;
	char mark[]={'S', 'H', 'C', 'D'};

	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf(" %c %d", &ma, &num);
		if(ma=='S') ca[0][num-1]=1;
		else if(ma=='H') ca[1][num-1]=1;
		else if(ma=='C') ca[2][num-1]=1;
		else if(ma=='D') ca[3][num-1]=1;
	}

	for(i=0; i<4; i++){
		for(ii=0; ii<13; ii++){
			if(ca[i][ii]==0){
				printf("%c %d\n", mark[i], ii+1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.next());
        }

        System.out.println(set.size());
    }
}

Measured memory_bytes: 76900
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a; 
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, m;
	cin >> n >> m;
	string s1 = "", s2 = "";
	f(i, 0, n)
	{
		s1 += to_string(m);
	}
	f(i, 0, m)
	{
		s2 += to_string(n);
	}
	if (s1 <= s2)
		cout << s1;
	else
		cout << s2;
	return 0;
}


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

int main() {
  int n;cin>>n;
  vector<vector<int>> vec(n,vector<int>(n,-1));
  rep(i,n){
    int a;cin>>a;
    rep(j,a){
      int x,y;cin>>x>>y;
      x--;
      vec[i][x]=y;//i番目の人がx番目の人が正直者か不親切な人か言った
    }
  }
  int ans=0;
  rep(bit,1<<n){
    vector<int> d(n);
    //1~n番目の人が正直者か不親切な人かbit全探索
    rep(j,n)if(bit&(1<<j))d[j]=1;//j番目の人が正直者なら1
    bool ok=true;
    rep(i,n)if(d[i]){
      //i番目の人が正直者
      rep(j,n){
        if(vec[i][j]==-1)continue;//i番目の人がj番目の人に対して言及していない
        if(vec[i][j]!=d[j])ok=false;//正直なi番目の人がj番目の人に対して正直者か不親切な人かを言って、その結果が矛盾している
      }
    }
    if(ok)ans=max(ans,__builtin_popcount(bit));//bitの1の個数、すなわち正直者の人数
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3552
n = gets.chomp
x = n.chars

cnt_b = 0
cnt_w = 0
for i in 0..x.length-1
    if i % 2 ==0
        if x[i]=="0"
            cnt_b+=1
        end
    else
        if x[i]=="1"
            cnt_b+=1
        end
    end
end
#puts cnt_b

for i in 0..x.length-1
    if i % 2 ==0
        if x[i]=="1"
            cnt_w+=1
        end
    else
        if x[i]=="0"
            cnt_w+=1
        end
    end
end
#puts cnt_w
puts [cnt_b, cnt_w].min


Measured memory_bytes: 9468
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
LL ans,x,pr[100005],sf[100005],co[100005],mul[100005];
int n;
int main()
{
    scanf("%d",&n);
    pr[0]=1,sf[n+1]=1,sf[n+2]=1;
    for(int i=1;i<=n;i++)pr[i]=pr[i-1]*i,pr[i]%=MOD;
    for(int i=n;i>0;i--)sf[i]=sf[i+1]*i,sf[i]%=MOD;
    for(int i=1;i<=n;i++)co[i]=co[i-1]+(pr[i]*sf[i+2]),co[i]%=MOD;
    for(int i=1;i<=(n+1)/2;i++)
    {
        mul[i]+=co[n-i];
        mul[i]+=co[i-1];
        mul[i]%=MOD;
    }
    for(int i=n;i>n/2;i--)mul[i]=mul[n-i+1];
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        ans+=x*pr[n];
        ans%=MOD;
        ans+=x*mul[i];
        ans%=MOD;
    }
    printf("%lld",(ans+MOD*50)%MOD);
}


Measured memory_bytes: 6900
N, M = map(int, input().split())
KA = [list(map(int, input().split())) for _ in range(N)]

res = [0] * 31
for i in range(N):
    for a in KA[i][1:]:
        res[a] += 1
ans = 0
for r in res:
    if r == N:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <climits>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;


// 基本的な演算
namespace BasicMath {
    // 数字の桁を求める
    static UInt Digits(UInt number);

    UInt Digits(UInt number) {
        return to_string(number).length();
    }
}
using namespace BasicMath;

int main(void) {
    Int n;
    cin >> n;
    Int sq = sqrt(n);

    Int ans = INT_MAX;
    for (Int i = 1; i <= sq; ++i) {
        if (n % i != 0) {
            continue;
        }
        Int len = Digits(max(i, n / i));
        ans = min(ans, len);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vpii a(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i].ff;
        a[i].ss = i + 1;
    }
    sort(a.begin(),a.end());
    for(auto x : a)
    {
        cout << x.ss << ' ';
    }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct UnionFind
{
    vector<ll> par;
    vector<ll> rank;
    vector<ll> sz;
    UnionFind(ll n) : par(n), rank(n), sz(n)
    {
        for(ll i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }
    ll root(ll x)
    {
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
    void unite(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y])
        {
            par[x] = y;
            sz[y] += sz[x];
        }
        else
        {
            par[y] = x;
            sz[x] += sz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(ll x, ll y)
    {
        return root(x) == root(y);
    }
    ll size(ll x)
    {
        x = root(x);
        return sz[x];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    vector<int> y(m);
    vector<int> z(m);
    for(int i = 0; i < m; i++)
    {
        cin >> x[i] >> y[i] >> z[i];
    }
    UnionFind tree(n+1);
    for(int i = 0; i < m; i++)
    {
        if(!tree.same(x[i], y[i]))
        {
            tree.unite(x[i], y[i]);
        }
    }
    int ans = 0;
    set<int> before;
    for(int i = 1; i <= n; i++)
    {
        int cand = tree.root(i);
        if(before.find(cand) == before.end())
        {
            ans++;
            before.insert(cand);
        }
    }
    cout << ans << endl;
}



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

int n;
char input[10];
int ans;

int dice[6];		//上面,前面,右面,後面,左面,下面
int copy_dice[6];

void ini(){
	dice[0] = 1;
	dice[1] = 2;
	dice[2] = 3;
	dice[3] = 5;
	dice[4] = 4;
	dice[5] = 6;
}

//前面1→上面0→後面3→下面5
//上面0→後面3→下面5→前面1
void North(){
	int i;
	copy_dice[0] = dice[1];
	copy_dice[3] = dice[0];
	copy_dice[5] = dice[3];
	copy_dice[1] = dice[5];
	copy_dice[2] = dice[2];
	copy_dice[4] = dice[4];
	for( i = 0; i < 6; i++ )
		dice[i] = copy_dice[i];
}

//上面0→右面2→下面5→左面4
//右面2→下面5→左面4→上面0
void East(){
	int i;
	copy_dice[2] = dice[0];
	copy_dice[5] = dice[2];
	copy_dice[4] = dice[5];
	copy_dice[0] = dice[4];
	copy_dice[1] = dice[1];
	copy_dice[3] = dice[3];
	for( i = 0; i < 6; i++ )
		dice[i] = copy_dice[i];
}

//上面0→後面3→下面5→前面1
//前面1→上面0→後面3→下面5
void South(){
	int i;
	copy_dice[1] = dice[0];
	copy_dice[0] = dice[3];
	copy_dice[3] = dice[5];
	copy_dice[5] = dice[1];
	copy_dice[2] = dice[2];
	copy_dice[4] = dice[4];
	for( i = 0; i < 6; i++ )
		dice[i] = copy_dice[i];
}

//右面2→下面5→左面4→上面0
//上面0→右面2→下面5→左面4
void West(){
	int i;
	copy_dice[0] = dice[2];
	copy_dice[2] = dice[5];
	copy_dice[5] = dice[4];
	copy_dice[4] = dice[0];
	copy_dice[1] = dice[1];
	copy_dice[3] = dice[3];
	for( i = 0; i < 6; i++ )
		dice[i] = copy_dice[i];
}

//前面1→右面2→後面3→左面4
//左面4→前面1→右面2→後面3
void Right(){
	int i;
	copy_dice[4] = dice[1];
	copy_dice[1] = dice[2];
	copy_dice[2] = dice[3];
	copy_dice[3] = dice[4];
	copy_dice[0] = dice[0];
	copy_dice[5] = dice[5];
	for( i = 0; i < 6; i++ )
		dice[i] = copy_dice[i];
}

//左面4→前面1→右面2→後面3
//前面1→右面2→後面3→左面4
void Left(){
	int i;
	copy_dice[1] = dice[4];
	copy_dice[2] = dice[1];
	copy_dice[3] = dice[2];
	copy_dice[4] = dice[3];
	copy_dice[0] = dice[0];
	copy_dice[5] = dice[5];
	for( i = 0; i < 6; i++ )
		dice[i] = copy_dice[i];
}

void (*pf[6])() = {North,East,West,South,Right,Left};
char *type[6] = {"North","East","West","South","Right","Left"};

int main(){
	int i,j;
	
	while( scanf("%d",&n) ){
		if( !n )break;
		ans = 1;
		ini();
		
		for( i = 0; i < n; i++ ){
			scanf("%s",input);
			for( j = 0; j < 6; j++ ){
				if( strcmp( input, type[j] ) == 0 )
					break;
			}
			pf[j]();
			//printf("%d\n",dice[0]);
			ans += dice[0];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long LL;

const int MOD = 1e9+7;

void solve(){
    int n;
    cin>>n;
    unordered_set<int> t;
    bool f = true;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(t.count(x)) f = false;
        t.insert(x);
    }
    if(f) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8520
#include <cstdio>
#include <cctype>

int main(){
	char A;
	int i=0;

	while(i<1200){
		scanf("%c",&A);
		char S;		
		if(isalpha(A)){
			if(islower(A))S=toupper(A);
			else S=tolower(A);
			printf("%c",S);
		}
        else printf("%c",A);
		++i;
		if(A=='\n')break;           
	}

	return 0;
}

Measured memory_bytes: 2620
import sys
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]


for i in range(2**(len(S)-1)):
    op_list = ['+']*(len(S)-1)
    for j in range(len(S)-1):

        if (i>>j)&1:
            op_list[j]='-'
    s = ""
    for j in range(len(S)-1):
        s = s + S[j] + op_list[j]

    s = s + S[len(S)-1]

    if 7==eval(s):
        print(s,"=7", sep="")
        sys.exit()

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

using namespace std;

bool is_subset(vector<int> large,vector<int> small){
	bool ret = true;
	for(auto it = small.begin();it != small.end();it++){
		if(find(large.begin(),large.end(),*it) == large.end()) ret = false;
	}
	return ret;
}

int main(){
	int n;
	while(cin >> n,n){
		vector<vector<int>> p(n);
		for(int i=0;i<n;i++){
			int m;
			cin >> m;
			for(int j=0;j<m;j++){
				int pi;
				cin >> pi;
				p[i].emplace_back(pi);
			}
		}
		int k;
		cin >> k;
		vector<int> l(k);
		for(int i=0;i<k;i++){
			cin >> l[i];
		}
		int ans = 0;
		for(int unsigned i = 0;i<n;i++){
			if(is_subset(p[i],l)){
				if(ans==0) ans = i+1;
				else ans = -1;
			}
		}
		if(ans) cout << ans << endl;
		else cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3204
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, m;
	map<string, int> red, blue;
	list<string> ls;

	cin >> n;
	for (int i=0; i<n; ++i){
		string s;
		cin >> s;
		ls.push_back(s);
		blue[s] += 1;
	}

	cin >> m;
	for (int i=0; i<m; ++i){
		string s;
		cin >> s;
		blue[s] = blue[s] - 1;
	}

	int maxi = 0;
	
	for (string i : ls) {

		if(maxi < blue[i]) maxi = blue[i];
	}

	std::cout << maxi << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	float x[21],y[21],S=0;
	int n,i;
	for(n=0;~scanf("%f,%f",x+n,y+n);n++);
	x[n]=x[0],y[n]=y[0];
	for(i=0;i<n;i++)
		S+=(x[i]-x[i+1])*(y[i]+y[i+1]);
	printf("%f\n",S/2);
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <unordered_set>
#include <cstring>

using namespace std;

int N, M, A[305][305];
int sel[305];
unordered_set<int> have;
int ans = ~0u >> 1;

int main() {
    scanf("%d%d", &N, &M);
    for (int i = 0; i != N; ++i)
        for (int j = 0; j != M; ++j)
            scanf("%d", &A[i][j]);
    for (int i = 1; i <= M; ++i) have.insert(i);
    for (int r = M; r; --r) {
        memset(sel, 0, sizeof sel);
        for (int i = 0; i != N; ++i)
            for (int j = 0; j != M; ++j)
                if (have.find(A[i][j]) != have.end()) {
                    ++sel[A[i][j]]; break;
                }
        int maxi = 0;
        for (int i = 1; i <= M; ++i)
            if (sel[i] > sel[maxi]) maxi = i;
        ans = min(ans, sel[maxi]);
        have.erase(maxi);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 26
#define NIL (-1)
typedef struct {
    int parent;
    int left;
    int right;
}re;
re T[N];
int n;
int getsibling(int t){
    if(T[t].parent == NIL) return -1;
    else{
        if(T[T[t].parent].left == t) return T[T[t].parent].right;
        else return T[T[t].parent].left;
    }
}
int getdegree(int t){
    int res = 0;
    if(T[t].left != NIL) res++;
    if(T[t].right != NIL) res++;
    return res;
}
int depth(int t){
    if(T[t].parent == NIL) return 0;
    else return depth(T[t].parent) + 1;
}
int height(int t){
    int c1 = 0;
    int c2 = 0;
    if(T[t].left != NIL) c1 = height(T[t].left) + 1;
    if(T[t].right != NIL) c2 = height(T[t].right) + 1;
    return c1 > c2 ? c1 : c2;
}
char * type(int t){
//    char * res = (char *)malloc(30 * sizeof(char));
    char *res;
    if(T[t].parent == NIL) res = "root";
    else{
        if(T[t].left == NIL && T[t].right == NIL) res = "leaf";
        else res = "internal node";
    }
    return res;
}
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++) T[i].parent = T[i].left = T[i].right = NIL;

    for(int i = 0; i < n; i++){
        int parent, left, right;
        scanf("%d %d %d", &parent, &left, &right);
        T[parent].left = left;
        T[parent].right = right;
        T[left].parent = parent;
        T[right].parent = parent;
    }

    for(int i = 0; i < n; i++){
        printf("node %d: parent = %d, "
               "sibling = %d, degree = %d, "
               "depth = %d, height = %d, %s\n", i, T[i].parent,
               getsibling(i), getdegree(i),
               depth(i), height(i), type(i)
        );
    }
    return 0;
}


Measured memory_bytes: 2148
#include<stdio.h>
int main(void){
  int n,p[8],q[8],s[9],i,j,f,g,a[9],b[9];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&q[i]);
  }
  s[0]=1;
  for(i=1;i<=n;i++){
    s[i]=s[i-1]*i;
  }
  /* printf("%d\n",s[2]);*/
  for(i=1;i<=8;i++){
    a[i]=0;
    b[i]=0;
  }
  f=1;
  g=1;
  for(i=0;i<n;i++){
    for(j=1;j<=n;j++){
      if(j==a[1]){
	continue;
      }
      if(j==a[2]){
        continue;
      } 
      if(j==a[3]){
        continue;
      } 
      if(j==a[4]){
        continue;
      } 
      if(j==a[5]){
        continue;
      } 
      if(j==a[6]){
        continue;
      } 
      if(j==a[7]){
        continue;
      } 
      if(j==a[8]){
        continue;
      } 
    if(p[i]!=j){
      f=f+s[n-(i+1)];
      /*printf("%d\n",f);*/
    }
    else{
      a[i+1]=j;
      break;
    }
    /*printf("%d\n",f);*/
  }
  }
  for(i=0;i<n;i++){
    for(j=1;j<=n;j++){
      if(j==b[1]){
        continue;
      }
      if(j==b[2]){
        continue;
      }
      if(j==b[3]){
        continue;
      }
      if(j==b[4]){
        continue;
      }
      if(j==b[5]){
        continue;
      }
      if(j==b[6]){
        continue;
      }
      if(j==b[7]){
        continue;
      }
      if(j==b[8]){
        continue;
      }
    if(q[i]!=j){
      g=g+s[n-(i+1)];
      /*printf("%d\n",g);*/
    }
    else{
      b[i+1]=j;
      break;
    }
  }
  }
  if(f>=g){
    printf("%d\n",f-g);
  }else{
    printf("%d\n",g-f);
  }
  /* printf("%d %d\n",f,g);*/
  return 0;
}


Measured memory_bytes: 128
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); i++)

const int INF = 1001001001;

using namespace std;

int a[12][12];

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}

	int ans = INF;
	rep(s, 1 << n) {
		int cost = 0;
		vector<int> d(m);
		rep(i, n) {
			if (s >> i & 1) {
				cost += c[i];
				rep(j, m) d[j] += a[i][j];
			}
		}
		bool ok = true;
		rep(j, m) if (d[j] < x) ok = false;
		if (ok) ans = min(ans,cost);
	}
	
	if (ans == INF) cout << -1;
	else cout << ans;
	return 0;
}

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

using namespace std;

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

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  int n,l;
  cin>>n>>l;
  int a[n];
  int min = 1000000;
  int sum = 0;
  int counter = 0;
  for(int i = 0; i < n; i++){
    a[i]=l+i;
    if(abs(a[i])<min){
      min=abs(a[i]);
      counter = a[i];
    }
    sum+=a[i];
  }
  cout<<sum-counter<<endl;
  return 0;
}




Measured memory_bytes: 256
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 1LL<<60;


priority_queue<
    pii,
    vector<pii>,
    greater<pii>
> q;

int a[200005];
int b[200005];

int main(){
    int n,k;
    cin >> n >> k;
    rep1(i,n) cin >> a[i];
    int base = 0;

    int cnt = 0;
    bool flag = false;
    rep(_,k){
        if(flag)break;
        flag = true;
        cnt = 0;
        rep1(i,n){
            q.push(mp(i-a[i],0));
            q.push(mp(i+a[i]+1,1));
        }

        rep1(i,n){
    //        prints(i,cnt);
            while(!q.empty()){
                if(q.top().F>i) break;
                pii tmp = q.top();
                //prints(tmp.F,tmp.S);
                q.pop();
                if(tmp.S == 0){
                    cnt++;
                }
                else{
                    cnt--;
                }
            }
            a[i] = cnt;
            if(cnt!=n) flag = false;
        }

    }
    rep1(i,n) cout << a[i] << ' ';
    cout << endl;


    return 0;
}




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

int main() {
  int n, taro_p = 0, hana_p = 0;
  cin >> n;
  for (int i=0;i<n;i++) {
    string taro, hana;
    cin >> taro >> hana;
    if (taro > hana)
      taro_p += 3;
    else if (taro < hana)
      hana_p += 3;
    else {
      taro_p += 1;
      hana_p += 1;
    }
  }
  cout << taro_p << " " << hana_p << endl;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

vector<vector<pair<ll,ll>>> v(200000);
bool seen[200000];
ll mini[200000];

void ki(ll x){
    seen[x]=true;
    rep(i,0,v[x].size()-1){
        if(seen[v[x][i].first])continue;
        mini[v[x][i].first]=mini[x]+v[x][i].second;
        ki(v[x][i].first);
    }
    
}
int main(){
    ll n;cin>>n;
    ll a[n],b[n],c[n];
    rep(i,0,n-2){
        cin>>a[i]>>b[i]>>c[i];
        v[a[i]].pb(make_pair(b[i],c[i]));
        v[b[i]].pb(make_pair(a[i],c[i]));
        
    }
    ll q,k;cin>>q>>k;
    ll x[q],y[q];
    rep(i,0,q-1){
        cin>>x[i]>>y[i];
    }
    mini[k]=0;
    ki(k);
    rep(i,0,q-1){
        cout<<mini[x[i]]+mini[y[i]]<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 19072
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, vector<ll> A) {
  ll ans{};
  if (accumulate(ALL(A),(ld)1.,[](ld a, ll x){ return a*x;})>1e18) ans = -1;
  else ans = accumulate(ALL(A),1LL,[](ll a, ll x){ return a*x;});
  cout << ans << endl;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  solve(N, move(A));
  return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

void solve() {
    vector<int> a(5);
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    int k; cin >> k;
    int flag = true;
    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            if(a[j] - a[i] > k) {
                flag = false;
                break;
            }
            if(!flag) break;
        }
    }
    cout << (flag?"Yay!":":(") << endl;

}

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

Measured memory_bytes: 256
N = str(int(input()))
total = 0
l = len(N)-1
if l == 0:
    print(N)
else:
    for i in range(2**l):
        b = format(i, '0'+str(l)+'b')
        subtotal = 0
        s = N[0]
        for j in range(len(b)):
            if int(b[j]):
                subtotal += int(s)
                s = N[j+1]
            else:
                s += N[j+1]

        subtotal += int(s)
        total += subtotal

    print(total)

Measured memory_bytes: 9152
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
char s[200000 + 10];
int main()
{
    scanf("%s", s+1);
    int len = strlen(s+1);
    int a = 200000 + 10, z = -1;
    for(int i=1;i<=len;i++)
    {
        if(s[i] == 'A') a = min(a, i);
        if(s[i] == 'Z') z = max(z, i);
    }
    cout << (z-a+1) << endl;
}

Measured memory_bytes: 384
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;


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

  int A,B; cin >> A>>B;
  
  int ans=-1;
  if (A<10 && B<10) ans = A*B;
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;

void main() {
	auto input = getStdin!(string[])()[0];
	int[] num = input.split(" ").to!(int[]);
	auto result = num.sort.to!(string[]);
	result.join(" ").writeln;
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

Measured memory_bytes: 2496
#include <iostream>
#include <string>
int main(){
    std::string a,b,c;
    std::cin>>a>>b>>c;
    if(*--a.end()==*b.begin()&&*--b.end()==*c.begin()) std::cout<<"YES";
    else std::cout<<"NO";
    std::cout<<std::endl;
}

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

using namespace std;

class HASH {
    int mod, base;
    vector<int> p = {1} , hashes;

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

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

public:
    HASH(int _mod , int _base) : mod(_mod), base(_base) {}

    void push_back(int x) {
        int h = hashes.size() ? hashes.back() : 0;
        hashes.push_back(add(mul(h , base) , x));
        p.push_back(mul(p.back() , base));
    }

    int get(int l , int r) {
        assert(l <= r && r < hashes.size());
        if (!l) return hashes[r];
        return add(hashes[r] , -mul(p[r - l + 1] , hashes[l - 1]));
    }
};

struct D_HASH {
    const int B1 = 256;
    const int B2 = 128;
    const int MOD1 = 2000000011;
    const int MOD2 = 1000000007;

    array<HASH , 2> h;
    D_HASH() : h{HASH(MOD1 , B1) , HASH(MOD2 , B2)} {}
    
    void push_back(int x) {
        h[0].push_back(x);
        h[1].push_back(x);
    }

    array<int , 2> get(int l , int r) {
        assert(l <= r);
        return {h[0].get(l , r) , h[1].get(l , r)};
    };
};


int n;
bool good(int len , D_HASH &dh) {
    map<array<int , 2> , int> exist;
    vector<array<int , 2> > v(n);

    for (int i = 0 ;i + len - 1 < n ;i++)
        v[i] = dh.get(i , i + len - 1);

    for (int i = len ;i + len - 1 < n ;i++)
        exist[v[i]]++;

    if (exist[v[0]])
        return 1;

    int r = len;
    while (r < n) {
        exist[v[r]]--;
        if (exist[v[r - len + 1]])
            return 1;
        r++;
    }

    return 0;
}

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
   
    string s;
    cin >> n >> s;

    D_HASH dh;
    for (char &c : s)
        dh.push_back(c);

    int l = 1 , r = n , ans = 0;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (good(mid , dh)) {
            ans = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }

    cout << ans;
}


Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
int main()

{
    int t,d,s,i;
    cin>>t>>d;
    s=(d*2)+1;
    i=t/s;
    if(t%s!=0)
        cout<<++i<<endl;
    else
        cout<<i<<endl;



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000000000
#define INF 1000000
#define M 1000000007
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std; 
int main(){
    fast_io
    ll n;
    cin>>n;
    ll a[n];
    ll sum = 0;
    map<ll,ll> mp;
    for(ll i = 0;i<n;i++){
        cin>>a[i];
        sum += a[i];
        mp[a[i]]++;
    }
    ll q;
    cin>>q;
    while(q--){
        ll x,y;
        cin>>x>>y;
        ll r = mp[x];
        ll o = x*r;
        sum = sum-o;
        sum += y*r;
        mp[y] += mp[x];
        mp[x] = 0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 10232
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

if get_nsp.sort.join("")=="abc"
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
use std::io::*;
use std::str::*;
use std::collections::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

fn check(s: &Vec<char>, t: &Vec<char>) -> bool {
    let mut mp: HashMap<char, char> = HashMap::new();
    s.iter().zip(t.iter()).all(|(&a, &b)| {
        let fa = mp.entry(a).or_insert(b);
        *fa == b
    })
}

fn main() {
    loop {
        let s: Vec<char> = read::<String>().chars().collect();
        let t: Vec<char> = read::<String>().chars().collect();
        println!("{}", if check(&s, &t) && check(&t, &s) { "Yes" } else { "No" });
    }
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
struct point
{
	ll x;
	ll y;
}p[N];
bool cmp(point a,point b)
{
	return atan2(a.y,a.x)<atan2(b.y,b.x);
}
int main()
{
	int n;	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&p[i].x,&p[i].y);
	int nx[N];
	for(int i=1;i<=n;i++)
		nx[i]=i+1; nx[n]=1;
	sort(p+1,p+1+n,cmp);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll x=p[i].x;
		ll y=p[i].y;
		ans=max(ans,x*x+y*y);
		for(int j=nx[i];j!=i;j=nx[j])
		{
			x=x+p[j].x;
			y=y+p[j].y;
			ans=max(ans,x*x+y*y);
		} 
	}
	printf("%.10lf\n",sqrt(ans));
	return 0;
} 

Measured memory_bytes: 256