akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    /**
     * 文字列s1から文字列s2に変換する際の操作回数の最小値(最小編集距離)を求める
     */
    public int minEditDistance(String s1,String s2) {
        int N = s1.length();
        int M = s2.length();

        int[][] minEditDis = new int[N + 1][M + 1];

        for(int i = 0;i < N + 1;i++) {
            minEditDis[i][0] = i;
        }

        for(int j = 0;j < M + 1;j++) {
            minEditDis[0][j] = j;
        }

        for(int i = 1;i < N + 1;i++) {
            for(int j = 1;j < M + 1;j++) {
//                s1[i-1]をs2[j-1]に置換する場合
                minEditDis[i][j] = minEditDis[i-1][j-1] + (s1.charAt(i - 1) == s2.charAt(j - 1) ? 0 : 1);
//                s1[i]を削除する場合
                minEditDis[i][j] = Math.min(minEditDis[i][j], minEditDis[i-1][j] + 1);
//                s2[j]を追加する場合
                minEditDis[i][j] = Math.min(minEditDis[i][j], minEditDis[i][j-1] + 1);
            }
        }

        return minEditDis[N][M];
    }

    private void solve() {
        String s1 = next();
        String s2 = next();

        out.println(minEditDistance(s1,s2));
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 29612
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int L, R, d;
    cin >> L >> R >> d;
    
    cout << (
            R/d
            -
            L/d
            +
            (
                L%d==0 ?
                    1
                :
                    0
            )
            ) << endl;

    return 0;
}


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

long seq(int a, int m) {
  int cnt = 1;
  int x = 1;
  while(true) {
    x = (a * x) % m;
    if (x == 1) break;
    else
      cnt++;
  }
  return cnt.to!long;
}

long gcd(long a, long b) {
  if (a > b) swap(a, b);
  while(true) {
    b %= a;
    if (b == 0) break;
    else
      swap(a, b);
  }
  return a;
}

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

long lcms(long[] arr) {
  long res = arr[0];
  for(int i = 1; i < arr.length; i++) {
    res = lcm(res, arr[i]);
  }
  return res;
}


void main() {
  while(true) {
    int[] a = readln.chomp.split(" ").map!(to!int).array;
    if (a[0] == 0) break;
    lcms([seq(a[0], a[1]), seq(a[2], a[3]), seq(a[4], a[5])]).writeln;
  }
}

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

k=1
mod=10**9+7
for i in range(n):
    k*=10
    k%=mod
l=1
m=1
for i in range(n):
    l*=9
    l%=mod
for i in range(n):
    m*=8
    m%=mod
a=k+m
a-=2*l
a%=mod
print(a)

Measured memory_bytes: 64348
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;


typedef long long int64;


int main()
{
	while(true) {

		int n, m;
		int64 ans = 0;
		vector<pair<int, int> > dp;

		scanf("%d%d", &n, &m);
		if(n == 0)
			break;
		dp.resize(n);
		for(int i = 0; i < n; ++i)
			scanf("%d%d", &dp[i].second, &dp[i].first);

		sort(dp.rbegin(), dp.rend());

		for(int pos = 0; pos < n; ++pos) {

			int d = dp[pos].second;
			int p = dp[pos].first;

			int x = min(d, m);

			m -= x;
			ans += (d - x) * (int64)p;
		}

		printf("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1112
#include <stdio.h>

int main(){

  int a,b,c;
  int cnt=0;
  scanf("%d %d %d",&a,&b,&c);

  for(int i = a; i <= b; i++){
    int ans;
    ans = c % i;
    if(ans == 0){
      cnt++;
    }
  }
  printf("%d\n",cnt);

}



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

int X, Y, Z;
const int maxn = 2e5 + 5;
int a[maxn], b[maxn], c[maxn];

bool cmp(int i, int j){
    return a[i] - b[i] < a[j] - b[j];
}

int id[maxn];
ll pre[maxn], suf[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> X >> Y >> Z;
    long long Ans = 0;
    for(int i = 1;i <= X + Y + Z;i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i] -= c[i];
        b[i] -= c[i];
        Ans += c[i];
        id[i] = i;
    }
    int n = X + Y + Z;
    sort(id + 1, id + 1 + n, cmp);
    priority_queue<int, vector<int>, greater<int> > pq;
    ll sum = 0;
    pre[0] = -1e18;
    for(int i = 1;i <= n;i++){
        int j = id[i];
        pq.push(b[j]);
        sum += b[j];
        if(pq.size() > Y){
            sum -= pq.top();
            pq.pop();
        }
        if(pq.size() < Y){
            pre[i] = -1e18;
        }
        else pre[i] = sum;
    }
    while(!pq.empty())
        pq.pop();
    sum = 0;
    suf[n + 1] = -1e18;
    for(int i = n;i >= 1;i--){
        int j = id[i];
        pq.push(a[j]);
        sum += a[j];
        if(pq.size() > X){
            sum -= pq.top();
            pq.pop();
        }
        if(pq.size() < X){
            suf[i] = -1e18;
        }else
            suf[i] = sum;
    }
    ll ans = -2e18;
    for(int i = 0;i <= n;i++){
        ans = max(ans, pre[i] + suf[i + 1]);
    }
    cout << ans + Ans << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int A;
    int count_odd = 0;
    for(int i = 0;i < N;i++) {
        cin >> A;
        if(A % 2 == 1) count_odd++;
    }
    if(count_odd % 2 == 0) {cout << "YES" << endl;}
    else {cout << "NO" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for(int i = 0; i < k; i++){
        sum+=p[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;

string shuffle(string str, int h){
    string head = str.substr(0, h);
    string tail = str.substr(h, str.size() - h);
    return tail + head;
}

int main(){
    string cards;
    int m, h;
    while(1){
        cin >> cards;
        if(cards == "-") break;
        cin >> m;
        for(int i = 0; i < m; i++){
            cin >> h;
            cards = shuffle(cards, h);
        }
        cout << cards << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T> T in(){T x;cin>>x;return x;}
// long long a = in<long long>();

int main(){
	int N; cin>>N;
	vector<string> S(N);
	vector<int> T(N);
	int allT = 0;
	rp(i,0,N){
		string s;int t;
		cin>>s>>t;
		S[i] = s;
		T[i] = t;
		allT += t;
	}
	string X;cin>>X;

	// ote(N);
	// ote(X);
	int ans = 0;
	rp(i,0,N){
		// cout<<S[i]<<" "<<T[i]<<"\n";
		ans += T[i];
		if(S[i] == X){
			ote(allT-ans);
			return 0;
		}
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e18
#define MOD 10000007

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;

int x;

bool is_pp(int x){
    int cp=x;
    for(int a=2; a*a<=x; a++){
        if(x%a!=0) continue;
        while(x%a==0){x/=a;}
        if(x==1) return true;
        else x=cp;
    } return false;
}

int largest_pp[1001];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>x;
    largest_pp[1]=1;
    for(int i=2; i<=x; i++){
        if(is_pp(i)) largest_pp[i]=i;
        else largest_pp[i]=largest_pp[i-1];
    } cout<<largest_pp[x];

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
mod = 10**9+7
flag = 0
flag_2 = 0
if n % 2 == 0:
  flag = -1
  for i in range(0,n,2):
    flag += 2
    if a[i] != flag or a[i+1] != flag:
      flag_2 = 1
  if flag_2 == 0:
    print(2**(n//2) % mod)
  else:
    print(0)
else:
  if a[0] != 0:
    flag_2 = 1
  for i in range(1,n,2):
    flag += 2
    if a[i] != flag or a[i+1] != flag:
      flag_2 = 1
  if flag_2 == 0:
    print(2**(n//2) % mod)
  else:
    print(0)

Measured memory_bytes: 52332
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
        }
        long answer = 1;
        for (int i = 0; i < N; i++) {
            answer *= 3;
        }
        long odd = 1;
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 == 1) {
                odd *= 1;
            } else {
                odd *= 2;
            }
        }
        System.out.println(answer - odd);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	int N;
	cin>>N;
	vector<int> a(N);
	rep(i,N){
		cin>>a[i];
	}
	int s,t;
	s=N/2;
	t=N/2;
	int sum=0;
	FDS(i,N-1){
	    if(a[i]==a[i+1]){
	        sum++;
	    }
	}
	if(sum==N-1){
	    cout<<N/2<<endl;
	    return 0;
	}
	
	vector<int> kisuu(s);
	vector<int> guusuu(t);
	rep(i,s){
		kisuu[i]=a[i*2];
	}
	rep(i,t){
		guusuu[i]=a[i*2+1];
	}
	VSORT(kisuu);
	VSORT(guusuu);
	int sub=1;
	int subsub=0;
	int subsubsub=0;
	int x;
	int ans=0;
	int i;
	FDS(i,s-1){
		if(kisuu[i]==kisuu[i+1]){
			sub++;
		}
		else{
			if(sub>=subsub){
				subsubsub=subsub;
				subsub=sub;
				sub=1;
				x=kisuu[i];
			}
			if(sub>=subsubsub){
			    subsubsub=sub;
			}
			sub=1;
		}
	}
	
	if(sub>=subsub){
		subsubsub=subsub;
		subsub=sub;
		sub=1;
		x=kisuu[i];
	}
	if(sub>=subsubsub){
		subsubsub=sub;
	}
	
	int sob=1;
	int sobsob=0;
	int sobsobsob=0;
	int y;
	FDS(i,s-1){
		if(guusuu[i]==guusuu[i+1]){
			sob++;
		}
		else{
			if(sob>=sobsob){
				sobsobsob=sobsob;
				sobsob=sob;
				sob=1;
				y=guusuu[i];
			}
			if(sob>=sobsobsob){
			    sobsobsob=sob;
			}
			sob=1;
		}
	}
	
	if(sob>=sobsob){
		sobsobsob=sobsob;
		sobsob=sob;
		sob=1;
		y=guusuu[i];
	}
	if(sob>=sobsobsob){
		sobsobsob=sob;
	}
	
	if(x!=y){
		ans+=(N-subsub-sobsob);
	}
	else{
		if(subsub<sobsob){
			ans+=N-sobsob-subsubsub;
		}
		if(subsub>sobsob){
			ans+=N-subsub-sobsobsob;
		}
		if(subsub==sobsob){
			ans+=N-subsub-max(subsubsub,sobsobsob);
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
 
 
using namespace std;
int main() {
string s;
  int ans=1000;
  cin >> s;
  size_t l = s.size();
      string sub;
  int num =0;
rep(i,l-2){
    sub=s.substr(i,3);
    num = stoi(sub);
  ans = min(ans,abs(753-num));

}
    
  
    
    
    
  cout << ans;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#define INF 100000000
#define MAX_C 100
using namespace std;
map<int, int> mp;
int main()
{
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	int counter = 0;
	for (int i = 0; i < n; i++) cin >> m[i];
	for (int i = 0; i < n; i++) {
		x -= m[i];
		counter++;
	}
	sort(m.begin(), m.end());
	cout << counter + x / m[0] << endl;
}

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1,n,m,k;
vll_t a,b;

int main(){
	//scanf("%d",&t);
	while(t--){
		string s;
		cin>>s;
		int ma=0;
		int i=0,j=0;
		for(i=0;i<s.size();i++){
			if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
				int count=1;
				for(j=i+1;j<s.size();j++){
					if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T'){
						count++;
					}
					else{
						break;
					}
				}
				ma=max(count,ma);
				i=j-1;
			}
		}
		cout<<ma<<endl;
	}
}

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



int main() {
  int h, w;
  cin >> h >> w;
  string board[50];

  for(int i = 0; i < h; i++) cin >> board[i];
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(board[i][j] == '#') continue;

      int num = 0;
      for(int d = 0; d < 8; d++){
        const int ni = i + dy[d];
        const int nj = j + dx[d];

        if(ni < 0 || h <= ni) continue;
        if(nj < 0 || w <= nj) continue;
        if(board[ni][nj] == '#') num ++;
      }
      board[i][j] = char(num + '0');
    }
  }
  for(int i = 0; i < h; i++) cout << board[i] << endl;


}

Measured memory_bytes: 256
N, L = map(int, input().split())

taste = [(L + i - 1) + 1 for i in range(N)]
pie = {}
ab, tas = 0, 0
for i in range(N):
    tmp0 = sum(taste)
    tmp = taste[:]
    tmp.pop(i)
    tmp1 = sum(tmp)
    if i == 0:
      ab, tas = abs(tmp0 - tmp1), tmp1
    else:
        if ab > abs(tmp0 - tmp1):
            ab, tas = abs(tmp0 - tmp1), tmp1
     	
print(tas)

Measured memory_bytes: 3064
#include <iostream>

int main()
{
  int a, b;
  int x = 0;
  std::cin >> a;
  std::cin >> b;

  for (int i = 0;; ++ i){
    if (b == 1){
      break;
    }
    ++x;
    if (a + i*(a-1) >= b){
      break;
    }
  }
    std::cout << x << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
#define MOD 1'000'000'007

#define N 2123456
ll a[N]={};
ll fct[N], fctsm[N];

int main(){
	fct[0] = 1;
	FOR(i, 1, N) fct[i]=fct[i-1]*i%MOD;
	fctsm[0]=0;
	FOR(i, 1, N) fctsm[i]=(fctsm[i-1]+fct[i]) %MOD;
	int n, h, d; scanf("%d%d%d", &n, &h, &d);
	a[h] = 1;
	ll sm = 0;
	for(int i = h-1; i >= 1; i--){
		// sm = a[i+1 ... i+d]
		// sm = 0;
		// for(int j=i+1; j<=i+d; j++) sm = (sm + a[j]) % MOD;
		sm = (sm + a[i+1] + (MOD-a[i+d+1])) % MOD;
		a[i] = fctsm[n] * sm % MOD;
	}
	// sm = a[1 ... d]
	sm = 0;
	for(int j=1; j<=d; j++) sm = (sm + a[j]) % MOD;
	a[0] = fct[n] * sm % MOD;
	printf("%lld\n", a[0]);
}


Measured memory_bytes: 43264
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define inf int(1e9)
#define half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;

string s;

void solve() {
    ll ans = 0, c_w = 0;
    repr(i, s.length()) {
        if (s[i] == 'W') c_w++;
        if (s[i] == 'B') ans += c_w;
    }
    cout << ans << endl;
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 640
use std::collections::HashMap;

fn main() {
  let nkl: Vec<usize> = read_vec();
  let (n, k, l) = (nkl[0], nkl[1], nkl[2]);
  let pqs: Vec<(usize, usize)> = read_tuples(k);
  let rss: Vec<(usize, usize)> = read_tuples(l);

  let mut ufr = UnionFind::new(n);
  for (p, q) in pqs {
    ufr.unite(p-1, q-1)
  }

  let mut uft = UnionFind::new(n);
  for (r, s) in rss {
    uft.unite(r-1, s-1)
  }

  let mut map = HashMap::new();
  for pq in (0..n).map(|p| ufr.rep(p)).zip((0..n).map(|p| uft.rep(p))) {
    let counter = map.entry(pq).or_insert(0);
    *counter += 1;
  }
  
  let mut ans: Vec<usize> = vec![];
  for i in 0 .. n {
    ans.push(*map.get(&(ufr.rep(i),uft.rep(i))).unwrap());
  }
  
  print_vec(&ans, " ");
}

struct UnionFind {
  rp: Vec<usize>,
  rk: Vec<usize>
}

impl UnionFind {
  fn new(n: usize) -> UnionFind {
    UnionFind {
      rp: (0..n).collect(),
      rk: vec![1; n]
    }
  }
  
  fn rep(&self, p: usize) -> usize {
    if self.rp[p] == p {p} else {self.rep(self.rp[p])}
  }
  
  fn rank(&self, p: usize) -> usize {
    self.rk[self.rep(p)]
  }
  
  fn same(&self, p: usize, q: usize) -> bool {
    self.rep(p) == self.rep(q)
  }
  
  fn unite(&mut self, p: usize, q:usize) {
    let rkp = self.rank(p);
    let rkq = self.rank(q);
    let (p, q) = if rkp <= rkq {(p, q)} else {(q, p)};
    
    let repp = self.rep(p);
    let repq = self.rep(q);
    self.rp[p] = repq;
    self.rp[repp] = repq;
    self.rk[repq] += self.rk[repp];
  }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}

fn read_tuple<T1: std::str::FromStr, T2: std::str::FromStr>() -> (T1, T2) {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut it = buf.trim().split_whitespace();
  let x = it.next().unwrap().parse::<T1>().ok().unwrap();
  let y = it.next().unwrap().parse::<T2>().ok().unwrap();
  (x, y)
}

fn read_tuples<T1: std::str::FromStr, T2: std::str::FromStr>(n: usize) -> Vec<(T1, T2)> {
  let mut vec: Vec<(T1, T2)> = vec![];
  for _ in 0 .. n {
    vec.push(read_tuple());
  }
  vec
}

fn print_vec<T: std::string::ToString>(vec: &[T], sep: &str) {
  let out = vec.iter().map(|e| e.to_string()).collect::<Vec<_>>().as_slice().join(sep);
  println!("{}", out);
}

Measured memory_bytes: 29928
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
int n,m;
char s[1005][1005];
int q[20000005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%s",s[i]);
	int head=0,tail=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i][j]=='#'){
				q[tail]=i;tail++;
				q[tail]=j;tail++;
				q[tail]=0;tail++;
			}
		}
	}
	int res=0;
	while(head<tail){
		int x=q[head];head++;
		int y=q[head];head++;
		int t=q[head];head++;
		res=max(res,t);
		for(int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx>=0&&nx<n&&ny>=0&&ny<m){
				if(s[nx][ny]=='.'){
					q[tail]=nx;tail++;
					q[tail]=ny;tail++;
					q[tail]=t+1;tail++;
				}
				s[nx][ny]='#';
			}
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n,m;cin>>n>>m;
    vl a(m);rep(i,m)cin>>a[i];
    ll sum=0;
    rep(i,m)sum+=a[i];
    if(n<sum){
        cout<<-1<<endl;
        return 0;
    }
    cout<<n-sum<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll pa(ll k){
    ll t=1;
    while(t<=k) t*=2;
    return t-k;
}

int main(){
    ll i,j;
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end(),greater<ll>());

    map<ll,ll> m;
    for(i=0;i<n;i++) m[a[i]]++;

    ll ans=0;
    for(i=0;i<n;i++){
        if(m[a[i]]>0) {
            m[a[i]]--;
            if(m[a[i]]==0) m.erase(a[i]);
            ll p=pa(a[i]);
            if(m.count(p)) {
                m[p]--;
                ans++;
                if(m[p]==0) m.erase(p);
            }
        }
    }
    cout<<ans<<endl;
   
  
}

Measured memory_bytes: 14336
import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni(), k = ni();
        boolean[] win = new boolean[1+k];
        int[] a = new int[n];
        for(int i = 0; i< n; i++)a[i] = ni();
        for(int i = 1; i<= k; i++){
            win[i] = false;
            for(int j = 0; j< n; j++)if(a[j]<=i)win[i] |= !win[i-a[j]];
        }
        pn(win[k]?"First":"Second");
    }
    //SOLUTION END
    void hold()throws Exception{throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)4e18;
    final int INF = (int)2e9, MX = (int)1e6+1;
    DecimalFormat df = new DecimalFormat("0.000000000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }  
            return str;
        }
    }
}    

Measured memory_bytes: 21844
from collections import deque 
H,W = map(int,input().split())
st = [str(input()) for _ in range(H)]
#print(st)
st = deque(st)
for i in range(H):
    st[i] = '#'+st[i]+'#'
st.appendleft('#'*(W+2))
st.append('#'*(W+2))

for i in range(H+2):
    print(st[i])

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

int main(){
  int c[9];
  int sum = 0;
  rep(i,9) {
    cin >>c[i];
    sum += c[i];
  }
  int jud = 3*(c[0]+c[4]+c[8]);
  if(sum==jud) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}


Measured memory_bytes: 3632
n=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
      arr.append([n,1])
    return arr

l=factorization(n)

ans=0
cnt=1
if n==1:
  print(0)
else:
  for i,e in l:
    cnt=1
    while(cnt<=e):
      e-=cnt
      ans+=1
      cnt+=1
  print(ans)

Measured memory_bytes: 9392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll num = b[i];

    auto ait = lower_bound(a.begin(), a.end(), num);
    ll acnt = distance(a.begin(), ait);

    auto cit = upper_bound(c.begin(), c.end(), num);
    ll ccnt = n - distance(c.begin(), cit);

    ans += acnt * ccnt;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
long N=0;
long SUM=0;
long i=0;
scanf("%ld",&N);
for(i=0;i<=N;i++){
    if(i%3!=0){
        if(i%5!=0){
        SUM=SUM+i;
        }
    }
}
printf("%ld\n",SUM);
return 0;

}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k, inf = 100000000;
    int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
    cin >> h >> w >> k;
    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    xs--, ys--, xt--, yt--;
    string s[h];
    for(int i=0;i<h;i++) cin >> s[i];
    vector<int> dis(h * w * 4, inf);
    multiset<pair<int, int> > ms;
    auto toId = [&](int x, int y, int v){
    	return (x * w + y) * 4 + v;
    };
    auto cei = [&](int n){return ((n + k - 1) / k) * k;};
    auto push = [&](int d, int x, int y, int v){
    	int now = toId(x, y, v);
    	if(dis[now] > d) {
    		dis[now] = d;
    		ms.insert({d, now});
    	}
    	return;
    };
    for(int i=0;i<4;i++) push(0, xs, ys, i);
    while(!ms.empty()){
    	int d = ms.begin()->first;
    	int id = ms.begin()->second;
    	ms.erase(ms.begin());
    	int x = id / w / 4;
    	int y = id / 4 % w;
    	int v = id % 4;
    	
    	if(d > dis[id]) continue;
    	for(int i=0;i<4;i++){
    		push(cei(d), x, y, i);
    	}
    	x += dx[v]; y += dy[v];
    	if(x < 0 || x >= h || y < 0 || y >= w || s[x][y] == '@') continue;
    	push(d + 1, x, y, v);
    }
    int ans = inf;
    for(int i=0;i<4;i++) ans = min(ans, dis[toId(xt, yt, i)]);
    cout << ((ans == inf)? -1 : (ans + k - 1) / k) << endl;
    return 0;
}


Measured memory_bytes: 36512
import math
for _ in range(int(input())):
    x1,y1,x2,y2,x3,y3=map(float,input().split())
    a,b,c=2*(x2-x1),2*(y2-y1),x1**2-x2**2+y1**2-y2**2
    aa,bb,cc=2*(x3-x1),2*(y3-y1),x1**2-x3**2+y1**2-y3**2
    x,y=(b*cc-bb*c)/(a*bb-aa*b),(c*aa-cc*a)/(a*bb-aa*b)
    print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))

Measured memory_bytes: 7592
N = int(input())
S = [int(input()) for i in range(N)]
S.sort()
if sum(S) % 10 != 0:
    print(sum(S))
else:
    for i in range(N):
        if S[i] % 10 != 0:
            print(sum(S)-S[i])
            exit()
    print(0)


Measured memory_bytes: 61984
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; }
template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000001

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    double a[n];
    FORR(i,a)
        cin >> i;
    double res = 0;
    FORR(i,a)
        res += 1.0/i;
    res = 1/res;
    cout << fixed << setprecision(9) << res << '\n';
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int N; cin >> N;
    int ans = 0;
    rep(i, N) {
        int l, r; cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
words = ["dream", "dreamer", "erase", "eraser"]
            #5      #7          #5      #6
s = input()

while len(s) > 0:
    if s[-5:] in words:
        s = s[:-5]
    elif s[-6:] in words:
        s = s[:-6]
    elif s[-7:] in words:
        s = s[:-7]
    else:
        print("NO")
        exit()

print("YES")


Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int q = saori.saori_hayami();
		int h = saori.saori_hayami();
		int s = saori.saori_hayami();
		int d = saori.saori_hayami();
		int n = saori.saori_hayami();
		long half = Math.min(q*2, h);
		long one = Math.min(half*2, s);
		long two = Math.min(one*2, d);
		long num = n/2;
		long ans = num*two;
		if(n == num*2){
			System.out.println(ans);
		} else {
			System.out.println(ans + one);
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32396
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int mod = 1000000000 + 7;
    int n = Integer.parseInt(sc.next());
    int a[] = new int[n];
    long sums[] = new long[n];
    long sum = 0;
    for (int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = n - 1; i >= 0; i--) {
      sum += a[i];
      sum %= mod;
      sums[i] = sum;
    }
    long ans = 0;
    for (int i = 0; i < n - 1; i++) {
      ans += sums[i + 1] * a[i];
      ans %= mod;
    }
    pw.println(ans);
  }
}


Measured memory_bytes: 61548
s = input()
a = int(s[:2])
b = int(s[2:])
yymm = 1<=b<=12
mmyy = 1<=a<=12
if yymm:
  if mmyy:
    print("AMBIGUOUS")
  else:
    print("YYMM")
else:
  if mmyy:
    print("MMYY")
  else:
    print("NA")


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

int main(){
  int  p,q,r;cin >> p >> q >> r;
  cout << (p+q+r)-max({p,q,r}) << endl;
  return 0;
}


Measured memory_bytes: 256
N, M, Q = [int(_) for _ in input().split()]

train_map = [[0] * (N + 1) for i in range(N + 1)]
for _ in range(M):
    l, r = [int(_) for _ in input().split()]
    train_map[l][r] += 1

cumsum = [[0] * (N + 1) for i in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        cumsum[i][j] = train_map[i][j] + cumsum[i][j - 1] + cumsum[i - 1][j] - cumsum[i - 1][j - 1]

for _ in range(Q):
    p, q = [int(_) for _ in input().split()]
    print(cumsum[q][q] - cumsum[p-1][q])


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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  int n;
  cin >> n;
  vector<pair<int, int>> V(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> V[i].first;
    V[i].second = i;
  }
  sort(V.begin() + 1, V.end());
  for (int i = 1; i <= n; ++i) {
    assert(V[i].first == i);
    cout << V[i].second << " \n"[i == n];
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans,num1,num2,dc;
	string t;
	cin>>t;
	int lent=t.length();
	dc=lent/2;
	for(int i=1;i<=lent;i++)
		if(t[i]=='p')num1++;
	ans=dc-num1;
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

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


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

	cin >> N >> K;
	vector<int>p(N);
	for (auto &i : p) {
		cin >> i;
		i--;
	}
	vector<long long int>score(N);
	vector<long long int>loop(N);
	for (auto &i : score) {
		cin >> i;
	}
	vector<vector<long long int>>dp(N, vector<long long int>(N + 1));
	for (int i = 0; i < N; i++) {
		int cn = i;
		for (int j = 1; j <= N; j++) {
			cn = p[cn];
			dp[i][j] = dp[i][j - 1] + score[cn];
			if (cn == i) {
				loop[i] = j;
				break;
			}
		}
	}
	long long int ans = -MOD;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= min(loop[i],K); j++) {
			if (dp[i][loop[i]] > 0) {
				ans = max(ans, dp[i][j] + (K - j) / loop[i] * dp[i][loop[i]]);
			}
			else {
				ans = max(ans, dp[i][j]);
			}
		}
	}
	cout << ans << endl;
}


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

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

int main(){
  int n;
  cin >> n;
  int a[n+2];
  int b[n+2];
  int c[n+2];
  int ans=0;
  b[0] = 0;
  c[n+1] = 0;
//入力
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
//左からの最大公約数を求めてく
  for(int i=1;i<=n;i++){
    b[i] = gcd(a[i],b[i-1]);
  }
//右からの最大公約数を求めてく
  for(int i=n;i>=1;i--){
    c[i] = gcd(a[i],c[i+1]);
  }
//i番目を飛ばした右と左の最大公約数を求めてそれらの最大値が答え
  for(int i=1;i<=n;i++){
    ans = max(ans,gcd(b[i-1],c[i+1]));
  }

  cout << ans << endl;

}






Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

int main()
{
    int N,X,T;
    cin >> N >> X >> T;

    int count = N / X ;

    if(N% X != 0)
    {
        count++;
    }

    int res = count * T;

    cout << res << endl;

    return 0;

}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a[10];
	string str;
	while(cin >> str){
		rep(i,10) a[i] = str[i]-'0';
		rep(i,9){
			rep(j,9-i){
				a[j] = a[j]+a[j+1];
				a[j] %= 10;
			}
		}
		cout << a[0] << endl;
	}
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <string.h>
#define N 36
void sele(void);
void bubl(void);
void pr(char);
char b[N][3];
char s[N][3];
int num;
int main(void){
    int i,math[N][2],mark=0;
    scanf("%d",&num);
    for(i=0;i<num;i++){
        scanf("%s",math[i]);
        strcpy(b[i],math[i]);
        strcpy(s[i],math[i]);
    }
    
    bubl();
    printf("%s",b[0]);
    for(i=1;i<num;i++){
         printf(" %s",b[i]);
    }
    printf("\nStable\n");
    
    sele();
    printf("%s",s[0]);
    for(i=1;i<num;i++){
         printf(" %s",s[i]);
    }
    
    for(i=0;i<num;i++){
       if(strcmp(s[i],b[i])!=0){
           mark =1;
           break;
       }
    }
    
    printf("%s",(mark==0)?"\nStable\n":"\nNot stable\n");
    
    return 0;
}

void sele(void){
    int i,j,min;
    char temp[3];
    for(i=0;i<=num-2;i++){
        min = i;
        for(j=i;j<=num-1;j++){
            if(s[j][1]<s[min][1]){
               min = j;
            }
        }
        
       if(i != min ){
            strcpy(temp,s[min]);
            strcpy(s[min],s[i]);
            strcpy(s[i],temp);
        }
    }
}

void bubl(void){
    int i,j;
    char temp[3];
    for(i=0;i<num-1;i++){
        for(j=num-1;j>=i+1;j--){
            if(b[j][1]<b[j-1][1]){
                strcpy(temp,b[j-1]);
                strcpy(b[j-1],b[j]);
                strcpy(b[j],temp);
            }
        }
    }
}





Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
vector<vector<char>> a;
int h, w;
const vi dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
bool good(pii p)
{
    int i = p.fi, j = p.se;
    return 0 <= i && i < h && 0 <= j && j < w;
}
int dist(pii from, pii to)
{
    queue<pii> q;
    q.push(from);
    vvi dist(h, vi(w, LLONG_MAX));
    dist[from.fi][from.se] = 0;
    while (sz(q))
    {
        pii cur = q.front();
        q.pop();
        for (int i = 0; i < 4; i++)
        {
            pii nxt = {cur.fi + dx[i], cur.se + dy[i]};
            if (good(nxt) && a[nxt.fi][nxt.se] != '#' && dist[nxt.fi][nxt.se] > dist[cur.fi][cur.se] + 1)
            {
                q.push(nxt);
                dist[nxt.fi][nxt.se] = dist[cur.fi][cur.se] + 1;
            }
        }
    }
    return dist[to.fi][to.se];
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> h >> w;
    a = vector<vector<char>>(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++)
            a[i][j] = s[j];
    }
    int res = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (a[i][j] != '#')
                for (int k = 0; k < h; k++)
                    for (int l = 0; l < w; l++)
                        if (!(i == k && j == l) && a[k][l] != '#')
                            res = max(res, dist({i, j}, {k, l}));
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 256