akhauriyash/Code-Regression huggingface dataset:
# AOJ ITP2_1_B: Deque
# Python3 2018.6.24 bal4u

from collections import deque
Q = deque()
q = int(input())
for i in range(q):
	a = input()
	if   a[0] == '0': # pushBack
		if a[2] == '0': Q.appendleft(a[4:])
		else          : Q.append(a[4:])
	elif a[0] == '1': print(Q[int(a[2:])]) # randomAccess
	else: # popBack
		if a[2] == '0': Q.popleft()
		else:           Q.pop()


Measured memory_bytes: 34648
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9;

int main()
{
    ll s;
    ll x2,y2,x3,y3;
    cin>>s;
    if(s>mod)
    {
        if(s/mod==mod)
        {  
            x2=mod;
            y2=0;
            x3=0;
            y3=mod;

        }
        else
        {
            ll q=s/mod;
            ll r=s%mod;
            x2=mod;
            y2=1;
            x3=mod-r;
            y3=q+1;
            
        }
        
        

    }
    else
    {
        x2=s;
        y2=0;
        x3=0;
        y3=1;
    }
    
    


     cout<<0<<" "<<0<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;

int arr[1000000];
ll mod = 1000000007;
int main ()
{
   int n;cin >>n;int cnt  =0;
   set<int>s;
   for(int i=0;i<n;i++){
    cin >>arr[i];
    s.insert(arr[i]);
    auto it = s.begin();
    if(arr[i]==*it){
        cnt++;
    }
   }

   cout<<cnt<<endl;
    return 0;

}


Measured memory_bytes: 10368
N, x = map(int, input().split())
*A, = map(int, input().split())
MAX = 10**18
B = [MAX]*N
ans = MAX
for k in range(N):
    for i in range(N):
        B[i] = min(B[i], A[(i-k) % N])
    ans = min(ans, k*x + sum(B))
print(ans)

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

using namespace std;

const long long int MOD = 1000000007;

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

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

	cin >> N >> K;
	while (N <= K) {
		N *= 2;
		M++;
	}
	cout << M << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  cin>>x;
  int ans=0;
  REP(i,1,1000){
    REP(j,2,1000){
      int a=pow(i,j);
      if(x<a){
        break;
      }
      if(x-ans>x-a){
        ans=a;
      }
    }
  }
  cout<<ans<<'\n';
  return(0);
}


Measured memory_bytes: 256
MOD = 10**9 + 7
inpl = lambda: list(map(int,input().split()))
def inv_mod(a, p=10**9+7):
    p = abs(p)
    a %= p
    stack = []
    p0 = p
    while a > 1:
        d, a, p = p//a, p%a, a
        stack.append(d)
    x, y = 1, 0
    while stack:
        d = stack.pop()
        x, y = y-d*x, x
    return x % p0
n, k = inpl()
if k >= n:
    k = n-1
ans = 1
t = 1
for i in range(k):
    t *= (n-1-i)*(n-i)
    t %= MOD
    j = inv_mod(i+1)
    t *= j*j % MOD
    ans += t
    ans %= MOD
print(ans)

Measured memory_bytes: 42092
/*
    ->->->->-> Vora Mahammasasim <-<-<-<-<-
*/
#include<bits/stdc++.h>
#define Quick std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define MOD 1e7+7;
using namespace std;





void solve(){

    string s,t;
    cin>>s>>t;
    int ans = 1e18;
    int n = s.size(),m = t.size();
    for(int i=0;i<=(n-m);i++){
        int cnt = 0,k = 0;
        for(int j=i;j<m+i;j++){
            if(s[j] != t[k]){
                cnt++;
            }
            k++;
        }
        ans =min(ans,cnt);
    }
    cout<<ans;

}

signed main(){

    Quick;
    int tt=1;
    //cin>>tt;
    for(int cas=1;cas<=tt;cas++){

        solve();

    }
    
    return 0;
}


Measured memory_bytes: 3656
N=int(input())
S=input()

indexs=[[] for i in range(10)]
for i in range(N):
  indexs[int(S[i])].append(i)
  
counter=0
for i in range(0, 1000):
  a=i//100
  b=(i%100)//10
  c=i%10
  
  if len(indexs[a])>0 and len(indexs[b])>0 and len(indexs[c])>0:
    x=min(indexs[a])
    z=max(indexs[c])
    n=len(indexs[b])
    j=0
    for i in range(n):
      if indexs[b][i]>x and indexs[b][i]<z:
        j=1
    counter+=j
  
print(counter)

Measured memory_bytes: 4328
#include <iostream>
#include <cassert>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <fstream>
#include <map>

#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define x first
#define y second

using namespace std;

const int INF = int(2e9) + 7;
const int N = int(1e5) + 11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a >= 10 || b >= 10) {
        cout << -1;
        return 0;
    }
    cout << a * b;
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    path = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, readline().rstrip().split())
        path[a-1].append(b-1)
        path[b-1].append(a-1)
    for p in path[0]:
        if N-1 in path[p]:
            print('POSSIBLE')
            return

    print('IMPOSSIBLE')
    return 
    

if __name__ == '__main__':
    main()

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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

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

int C[2010][2010];

signed main(){
    C[0][0] = C[1][0] = C[1][1] = 1;
    FOR( i, 2, 2010 ){
        REP( j, i + 1 ){
            C[i][j] = C[i - 1][j];
            if( j - 1 >= 0 ) C[i][j] += C[i - 1][j - 1];
            C[i][j] %= MOD;
        }
    }

    int N, K; cin >> N >> K;
    REP( i, K ){
        cout << C[N - K + 1][i + 1] * C[K - 1][i] % MOD << endl;
    }

}



Measured memory_bytes: 30336
from itertools import accumulate
S = input()
ans = [0]*len(S)
RLgr = []
R = 0
L = 0
RL = "R"
for i in range(len(S)):
    if S[i] == RL:
        if S[i] == "R":
            R += 1
        else:
            L += 1
    else:
        if RL == "R":
            RLgr.append(R)
            R = 0
            RL = "L"
            L+=1
        else:
            RLgr.append(L)
            L = 0
            RL = "R"
            R+=1
RLgr.append(L)
RLsum = list(accumulate(RLgr))
for i in range(0,len(RLgr)-1,+2):
    a=RLgr[i]//2
    b=RLgr[i+1]//2
    ans[RLsum[i]-1]=b+RLgr[i]-a
    ans[RLsum[i]]=a+RLgr[i+1]-b

for i in ans:
    print(i,end=" ")


Measured memory_bytes: 14704
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 * Integer.valueOf(char)はダメ、(String)
 */

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
 
    	int N = sc.nextInt();
    	if(N <= 999) System.out.println("ABC");
    	else System.out.println("ABD");;
	}
}

Measured memory_bytes: 21076
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, a, b = map(int, input().split())
s = input().strip()

_pass = 0
_pass_foreign = 0
for i, v in enumerate(s):
    if _pass == a + b:
        print('No')
        continue
    if v == 'c':
        print('No')
    if v == 'a':
        print('Yes')
        _pass += 1
    if v == 'b':
        if _pass_foreign < b:
            print('Yes')
            _pass += 1
            _pass_foreign += 1
        else:
            print('No')


Measured memory_bytes: 52312
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;cin>>k>>n;
  vector<int >nos(n,0);
  for(int i=0;i<n;i++)cin>>nos[i];
  int maxi = abs(nos[n-1]-k)+nos[0];
  for(int i=0;i<n-1;i++){
  	maxi = max(maxi,abs(nos[i]-nos[i+1]));
  }
  cout<<k-maxi;
}

Measured memory_bytes: 4028
//BISMILLAHIRRAHMANIRRAHIM....*/
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<cassert>
#include<sstream>
#include<queue>
#include<stack>
#include<iostream>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long
#define pb push_back
#define MP make_pair
#define vsort(v) sort(v.begin(),v.end())
#define NL printf("\n")
#define mod 1000000009
#define P(n) printf("%d",n)
#define xx first
#define yy second
#define bit(n) __builtin_popcount(n)
#define sc(a) scanf("%d",&a)
#include <set>
#include<map>
using namespace std;

// freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
/*int fx[] = {1,-1,0,0};
int fy[] = {0,0,1,-1};

int month[]= {31,28,31,30,31,30,31,31,30,31,30,31};
string day[]= {"Monday", "Tuesday", "Wednesday","Thursday","Friday", "Saturday", "Sunday"};
*/
 int ans = 1;
 void solve(int i, int j,int n){
        cout << "X";
       if(i==1 && j==1) return ;
       if(i==n && j==1) return ;
       if(i==n && j==n) return ;
       if(i==1 && j==n) return ;

       solve(i-1,j-1,n);
       solve(i-1,j+1,n);
       solve(i+1,j-1,n);
       solve(i+1,j+1,n);

       cout << endl;

     return ;
 }
 int solve2(int n){
    int o=0;
    if(n==0) return 1;
    while(n>0){
        if(n%10==0) o++;
        n/=10;
    }
    return o;
 }
 void sol(char c){
     char d=c+1;
  cout << d << endl;
  return ;
 }
 int main()
{
   //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

  //   sieve();

       int n,b,t,k,m;

     //  solve(n,n,n);
     int ans = 0,sum = 0;
     cin >> n >> m;
     int ac = 0;
     string ver;
     bool res[n+10];
     int pena[n+10];
     int p;
     memset(pena,0,sizeof pena);
     memset(res,0,sizeof res);
     for(int i = 1;  i<=m; i++){
        cin >> p >> ver;
        if(res[p]) continue;
        if(ver=="AC") res[p] = 1;
        else{
            pena[p]++;
        }
     }
  int pen = 0;
     for(int i = 1; i<=n; i++) if(res[i]==1){ ac++;
      pen+=pena[i];
     }

     cout << ac << " " << pen << endl;

     /*while(t--){
        cin >> a >> b;
     ans = 0;
     for(int i = a; i<=b; i++){
         ans +=solve2(i);
     }
     cout << ans << endl;
    }

    */


return 0;
}


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

int main(){
	int mheight=0;
	int mbest[4]={0,0,0,0};
	int j=0;
	for(j=0;j<10;j++){
		char str[256];
		char a=' ';
		fgets(str,256,stdin);
		sscanf(str," %d",&mheight);

		int ccount=0;
		if (mbest[3]<mheight){
			mbest[3]=mheight;
			do{
				ccount=0;
				int i=0;
				for(i=0;i<3;i++){
					if(mbest[i]<mbest[i+1]){
						mbest[i]+=mbest[i+1];//A=A+B
						mbest[i+1]=mbest[i]-mbest[i+1];//B=(A+B)-B=A
						mbest[i]-=mbest[i+1];//A=A+B-A=B
						ccount=1;
					}
				}
			}while(ccount!=0);
		}
	}
	int i=0;
	for(;i<3;i++){
		printf("%d\n",mbest[i]);
	}
	
	return 0;
}

Measured memory_bytes: 612
while True:
    x = input()
    if x== '0' :
        break
    m=0
    n=1
    a=0
    b=0
    if x[0]=='B':
        (n,m)=(m,n)
    for i in range(len(x)-1):
        if x[i] == x[i+1] :
            a += n
            b += m
        else :
            (n,m) = (m,n)
            a += n
            b += m
    if a>b : a+=1
    else : b+=1
    print(a,b)


Measured memory_bytes: 5560
def nextpt(ratio1, ratio2, pt):
  if ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]>0:
    pt[0]=pt[0]+((-1)*pt[0])%ratio2[0]
    pt[1]=pt[0]*ratio2[1]//ratio2[0]
  else:
    pt[1]=pt[1]+((-1)*pt[1])%ratio2[1]
    pt[0]=pt[1]*ratio2[0]//ratio2[1]
  return pt

n=int(input())
ratios = [list(map(int,input().split())) for _ in range(n)]

pt=ratios[0]
for i in range(n-1):
  pt=nextpt(ratios[i], ratios[i+1], pt)

print(sum(pt))

Measured memory_bytes: 9320
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> book(n);

    string s;
    int p;
    rep(i, n) {
        cin >> s >> p;
        p *= -1;
        book[i].first = make_pair(s, p);
        book[i].second = i+1;
    }
    sort(book.begin(), book.end());

    rep(i, n) {
        cout << book[i].second << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;
// ||

int main() {
  ll n, a, b; cin >> n >> a >> b;
  vll v(n); REP(i, n) cin >> v[i];
  sort(v.begin(), v.end(), greater<ll>());
  double ans = 0;
  REP(i, a) ans += (double)v[i];
  cout << fixed << setprecision(8) << ans / (double)a << endl;
  if (v[0] != v[a-1]) {
    ll nn=1, nk=1;
    for (ll i=a-2; i>=0; i--) {
      if (v[a-1] == v[i]) {nn++; nk++;}
      else break;
    }
    for (ll i=a; i<n; i++) {
      if (v[a-1] == v[i]) nn++;
      else break;
    }
    ll ans = 1; // nnCnk
    REP(i, nk) ans = ans * (nn-i) / (i+1);
    cout << ans << endl;
  } else {
    ll nn=a;
    for (ll i=a; i<n; i++) {
      if (v[a-1] == v[i]) nn++;
      else break;
    }
    ll ans = 0;
    for (ll nk=a; nk<=b; nk++) {
      if (nk > nn) break;
      ll tmp=1;
      REP(j, nk) tmp = tmp * (nn-j) / (j+1);
      ans += tmp;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

int main(){
	int n; cin >> n;
	VI l(n), r(n);
	int x, y;
	REP(i,n){
		cin >> x >> y;
		l[i]=x+y;
		r[i]=x-y;
	}
	sort(ALL(l));
	sort(ALL(r));
	int ans=max(l[n-1]-l[0],r[n-1]-r[0]);
	cout << ans << endl;
	return 0;
}

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

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

  int L = A + B;
  int R = C + D;
  
  if (L == R)
  {
    cout << "Balanced" << endl;
  }
  else if (L > R)
  {
    cout << "Left" << endl;
  }
  else
  {
    cout << "Right" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from bisect import *

n, k = map(int, input().split())
candles = list(map(int, input().split()))
i0 = bisect_right(candles, 0)
MIN = float("inf")
if i0 - k >= 0:
    MIN = -candles[i0 - k]
i_start = max(0, i0 - k + 1)
if 0 in candles:
    i0 -= 1
if i0 + k - 1 <= n - 1:
    MIN = min(MIN, candles[i0 + k - 1])
i_end = min(i0, n - k + 1)
for i in range(i_start, i_end):
    L=-candles[i]
    R=candles[i+k-1]
    temp=L+R+min(L,R)
    if temp<MIN:
        MIN=temp
print(MIN)


Measured memory_bytes: 14452
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
//		int n=sc.nextInt(),a[]=sc.nxtArr(n);
//		long sum=0;
//		for(int x:a)
//			sum+=x;
//		long ans=0;
//		int MOD=(int)1e9+7;
//		for(int x:a) {
//			sum-=x;
//			ans+=x*1L*sum%MOD;
//			ans%=MOD;
//		}
//		System.out.println(ans);
		int n = sc.nextInt(), m = sc.nextInt();
		;
		DSU dsu = new DSU(n);
		while (m-- > 0)
			dsu.union(sc.nextInt() - 1, sc.nextInt() - 1);
		int[] ans = new int[n];
		for (int i = 0; i < n; i++)
			ans[dsu.findSet(i)]++;
		int max = 0;
		for (int x : ans)
			max = Math.max(max, x);
		System.out.println(max);
		out.close();

	}

	static class DSU {
		int[] p, r;

		DSU(int n) {
			p = new int[n];
			r = new int[n];
			for (int i = 0; i < n; i++)
				p[i] = i;
		}

		boolean union(int x, int y) {
			x = findSet(x);
			y = findSet(y);
			if (x == y)
				return false;
			if (r[x] > r[y]) {
				p[y] = x;
			} else {
				p[x] = y;
				if (r[x] == r[y])
					r[y]++;
			}
			return true;

		}

		int findSet(int x) {
			if (p[x] == x)
				return x;
			else
				return p[x] = findSet(p[x]);
		}
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

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

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

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

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

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready() || st.hasMoreTokens();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 57664
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	auto S = rs;
	ulong tmp;
	foreach(i; 0..N-1) if(S[i] == S[i+1]) tmp++;
	min(tmp + 2 * K, N - 1).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2428
//abc117_d.cpp
//Thu Feb 7 21:48:59 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n;
	ll k;
	cin >> n >> k;

	ll a[n];
//	ll keta[60];
//	fill(keta,keta+60,0LL);
	for (int i=0;i<n;i++){
		cin >> a[i];
//		for (int j=0;j<60;j++){
//			ll mask = 1LL<<j;
//			if (a[i]&mask){
//				keta[j]++;
//			}
//		}
	}

	ll largest = 0;
//	for (int j=0;j<60;j++){
//		largest += (1LL<<j)*keta[j];
//	}

//	for (int j=0;j<60;j++){
//		ll temp = 0LL;
//		if (k&1LL<<j){
//			temp += (1LL<<j)*(n-keta[j]);
//		}else {
//			temp += (1LL<<j)*keta[j];
//		}
//		largest = max(largest,temp);
//	}

	for (int i=-1;i<60;i++){
		if (i==-1 || k&(1LL<<i)){
			ll temp = 0LL;
			for (int j=0;j<60;j++){
				ll num = 0;
				for (int l=0;l<n;l++){
					if (a[l]&(1LL<<j)){
						num++;
					}
				}
				if (j<i){
					temp += (1LL<<j)*max(num,n-num);
				}else if (j==i){
					temp += (1LL<<i)*num;
				}else if (j>i){
					if (k&(1LL<<j)){
						temp += (1LL<<j)*(n-num);
					}else {
						temp += (1LL<<j)*num;
					}
				}
			}
			largest = max(temp,largest);
		}
	}

	cout << largest << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1024
import math
n = int(input())

ans = 0
if n < 105:
    print(0)
else:
    for i in range(105, n +1, 2):
        div = []
        for j in range(1, int(math.sqrt(i**2) + 1)):
            if i % j == 0:
                div.append(j)
                if j != i // j:
                    div.append(i //j)
        if len(div) // 2 == 8:
            ans += 1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n, w;
	cin >> n >> w;
	int wt[n], v[n];
	for (int i = 0; i < n; i++)
	{
		cin >> wt[i];
		cin >> v[i];
	}
	long long k[n + 1][w + 1];
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= w; j++)
		{
			if (i == 0 || j == 0)
				k[i][j] = 0;
			else if (wt[i - 1] <= j)
			{
				k[i][j] = max(v[i - 1] + k[i - 1][j - wt[i - 1]], k[i - 1][j]);
			}
			else
				k[i][j] = k[i - 1][j];
		}

	cout << k[n][w] << endl;
	return 0;
}




Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

map<ll,ll> ans;

//素因数分解
template <class T>
void prime_factor(T x){
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]++;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    FOR(i,1,n+1){
        prime_factor(i);
    }
    ll cnt=1;
    for(auto itr:ans){
        //cout<<itr.first<<' '<<itr.second<<'\n';
        cnt*=(itr.second+1)%mod;
        cnt%=mod;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
N=int(input())
a=[int(i) for i in input().split()]

def f(A):
  P=[0]*N
  S=[(-1,0)]
  for i,b in enumerate(A):
    while S[-1][1]>b:
      S.pop()
    P[b-1]=i-S[-1][0]
    S.append((i,b))
  return P
P=f(a)
Q=f(a[::-1])
ans=0
for i in range(N):
  ans+=(i+1)*P[i]*Q[i]
print(ans)
  
  
  

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  ll k; 
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) --a[i];
  vector<vector<int>> table(70, vector<int>(n));
  rep(i, n) table[0][i] = a[i];
  for(int d = 1; d < 70; ++d) {
    rep(i, n) table[d][i] = table[d-1][table[d-1][i]];
  }
  int d = 62;
  int now = 0;
  while(k > 0) {
    if(k >= 1ll<<d) {
      k -= 1ll<<d;
      now = table[d][now];
    }
    --d;
  }
  cout << now+1 << endl;
}


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

using namespace std;
int v[1000000];

int main() {
/*	vector<int> v;
	v.push_back(0);*/
	int n;
	cin>>n;
	/*while(n--){
		int a;
		cin>>a;
		v.push_back(a);
	}*/
	
	for(int i = 1; i <=n;i++){
		cin>>v[i];
		
	}
	int i = 1;
	int a = 0;
	
	while(1){
		if(v[i] == 2){
			cout<<a+1;
			return 0;
		}	
		
		if(v[i] == -1){
			cout<<-1;
			return 0;
		}
		
		int t = v[i];
		v[i] = -1;
		i = t;
		a+=1;
	}

	return 0;
}

Measured memory_bytes: 768
# tenka1-2017-beginnerB - Different Distribution
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = sorted(tuple(map(int, input().rstrip().split())) for _ in range(n))
    print(A[-1][0] + A[-1][1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 16992
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    vector<int> tmp(n, 0);
    int ans = 0;
    rep(i, 0, n){
        tmp[i] = c.end() - upper_bound(all(c), b[i]);
    }
    repb(i, n - 2, 0){
        tmp[i] += tmp[i + 1];
    }
    rep(i, 0, n){
        int id = upper_bound(all(b), a[i]) - b.begin();
        if(id < n) ans += tmp[id];
    }
    cout << ans << endl;
}

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


int main(){
  int N;
  string S;
  cin >> N >> S;
  
  int l = N/2;
  vector<char> s1(l);
  vector<char> s2(l);

  if(N % 2 == 0){
    for(int i = 0;i<l;i++){
      s1[i] = S[i];
    }
    for(int i = l;i<N;i++){
      s2[i-l] = S[i];
    }
  }
  
  if(s1 == s2 && N%2 == 0) cout << "Yes" << endl;
  if(s1 != s2 || N%2 != 0) cout << "No" << endl;

  
 }

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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n, m;
    cin >> n >> m;
    cout << (n+m)/2 << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <map>
#include <vector>

int main(void){
	int n, m;
	std::map<char, char> table;

	while(1){
		std::vector<char> data;
		std::cin >> n;
		if(n == 0)	return 0;

		for(char i='0'; i <= 'z'; i++){
			table[i] = '\0';
		}

		for(int i=0; i < n; i++){
			char before, after;
			std::cin >> before >> after;
			table[before] = after;
		}

		std::cin >> m;
		for(int i=0; i < m; i++){
			char temp;
			std::cin >> temp;
			data.push_back(temp);
		}

		for(int i=0; i < m; i++){
			if(table[data[i]] != '\0'){
				data[i] = table[data[i]];
			}
		}

		for(int i=0; i < m; i++){
			std::cout << data[i];
		}
		std::cout << std::endl;
	}
}

Measured memory_bytes: 1340
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

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

    int aa = a + a - 1;
    int bb = b + b - 1;
    int ab = a + b;
    int sum = max(aa, max(bb, ab));

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    ans=(N//K)**3
    if K%2==0:
        ans+=((N+K//2)//K)**3
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
N, K = map(int,input().split())
count = 0
A = list()
for _ in range(K):
  d = int(input())
  a = list(map(int,input().split()))
  A.append(a)
sum_A = sum(A,[])
for i in range(1,N+1):
  if (i in sum_A) == False:
    count = count + 1
print(count)
  

Measured memory_bytes: 9124
unittest
{
	assert( [ "3 4", "aabb", "aabb", "aacc" ].parse.expand.solve == "Yes" );
	assert( [ "2 2", "aa", "bb" ].parse.expand.solve == "No" );
	assert( [ "5 1", "t", "w", "e", "e", "t" ].parse.expand.solve == "Yes" );
	assert( [ "2 5", "abxba", "abyba" ].parse.expand.solve == "No" );
	assert( [ "1 1", "z" ].parse.expand.solve == "Yes" );
}



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

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	auto ass = new dchar[][]( hw[ 0 ], hw[ 1 ] );
	foreach( ref as; ass )
	{
		input.popFront;
		as = input.front.to!( dchar[] );
	}
	return tuple( hw[ 0 ], hw[ 1 ], ass );
}

auto solve( long h, long w, dchar[][] ass )
{
	// 同じ文字の必要数を計算
	auto ns = [ 4:0L, 2:0L, 1:0L ];
	ns[ 4 ] += ( h / 2 ) * ( w / 2 );
	if( h % 2 == 1 ) ns[ 2 ] += ( h % 2 ) * ( w / 2 );
	if( w % 2 == 1 ) ns[ 2 ] += ( h / 2 ) * ( w % 2 );
	if( h % 2 == 1 && w % 2 == 1 ) ns[ 1 ] += 1;
	
	// 文字ごとに4,2,1単位で集計
	auto cs = [ 4:0L, 2:0L, 1:0L ];
	foreach( g; ass.join.sort().group )
	{
		auto c = g[ 1 ];
		for( auto k = 4; 0 < k; k /= 2 )
		{
			cs[ k ] += c / k;
			c %= k;
		}
	}
	
	// 必要数と一致するか判定
	for( auto k = 4; 0 < k; k /= 2 )
	{
		if( cs[ k ] < ns[ k ] ) return "No";
		cs[ k / 2 ] += ( cs[ k ] - ns[ k ] ) * 2;		// 余った分は小さい単位に分解して繰り越し
	}
	return "Yes";
}


Measured memory_bytes: 508
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int R[200][200][200], D[200][200][200];
int TR[200][200][200], TD[200][200][200];
char p[200][200];
int n, m;
int main() {
	int i, j, k;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) {
		scanf("%s", p[i] + 1);
	}
	for (i = 1; i <= m; i++) {
		for (j = 1; j <= n; j++) {
			int ck2 = 0, ck1 = 0;
			for (k = j; k <= n; k++) {
				if (k != j && p[k][i] != p[j][i])ck2 = 1;
				if (p[k][i] != p[k][i - 1])ck1 = 1;
				if (ck2)R[j][k][i] = 0;
				else if (ck1)R[j][k][i] = 1;
				else R[j][k][i] = R[j][k][i - 1] + 1;
			}
		}
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			int ck2 = 0, ck1 = 0;
			for (k = j; k <= m; k++) {
				if (k != j && p[i][k] != p[i][j])ck2 = 1;
				if (p[i][k] != p[i - 1][k])ck1 = 1;
				if (ck2)D[j][k][i] = 0;
				else if (ck1)D[j][k][i] = 1;
				else D[j][k][i] = D[j][k][i - 1] + 1;
			}
		}
	}
	for (int ii = 0;; ii++) {
		if (R[1][n][m] == m) {
			printf("%d\n", ii);
			return 0;
		}
		for (i = 1; i <= n; i++)for (j = 1; j <= n; j++)for (k = 1; k <= m; k++)TR[i][j][k] = R[i][j][k], R[i][j][k] = 0;
		for (i = 1; i <= m; i++)for (j = 1; j <= m; j++)for (k = 1; k <= n; k++)TD[i][j][k] = D[i][j][k], D[i][j][k] = 0;
		for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) for (k = 1; k <= m; k++) {
			int t = TR[i][j][k] + TR[i][j][k - TR[i][j][k]];
			if (t > 0) {
				R[i][j][k] = t;
				D[k - t + 1][k][j] = max(D[k - t + 1][k][j], j - i + 1);
			}
		}
		for (i = 1; i <= m; i++) for (j = 1; j <= m; j++) for (k = 1; k <= n; k++) {
			int t = TD[i][j][k] + TD[i][j][k - TD[i][j][k]];
			D[i][j][k] = max(D[i][j][k], t);
			t = D[i][j][k];
			if (t > 0) {
				R[k - t + 1][k][j] = max(R[k - t + 1][k][j], j - i + 1);
			}
		}
		for (i = m - 1; i >= 1; i--)for (j = n; j >= 1; j--)for (k = 1; k <= n - j + 1; k++)R[k][k + j - 1][i] = max(R[k][k + j - 1][i], max(R[k][k + j - 1][i + 1] - 1, max(R[k][k + j][i], R[k - 1][k + j - 1][i])));
		for (i = n - 1; i >= 1; i--)for (j = m; j >= 1; j--)for (k = 1; k <= m - j + 1; k++)D[k][k + j - 1][i] = max(D[k][k + j - 1][i], max(D[k][k + j - 1][i + 1] - 1, max(D[k][k + j][i], D[k - 1][k + j - 1][i])));
	}
}

Measured memory_bytes: 122752
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define mod 1000000007
#define pb push_back
#define po pop_back
#define f(i,x,n) for(ll i=x; i<n; i++)
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)),x.resize(distance(x.begin(),unique(all(x))))
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;

ll GCD(ll a, ll b)
{
    if(b==0) return a;
    return GCD(b,a%b);
}
ll LCM(ll a, ll b)
{
    return (a*b)/GCD(a,b);
}
void solve()
{
    ll a,b;
    cin>>a>>b;
    ll res = LCM(a,b);
    cout<<res;
}
int main()
{
// fast();
// #ifndef ONLINE_JUDGE
//             freopen("input.txt", "r", stdin);
//             freopen("output.txt","w",stdout);
// #endif
//     int t;
//     cin>>t;
//     while(t--)
//     {
         solve();
//     }
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}



int main()
{
	int a, b, cnt = 1, ans = 0;
	string s, t;

	cin >> a >> b;

	while (cnt < b) {
		cnt += a - 1;
		ans++;
	}
	
	cout << ans << endl;

	return 0;

}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >> X ;
	int flag=0;
	N=100;
	while(N<X){
	    N=N+N/100;
	    flag++;
	}
	std::cout << flag << std::endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << std::min(a,b) + std::min(c,d) << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n;
pii a[100010];

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n;
    Forn(i, n)
    {
        int x;
        cin >> x;
        a[i] = mp(x, i);
    }
    sort(a+1, a+n+1);
    Forn(i, n)
    {
        cout << a[i].S << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

//142 C
int main(void) {
	ll n;
	cin >> n;
	vector<ll> ans = vector<ll>(n);
	rep(i, 1, n+1) {
		ll a;
		cin >> a;
		ans[a - 1] = i;
	}
	rep(i, 0, n) {
		cout << ans[i];
		if (i != n - 1) cout << " ";
		else cout << endl;
	}
}

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

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

Measured memory_bytes: 256
import java.util.*;

public  class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		HashMap<String, Long> map = new HashMap<String, Long>();
		map.put("M", (long) 0);
		map.put("A", (long) 0);
		map.put("R", (long) 0);
		map.put("C", (long) 0);
		map.put("H", (long) 0);
		for (int i = 0; i < count; i++) {
			String initial = sc.next().split("")[0];

			if (initial.equals("M") || initial.equals("A") || initial.equals("R") || initial.equals("C") || initial.equals("H")) {
				long value = map.get(initial);
				map.put(initial, value + 1);
			}
		}

		long result = 0;
		result += map.get("M") * map.get("A") * map.get("R");
		result += map.get("M") * map.get("A") * map.get("C");
		result += map.get("M") * map.get("A") * map.get("H");
		result += map.get("M") * map.get("R") * map.get("C");
		result += map.get("M") * map.get("R") * map.get("H");
		result += map.get("M") * map.get("C") * map.get("H");
		result += map.get("A") * map.get("R") * map.get("C");
		result += map.get("A") * map.get("R") * map.get("H");
		result += map.get("A") * map.get("C") * map.get("H");
		result += map.get("R") * map.get("C") * map.get("H");
		
		System.out.println(result);
	}
}

Measured memory_bytes: 62748
a=[[0]*3 for _ in range(3)]
for i in range(3):
    a[i]= list(map(int, input().split()))
n = int(input())
b = [int(input()) for i in range(n)]

bingo=[[False]*3 for _ in range(3)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                bingo[j][k]=True
flag=False
for i in range(3):
    if all([bingo[i][0], bingo[i][1], bingo[i][2]]):
        flag=True

for i in range(3):
    if all([bingo[0][i],bingo[1][i],bingo[2][i]]):
        flag=True

if all([bingo[0][0],bingo[1][1],bingo[2][2]]):
        flag=True

if all([bingo[0][2],bingo[1][1],bingo[2][0]]):
    flag=True

if flag:
    print('Yes')
else:
    print('No')

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

using namespace std;

constexpr char nl = '\n';

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

  int N;
  cin >> N;
  set<string> S;

  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    S.insert(s);
  }

  cout << S.size() << nl;
}


Measured memory_bytes: 19268
n = int(input())
s = 'abcdefghij'

def ans(a, c):
    if len(a)==n-1:
        for i in range(c):
            print(a+s[i])
    else:
        for i in range(c):
            a+=s[i]
            if i==c-1:
                ans(a, c+1)
            else:
                ans(a,c)
            a=a[0:-1]

ans('', 1)

Measured memory_bytes: 4340
#include <iostream>
#include <algorithm>
using namespace std;
const int oo = 1e6;
int n, k;
int arr[100007];

int main() {
char arr[19];
cin >> arr;
for(int i = 0; i < 19; i++){
  if(arr[i] == ','){
    arr[i] = ' ';
  }
}
cout << arr << endl;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
map<char,int> 
count_same_elements(const vector<char>& v){map<char,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T,class U>
void msg_with_compare(T A,T B,U A_greater_B,U A_eq_B,U A_less_B){
    if(A==B){cout<<A_eq_B<<"\n";}else if(A>B){cout<<A_greater_B<<"\n";}else{cout<<A_less_B<<"\n";}}
template<class B,class T>
void msg_with_boolean(B A,T true_msg,T false_msg){cout<< ( A? true_msg:false_msg);}
template<class B,class T>
void msg_with_boolean(B A1,B A2,T both_true_msg,T true_false_msg,T false_true_msg,T both_false_msg){
    if(A1){if(A2){cout<<both_true_msg;}else{cout<<true_false_msg;}
    }else{if(A2){cout<<false_true_msg;}else{cout<<both_false_msg;}}
}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}

ll n,x;
vector<ll> m;
void input(){
    cin>>n>>x;
    scan_vector(n,m);
}
void src(){
    cout<<n+(x-accumulate(m.begin(),m.end(),0ll))/(*min_element(m.begin(),m.end()));
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

char B;

int main() {
    cin >> B;
    if (B == 'A') {
        cout << 'T' << endl;
    } else if (B == 'T') {
        cout << 'A' << endl;
    } else if (B =='C') {
        cout << 'G' << endl;
    } else {
        cout << 'C' << endl;
    }

    return 0;
}

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

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

    transform (a.begin (), a.end (), a.begin (), ::toupper);
    transform (b.begin (), b.end (), b.begin (), ::toupper);
    transform (c.begin (), c.end (), c.begin (), ::toupper);

    cout << a.substr(0,1) << b.substr(0,1) << c.substr(0,1) << endl;
}

Measured memory_bytes: 256
/*
❤️❤️❤️I_love_QMsh❤️❤️❤️
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define x first
#define y second

using namespace std;
using namespace __gnu_pbds; // gp_hash_table<int, int> table;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // <int> .find_by_order(int) .order_of_key(int)

template<typename T> bool smin(T &a, const T &b) { bool ret = b < a; return a = (ret ? b : a), ret; }
template<typename T> bool smax(T &a, const T &b) { bool ret = a < b; return a = (ret ? b : a), ret; }

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

mt19937 rnd;

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) {
    cin >> i;
  }
  int mn = *min_element(all(a));
  int mx = *max_element(all(a));
  int ans = INT_MAX;
  for (; mn <= mx; mn++) {
    int cur = 0;
    for (int j : a) {
      cur += (mn - j) * (mn - j);
    }
    smin(ans, cur);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}


int main() {
	ll N, M;
	cin >> N >> M;
	dsu d(N);
	rep(i, M) {
		ll A, B;
		cin >> A >> B;
		A--;
		B--;
		d.merge(A, B);
	}
	vector<vector<int>> AN = d.groups();
	cout << AN.size()-1 << endl;
}

Measured memory_bytes: 9028