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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){

    int k, q;
    cin >> k >> q;
    vector<int> d(k);
    for(int i = 0; i < k; ++i)
        cin >> d[i];
    vector<int> vn(q), vx(q), vm(q);
    for(int i = 0; i < q; ++i)
        cin >> vn[i] >> vx[i] >> vm[i];

    for(int i = 0; i < q; ++i){
        int n = vn[i];
        int m = vm[i];
        int x = vx[i] % m;
        vector<int> a(k);
        for(int j = 0; j < k; ++j)
            a[j] = d[j] % m;
        i64 sum = accumulate(a.begin(), a.end(), 0LL);
        --n;

        // n - 0が出る個数 - 繰り上がりの回数

        i64 t_sum = sum * (n / k) + x;
        i64 zero_cnt = count(a.begin(), a.end(), 0) * (n / k);
        // cout << t_sum << " : " << n / k << endl;
        for(int j = 0; j < n % k; ++j){
            t_sum += a[j];
            zero_cnt += (a[j] == 0);
        }

        /*
        cout << endl;
        for(int j = 0; j < k; ++j)
            cout << a[j] << " \n"[j + 1 == k];
            */
        cout << n - t_sum / m - zero_cnt << endl;
        // cout << "\n------\n";
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename H> void print(H head) { std::cout << head << std::endl; }
template <typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << *it << " ";
    if ((it - begin) % 20 == 19 || it == end - 1) { std::cout << std::endl; }
  }
}

int main()
{
  //std::ifstream ifs("input.def");
  //std::cin.rdbuf(ifs.rdbuf());

  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N, C;
  std::cin >> N >> C;

  std::vector< std::pair<ll, ll> > vp(N);
  std::vector< ll > vx(N, 0LL);
  std::vector< ll > vv(N, 0LL);


  for (ll i = 0; i < N; i++) {
    std::cin >> vp[i].first >> vp[i].second;
  }

  std::sort(vp.begin(), vp.end());

  std::vector<ll> vsum1(N+1, 0LL);
  std::vector<ll> vmax1(N+1, 0LL);
  std::vector<ll> vmax1_rev(N+1, 0LL);
  for (ll i = 1; i <= N; i++) {
    vsum1[i]     = vsum1[i-1] + vp[i-1].second;
    vmax1[i]     = std::max(vmax1[i-1],     vsum1[i] - vp[i-1].first * 1);
    vmax1_rev[i] = std::max(vmax1_rev[i-1], vsum1[i] - vp[i-1].first * 2);
  }

  std::reverse(vp.begin(), vp.end());

  std::vector< ll > vsum2(N+1, 0LL);
  std::vector<ll> vmax2(N+1, 0LL);
  std::vector<ll> vmax2_rev(N+1, 0LL);
  for (ll i = 1; i <= N; i++) {
    vsum2[i]     = vsum2[i-1] + vp[i-1].second;
    vmax2[i]     = std::max(vmax2[i-1],     vsum2[i] - (C - vp[i-1].first) * 1);
    vmax2_rev[i] = std::max(vmax2_rev[i-1], vsum2[i] - (C - vp[i-1].first) * 2);
  }

  ll ans = 0LL;
  for (ll i = 0; i <= N; i++) {
    ans = std::max(ans, vmax1[i] + vmax2_rev[N-i]);
    ans = std::max(ans, vmax2[i] + vmax1_rev[N-i]);
  }

  print(ans);

  return 0;
}


Measured memory_bytes: 8064
H,W = map(int,input().split())

import sys

a = (W+1)//2+(W//2)

if H == 1 or W == 1:
    print(1)
    sys.exit()

if H%2 == 0:
    print(a*(H//2))
else:
    print(a*(H//2)+(W+1)//2)

Measured memory_bytes: 3060
#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>;

const int INF = 1001001001;
vector<int> to[100005];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front(); q.pop();
        for (int u: to[v]){
            if(dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    rep(i, n){
        if(i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 10588
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF (1<<29)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define REP(i, n) FOR(i, 0, n)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX (128)
int N,S,T[MX],a,b;
int main(void){
    scanf("%d",&N),ga(N,T),S=accumulate(T,T+N,0);
    IN(Q)F(Q)scanf("%d%d",&a,&b),printf("%d\n",S-T[--a]+b);
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdlib>
#include <utility>
#include <set>
#include <queue>
#define INF 100000000
using namespace std;

bool used[3010]={0};
int mol[3010]={0};
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq[3010];
int A[100010],B[100010],L[100010];

int main(){
	int N,M,K,a,b,c,cnt,hog,imax,imad;
	pair<int,int> pa,pa2;
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > que;
	set<pair<int,int> >::iterator it;
	cin>>N>>M>>K;
	fill(mol,mol+N,INF);
	for(int i=0;i<M;i++){
		cin>>a>>b>>c;
		a--;b--;
		pq[a].push(make_pair(c,b));
		pq[b].push(make_pair(c,a));
		A[i]=a;
		B[i]=b;
		L[i]=c;
	}
	for(int i=0;i<K;i++){
		cin>>a;
		a--;
		que.push(make_pair(0,a));
	}

	while(!que.empty()){
		pa=que.top();que.pop();
		imax=pa.second;
		if(!used[imax]){
			mol[imax]=imad=pa.first;
			used[imax]=true;
			while(!pq[imax].empty()){
				pa2=pq[imax].top();pq[imax].pop();
				if(!used[pa2.second])que.push(make_pair(imad+pa2.first,pa2.second));
			}
		}
	}
	cnt=0;
	for(int i=0;i<M;i++){
		if(L[i]<=abs(mol[A[i]]-mol[B[i]])) cnt=max(cnt,max(mol[A[i]],mol[B[i]]));
		else{
			if((L[i]-abs(mol[A[i]]-mol[B[i]]))%2==0){
				hog=(L[i]-abs(mol[A[i]]-mol[B[i]]))/2;
			}
			else{
				hog=(L[i]-abs(mol[A[i]]-mol[B[i]]))/2+1;
			}
			cnt=max(cnt,hog+max(mol[A[i]],mol[B[i]]));
		}
	}
	/*for(int i=0;i<N;i++){
		cout<<mol[i]<<" ";
	}*/
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 6144
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var h = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

		var dp = new int[n + 1, 3];
		for (int i = 1; i <= n; i++)
		{
			dp[i, 0] = Math.Max(dp[i - 1, 1] + h[i - 1][1], dp[i - 1, 2] + h[i - 1][2]);
			dp[i, 1] = Math.Max(dp[i - 1, 2] + h[i - 1][2], dp[i - 1, 0] + h[i - 1][0]);
			dp[i, 2] = Math.Max(dp[i - 1, 0] + h[i - 1][0], dp[i - 1, 1] + h[i - 1][1]);
		}
		Console.WriteLine(Math.Max(Math.Max(dp[n, 0], dp[n, 1]), dp[n, 2]));
	}
}


Measured memory_bytes: 27832
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))

prev_a = None
ret = 0
for a_ in a:
    ret += b[a_ - 1]
    if prev_a is not None and a_ - prev_a == 1:
        ret += c[prev_a - 1]
    prev_a = a_

print(ret)


Measured memory_bytes: 3064
s_list = list(input())
s_list1 = s_list[1:]
count = 0

if s_list[0] == "A":
    del s_list[:2], s_list[-1]
    for i in range(len(s_list)):
        if s_list[i] == "C":
            count += 1
            isC = i + 1
    if count != 1:
        print("WA")
    else:
        del s_list1[isC]
        Str = "".join(s_list1)
        if Str.islower():
            print("AC")
        else:
            print("WA")
else:
    print("WA")

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <stack>

int main()
{
    int N, p;
    scanf("%d", &N);
    
    std::vector<int> s(N, -1);    
    std::vector<std::stack<int>> G(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &p);
        s[p - 1] += 1;
        G[p - 1].push(i);
    }

    for (int i = 1; i < N; i++) {
        s[i] += s[i - 1];
    }
    
    int min = N, min_idx = -1;
    for (int i = 0; i < N; i++) {
        if (s[i] < min) {
            min = s[i];
            min_idx = i;
        }
    }

    min_idx = (min_idx + 1) % N;
    
    std::vector<int> res(N);
    std::stack<int> st;
    for (int i = 0; i < N; i++) {
        int p = (i + min_idx) % N;
        while (!G[p].empty()) {
            int t = G[p].top();
            G[p].pop();
            st.push(t);            
        }
        res[p] = st.top();
        st.pop();
    }

    for (int num : res) {
        printf("%d\n", num + 1);
    }    
    return 0;
}

Measured memory_bytes: 70956
def main():
    x, y = map(int, input().split())
    y2 = y
    ans = 'No'

    for i in range(x + 1):
        x2 = x - i 
        if 4 * i + 2 * x2 == y:
            ans = 'Yes'
            break

    print(f'{ans}')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);

	public static void main(String[] $){
		int[]a=new int[11];
		while(true){
			int n=s.nextInt();
			if(n==0)
				return;
			int w=s.nextInt();
			
			Arrays.fill(a,0);
			
			int len=0;
			for(int i=0;i<n;++i) {
				int v=s.nextInt()/w;
				len=Math.max(len,v);
				++a[v];
			}
			
			int h=Arrays.stream(a).max().getAsInt();
			
			double r=0;
			for(int i=0;i<=len;++i)
				r+=a[i]*(len-i);
			
			System.out.println(r/len/h+0.01);
		}
	}
}


Measured memory_bytes: 34868
#include<iostream>
using namespace std;
int main(){
  int N, A[200000], sA[200000];
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A[i];
    sA[i] = A[i];
  }
  sort(sA, sA+N, greater<int>());
  for(int i=0; i<N; i++){
    int j=0;
    if(A[i] == sA[0]) cout << sA[1] << endl;
    else cout << sA[j] << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int arr[105];

int32_t main()
{
    fast;
    int n;cin>>n;
    for(int i=1;i<n;i++)
        cin>>arr[i];

    int ans=arr[1];
    for(int i=2;i<n;i++)
        ans+=min(arr[i-1],arr[i]);
    ans+=arr[n-1];
    cout<<ans;
}

Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll>h(n);
  rep(i,n) cin >> h.at(i);
  sort(h.begin(),h.end());
  ll count = 0;
  rep(i,n-k) count += h.at(i);
  cout << count << endl;
}

Measured memory_bytes: 1792
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;



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

    vector<vector<int>> g(n);
    for (int i=0; i<n; i++) g[i] = vector<int>();  // id=i+1

    int s, d;
    for (int i=0; i<n-1; i++) {
        cin >> s >> d;
        s--; d--;
        g[s].push_back(d);
    }

    int p, x;
    vector<int> scores(n);
    fill(scores.begin(), scores.end(), 0);
    for (int i=0; i<q; i++) {
        cin >> p >> x;
        scores[p-1] += x;
    }

    queue<pair<int, int>> queue;
    queue.push(make_pair(0, scores[0]));

    int node, score;
    while (!queue.empty()) {
        node = queue.front().first;
        score = queue.front().second;
        queue.pop();
        scores[node] = score;

        for (auto next_node: g[node]) {
            queue.push(make_pair(next_node, score+scores[next_node]));
        }
    }

    cout << scores[0];
    for (int i=1; i<n; i++) cout << ' ' << scores[i];
    cout << endl;
    return 0;
}



Measured memory_bytes: 14080
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int w,h;
int tbl[30][30];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
int gx,gy;
int ans;

void dfs(int x,int y,int d){
  if(d >= ans) return;
  if(x==gx && y==gy){
    ans = d;
    return;
  }
  for(int i=0;i<4;++i){
    for(int j=1;;++j){
      int mx = x+j*dx[i];
      int my = y+j*dy[i];
      if(mx<0 || my<0) break;
      if(mx>=w || my>=h) break;
      if(j==1 && tbl[my][mx]==1) break;
      if(tbl[my][mx]==3){
	dfs(mx,my,d+1);
	break;
      }
      if(mx+dx[i]<0 || my+dy[i]<0) break;
      if(mx+dx[i]>=w || my+dy[i]>=h) break;

      if(tbl[my+dy[i]][mx+dx[i]]==1){ //??????????????????????????¨???
	tbl[my+dy[i]][mx+dx[i]] = 0;
	dfs(mx,my,d+1);
	tbl[my+dy[i]][mx+dx[i]] = 1;	
	break;
      }
    }
  }
}

int main(){
  while(cin>>w>>h,w||h){
    for(int i=0;i<h;++i)
      for(int j=0;j<w;++j)
	cin >> tbl[i][j];
    int sx,sy;
    for(int i=0;i<h;++i)
      for(int j=0;j<w;++j){
	if(tbl[i][j]==2) sx=j,sy=i;
	if(tbl[i][j]==3) gx=j,gy=i;
      }
    for(int i=0;i<h;++i)
      for(int j=0;j<w;++j)
	if(tbl[i][j]==2) tbl[i][j] = 0;
    ans = 11;
    dfs(sx,sy,0);
    if(ans>10) ans = -1;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    int sa = b-a;
    int i;
    int sum = 0;
    for(i = 1;i < sa;++i){
        sum += i;
    }
    int ans = sum-a;
    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 < n; i++)
int n, t=1, u=2;
int main(){
	scanf("%d", &n);
	for(;t<n;t*=2);
	if(t==n) return 0*puts("No");
	puts("Yes");
	if(n==3) return 0*printf("1 2\n2 3\n3 4\n4 5\n5 6\n");
	t/=2;
	for(;u<t;u++) printf("%d %d\n%d %d\n", u-1,u,u-1+n,u+n);
	printf("%d %d\n", u-1,1+n);
	for(;u<n;u+=2) printf("%d %d\n%d 1\n1 %d\n%d %d\n", u,u+1,u+1,u+n,u+n,u+n+1);
	if(n==u) printf("%d %d\n%d %d\n", n,u%4==2?t+1:t+n,u^t,n+n);
}

Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val firstLine = readLine()?.split(" ").orEmpty()
    val readCount = firstLine[0].toInt()
    var pastCount = 0L
    val resultOrder = firstLine[1].toLong()
    val bigList = mutableListOf<Pair<Int,Int>>()

    for(i in 0 until readCount){
        val valueLine = readLine()?.split(" ").orEmpty()
            bigList.add(Pair(valueLine[0].toInt(), valueLine[1].toInt()))
    }

    bigList.sortBy{it.first}

    run loop@{
        bigList.forEach {
            pastCount += it.second
            if(pastCount >= resultOrder){
                println(it.first)
                return@loop
            }
        }
    }
}

Measured memory_bytes: 80040
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int, string> c;
vector<c> V;

bool compare(c x,c y) {
  return x.first<y.first;
}

int main() {
  int N;
  cin >> N;
  while(1) {
    if(N == 0) break;
    for(int i=0;i<N;i++) {
      int win,lose,draw,point;
      string country;
      cin >> country >> win >> lose >> draw;
      point = win * 3 + draw * 1;
      c temp;
      temp.first = point;
      temp.second = country;
      V.push_back(temp);
    }
    stable_sort(V.rbegin(), V.rend(), compare);

    for(int i=0;i<N;i++) {
      cout << V[i].second << "," << V[i].first << endl;
    }
    N=0;
    cin >> N;
    if(N == 0) break;
    else cout << endl;
    V.clear();
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <functional>
#include <cmath>
#include <iostream>
#include <vector>

std::uint64_t gcd(std::uint64_t a, std::uint64_t b) {
	if (a == 0) return b;
	if (b == 0) return a;
	return gcd(b, a % b);
}


int main() {
	int N;
	std::cin >> N;

	std::vector<std::uint64_t> T;
	T.reserve(N);

	for (int i = 0; i < N; ++i) {
		std::cin >> T[i];
	}

	std::sort(std::begin(T), std::end(T), std::greater<std::uint64_t>());
	std::uint64_t ans = T[0];

	for (int i = 1; i < N; ++i) {
		ans = ans * (T[i] / gcd(T[i], ans));
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PI 2 * acos(0)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 200000
#define MOD 1e7
#define print(a, b) printf("Case %d: %.0f\n", a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
/*................OMI.................*/

bool isPrime(ll n)
{
   if (n <= 1)
      return false;
   if (n <= 3)
      return true;

   if (n % 2 == 0 || n % 3 == 0)
      return false;

   for (ll i = 5; i * i <= n; i = i + 2)
      if (n % i == 0)
         return false;

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

ll lcm(ll a, ll b)
{
   ll g = gcd(a, b);
   ll ans = (a * b) / g;
   return ans;
}

///palindrome check!
bool palindrome(string s)
{
   for (ll i = 0; i < s.length() / 2; i++)
   {
      if (s[i] != s[s.length() - i - 1])
         return 0;
   }
   return 1;
}
/// divisors->>
void printDivisors(int n)
{
   for (int i = 1; i <= sqrt(n); i++)
   {
      if (n % i == 0)
      {
         if (n / i == i)
            printf("%d ", i);

         else
            printf("%d %d ", i, n / i);
      }
   }
}

///prime storage>>>

vector<ll> prime;

void primes(ll m)
{

   bool isprime[m];
   for (int i = 0; i <= m; i++)
      isprime[i] = true;

   for (int i = 3; i * i <= m; i++)
   {
      if (isprime[i])
      {

         for (int j = i * i; j <= m; j += i)
            isprime[j] = false;
      }
   }
   prime.push_back(2);
   for (int i = 3; i <= m; i += 2)
      if (isprime[i])
         prime.push_back(i);
}

/************MAIN_FUNCTION***********/

int main(int argc, char *argv[])
{
   FAST;

   ll m;
   cin >> m;

   int c = 0;
   ll muldhon = 100;
   while (muldhon < m)
   {
      muldhon += (muldhon / 100);
      c++;
   }
   cout << c << endl;

   return 0;
}

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

int main()
{
	long long X, Y;
	cin >> X >> Y;

	long long temp = X;
	long long count = 1;

	for (long long loop = 2; loop < Y; ++loop) {
		temp = temp * loop;

		if (temp <= Y) {
			++count;
			--loop;
		} else {
			break;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>

int main(void) {
  int n;
  int i;
  int x;

  scanf("%d", &n);
  
  for (i = 3; i <= n; i++) {
    x = i;
    if (i % 3 == 0)
      printf(" %d", i);
    else
      while(1) {
	if (x == 0)
	  break;
	if(x % 10 == 3) {
	  printf(" %d", i);
	  break;
	}
	x /= 10;
      }
  }
  printf("\n");
  

  return 0;
}



Measured memory_bytes: 1928
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL INF=1<<29;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{ int N,A,B;
  scanf("%d%d%d",&N,&A,&B);
  if(N*A>B)
  {
   printf("%d",B);
  }
  else
  {
    printf("%d",N*A);
  }
    return 0;
    }

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, x[100000];
int num[100001], sum[100000], odd[100000];

int main() {
	scanf("%d%d", &n, &m);
	inc(i, n) { scanf("%d", &x[i]); }
	
	inc(i, n) { num[ x[i] ]++; }
	
	incII(i, 1, 100000) {
		sum[i % m] += num[i];
		odd[i % m] += num[i] % 2;
	}
	
	int ans = 0;
	incII(i, 0, (m / 2)) {
		int mi = (odd[i] < odd[(m - i) % m] ? i : (m - i) % m);
		int ma = (odd[i] < odd[(m - i) % m] ? (m - i) % m : i);
		
		if(mi == ma) { ans += sum[mi] / 2; continue; }
		
		if(sum[mi] >= odd[ma]) { ans += (sum[mi] + sum[ma]) / 2; }
		else { ans += sum[mi] + (sum[ma] - odd[ma]) / 2; }
		
		// printf("<%d, %d>: ans = %d\n", mi, ma, ans);
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>v;
    for (int i = 0; i < n; i++) {
        int z;
        cin >> z;
        z--;
        v.push_back(z);
    }
    int now = 0, c = 0;
    for (;;)
    {
        if (now == 1) {
            cout << c << endl;
            break;
        }
        if (c >= n) {
            cout << -1 << endl;
            break;
        }
        c++;
        now = v[now];
    }
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define VL vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define what(A) cout<<#A<<" is "<<A<<endl;
int main()
{
    fastio
        ll l = 0;
        ll test = 1;
    //cin >> test;
    while (test--)
    {
        ll n,k;
        cin>>n>>k;
        ll a[n];
        FOR(i,0,n)
        {
            cin>>a[i];
        }
        FOR(i,0,n-k)
        {
            if(a[i]<a[i+k])
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int q,K;
char f[1000005];
vector<int>posc;
vector<ll>rui_m;
int main(){
	scanf("%d%s",&n,&f);
	cin>>q;
	int cur_m = 0;
	for(int i=0;i<n;i++){
		if(f[i] == 'C'){
			posc.pb(i);
			if(rui_m.empty()) rui_m.pb(cur_m);
			else rui_m.pb(rui_m[rui_m.size()-1]+cur_m);
		}
		else if(f[i] == 'M') cur_m++;
	}
	while(q--){
		cin>>K;
		int nxt = 0;
		int nxt2 = 0;
		ll ans = 0;
		int curm=0;
		for(int i=0;i<n;i++){
			if(f[i] == 'D'){
				int L = i+1, R = i+K-1;
				if(R >= n) R = n-1;
				while(nxt != posc.size() && posc[nxt] < L) nxt++;
				while(nxt2 != posc.size() && posc[nxt2] <= R ) nxt2++;
				//[nxt,nxt2)
				ll dif = 0;
				if(nxt2) dif = rui_m[nxt2-1];
				if(nxt) dif -= rui_m[nxt-1];
				dif -= 1LL*curm*(nxt2-nxt);
				ans += dif;
			}
			else if(f[i] == 'M') curm++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 14556
S = input()
min = 10000
S = [int(S[i]) for i in range(len(S))]
for i in range(len(S)-2):
  num = S[i]*100+S[i+1]*10+S[i+2]
  tmp = abs(753-num)
  if(tmp < min):
    min = tmp
print(min)

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

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

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  let c = read::<i64>();
  let x = read::<i64>();
  let mut cnt = 0;

  for i in 0..a + 1 {
    for j in 0..b + 1 {
      for n in 0..c + 1 {
        if i * 500 + j * 100 + n * 50 == x {
          cnt += 1;
        }
      }
    }
  }

  println!("{}", cnt);
}


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

#define FOR(i,start,end) for(int i=start; i<(int)(end); i++)
#define REP(i,n) FOR(i,0,n)

int main() {

    int i=1, input;

    while(1) {
        scanf("%d", &input);
        if(input == 0) {
            break;
        }
        printf("Case %d: %d\n", i, input);
        i += 1;
    }

    return 0;
}



Measured memory_bytes: 3108
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

LL X, Y;

int main()
{
	while(scanf("%lld %lld", &X, &Y) != EOF)
	{
		if(X == Y || Y == 1 || (X % Y == 0) ) printf("-1\n");
		else {
			LL ans = 0;
			for(LL i = 2; ; i++) {
				LL tmp = X * i;
				if(tmp % Y != 0) {
					ans = tmp;
					break;
				}
				if(tmp > INF) {
					ans = -1;
					break;
				}
			}
			printf("%lld\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll n, x, t;
	cin>>n>>x>>t;
	ll a = (n/x) + (n%x > 0);
	cout<<a*t<<endl;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main()
{
	int a[3],t,k,keep;

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

	for(t=0;t < 3;t++){
		for(k=t;k < 3;k++){
			if(a[t] > a[k]){
				keep = a[t];
				a[t] = a[k];
				a[k] = keep;
			}
		}
	}


	printf("%d %d %d\n",a[0],a[1],a[2]);

	return 0;
}

Measured memory_bytes: 596
import numpy as np

n, q = map(int, input().split())
s = input()

# 'AC'が登場した回数
A = [0] * (n + 1)
for i in range(n):
    if s[i:i + 2] == 'AC':
        A[i] = 1

S = [0] * (n + 2)
S[1:] = np.cumsum(A)

for i in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    print(S[r] - S[l])


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  long n; cin >> n;
  vector <int> ans;
  while (n > 0){
    ans.push_back((n - 1) % 26);
    n -= ans.back() + 1; n /= 26;  
  }
  reverse(all(ans));
  for (int x : ans) cout << (char)(x + 'a');
  return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
 
int main() {
    int n;
    int a[100100];
    cin>>n;
    vector<pair<int,int> >v;
    REP(i,n){
        cin>>a[i];
        v.PB(MP(a[i],i+1));
    }
    sort(v.begin(),v.end());
    REP(i,v.size()){
        cout<<v[i].second;
        if(i==n-1)cout<<endl;
        else cout<<" ";
    }
}

Measured memory_bytes: 2164
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,K = inpl()
ans = 0
S = input()
for i in range(1,N):
    if S[i] == S[i-1]:
        ans += 1

print(min(ans+K*2,N-1))


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;
using i64 = int64_t;

constexpr i64 INF = 1010000000000000017LL;

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(int i=(int)(start);i<(int)(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(int i=(int)(start);i>(int)(end);--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;

#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >

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

template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  int D;
  cin >> D;

  v(int) C(26);
  cin >> C;

  v(v(int)) S(D, v(int)(26));
  cin >> S;

  v(int) T(D);
  v(int) X(26, 0);

  rep(i, D) {
    i64 tmp = 0;
    rep(j, 26) {
      if(S[i][j] + C[j] * (X[j] + 1) > tmp) {
        T[i] = j + 1;
        tmp = S[i][j] + C[j] * (X[j] + 1);
      }
    }
    cout << T[i] << "\n";
    rep(j, 26) {
      if(T[i] - 1 == j){
        X[j] = 0;
      }
      else{
        X[j]++;
      }
    }
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  Main();
}

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

int main() {
    int a,b;
    cin>>a>>b;
    int counter=0;
    
    for(int i=a; i<=b; i++){
        int temp1 = (i%100000)/10000;
        int temp2 = (i%10000)/1000;
        //int temp3 = (i%1000)/100;
        int temp4 = (i%100)/10;
        int temp5 = (i%10)/1;

        if(temp1==temp5 and temp2==temp4){
            counter++;
        }
    }
    
    cout<<counter<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a =new int[3];
		int A = sc.nextInt();
		int B = sc.nextInt();

		int answer =0;

		a[0] = A + (A-1);
		a[1] = A + B;
		a[2] = B + B-1;
		for (int i=0; i<3; i++) {
			answer = Math.max(answer, a[i]);
		}
		System.out.print(answer);
	}

}


Measured memory_bytes: 23636
import sys
input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np


def main():
	k=II()
	s=input()

	if len(s)<=k+1:
		print(s)
	else:
		print(s[:k]+"...")
















if __name__ == "__main__":
	main()


Measured memory_bytes: 9196
#Knapsak 2
N, W = map(int, input().split())

w = [0] * (N + 1)
v = [0] * (N + 1)

for i in range(1, N + 1):
    w[i], v[i] = map(int, input().split())
    
INF = 1000000010
MAX_V = 100010 #NVの最大
dp = [[INF] * (MAX_V + 1) for _ in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    for value in range(MAX_V):
        if value >= v[i]:#入れられる可能性があるかどうか
#ある場合は、直前にvalueがvalue-v[i]の場合の重さ最小値にw[i]を加えたものと比較
            dp[i][value] = min(dp[i][value], dp[i - 1][value-v[i]] + w[i])
#dp[i][value] = i-1番目までの品から価値がvalue以上になるように選んだ時の重さの最小値
        dp[i][value] = min(dp[i-1][value], dp[i][value])
    
ans = 0
for i in range(MAX_V+1):
    if dp[N][i] <= W:
        ans = i
print(ans)

Measured memory_bytes: 121196
#include <stdio.h>

int main()
{
   int a,b,c;
   scanf ("%d %d %d",&a,&b,&c);
   if (a<b<c && a<b && b<c && a<c){
       printf ("Yes\n");
   }else { 
       printf ("No\n");
   }

    return 0;
}



Measured memory_bytes: 2080
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

bool prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  vector<int> a;
  for (int i = 7; i <= 55555; ++i) {
    if (i % 5 == 1 && prime(i)) {
      a.push_back(i);
    }
  }
  // cout << a.size() << endl;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import math

A, B, H, M = map(int,input().split())

longdeg = (2 * math.pi) / 12 * (H + M/60)
shortdeg = (2 * math.pi) * M / 60

deg = abs(longdeg - shortdeg)

if deg > math.pi:
    deg = 2 * math.pi - deg

print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(deg)))

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

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

    int N;
    cin >> N;
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        V[a - 1] = i + 1;
    }
    for (int i = 0; i < N; i++) {
        if (i > 0) cout << " ";
        cout << V[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {
         if (n == r){dp[n][n] = 1;}
	else if (r == 0) {return dp[n][0] = 1;}
	else if (r == 1) {return dp[n][1]=n;}
	else {dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
	return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;}
}
//stack
// stack int top, S[1000];stack
// stack void push(int x) {	S[++top] = x;}stack
// stack int pop() {	top--;	return S[top + 1];}stack

//queue
typedef struct pp { char name[100];int t; }P;
P Q[LEN];
int head, tail, n;
void enqueue(P x) { Q[tail] = x;tail = (tail + 1) % LEN; }
P dequeue() {P x= Q[head] ;head =( head + 1) % LEN;return x; }
int min(int a, int b) { return a < b ? a : b; }



int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	cin >> n >> q;
		
	for (i = 1;i <=n;i++) {
		cin >> Q[i].name;
		cin >> Q[i].t;
	}
	head = 1;tail = n + 1;

	while (head != tail) {
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if (u.t > 0)enqueue(u);
		else { cout << u.name << " " << elaps << endl; }
	}
	return 0;
}


Measured memory_bytes: 13248
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	int ans = (N - 1) / 2;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 50;

void solve(long long N, long long M, long long L, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, long long Q, std::vector<long long> s, std::vector<long long> t){
    vector<vll> d(N, vll(N, INF)), gas(N, vll(N, INF));
    rep(i, M){
        d[A[i]-1][B[i]-1] = C[i];
        d[B[i]-1][A[i]-1] = C[i];
    }
    rep(i, N){
        d[i][i] = 0;
        gas[i][i] = 0;
    }
    rep(k, N){
        rep(i, N){
            rep(j, N){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    rep(i, N){
        rep(j, N){
            if(d[i][j]<=L)
                gas[i][j] = 1;
        }
    }
    rep(k, N){
        rep(i, N){
            rep(j, N){
                gas[i][j] = min(gas[i][j], gas[i][k]+gas[k][j]);
            }
        }
    }
    rep(i, Q){
        ll dist = gas[s[i]-1][t[i]-1];
        if(dist >= INF)
            cout << -1 << endl;
        else
            cout << dist -1 << endl;
    }

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long L;
    scanf("%lld",&L);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> s(Q);
    std::vector<long long> t(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&t[i]);
    }
    solve(N, M, L, std::move(A), std::move(B), std::move(C), Q, std::move(s), std::move(t));
    return 0;
}


Measured memory_bytes: 4352
#include<stdio.h>

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

  for(i=100;i>=1;i--){
    if( (a%i == 0) && (b%i == 0) ){
      cnt++;
      x=i;
    }

    if(cnt>=c){
      printf("%d\n",x );
      break;
    }

  }
  return 0;
}


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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

LL binpow(LL x, LL p, LL m) {
	LL res = 1;
	while (p) {
		if (p%2) {
			res *= x;
			res %= m;
		}
		p>>=1;
		x *= x;
		x %= m;
	}
	return res;
}

int main()
{
	LL n, k;
	cin >> n >> k;

	LL g[k+1];

	for (LL i = 0; i < k+1; ++i) {
		g[i] = 0;
	}

	g[1] = 1;

	for (LL i = 2; i <= k; ++i) {
		LL cnt = 1;
		for (LL j = 2; j*j <= i; ++j) {
			if (i % j == 0) {
				if (j*j == i) {
					cnt += g[j];
				}
				else {
					cnt += g[j]+g[i/j];
				}
			}
		}
		g[i] = i-cnt;
	}
	
	LL sum = 0;
	for (LL i = 1; i <= k; ++i) {
		sum += ((binpow(k/i, n, mod)*g[i])%mod);
		sum %= mod;
	}
	cout << sum << "\n";
}


Measured memory_bytes: 4372
#include <iostream>

using namespace std;

long long merge_sort(int *a, int l, int r)
{
    if (l == r - 1)
	return a[l] > a[r] ? (swap(a[l], a[r]), 1) : 0;
    else if (l == r)
	return 0;

    int mid = (l + r) / 2;
    long long cnt = 0;
    cnt += merge_sort(a, l, mid);
    cnt += merge_sort(a, mid + 1, r);

    int i = l, j = mid + 1, k = 0, ln = mid - l + 1, rn = r - mid + 1;
    int b[r - l + 1];
    while (i <= mid && j <= r) {
	if (a[i] < a[j]) {
	    b[k++] = a[i++];
	    ln--;
	}
	else {
	    b[k++] = a[j++];
	    cnt += ln;
	    rn--;
	}
    }
    while (i <= mid)
	b[k++] = a[i++];
    while (j <= r)
	b[k++] = a[j++];

    for (i = 0; i <= r - l; i++)
	a[l + i] = b[i];

    return cnt;
}


int main(void)
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
	cin >> a[i];

    cout << merge_sort(a, 0, n - 1) << endl;
    
    return 0;
}

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

using namespace std;

const int N = 105;

int n, m, a[N][N], S[N][N], f[N][N];
int X, Y, _n, _m, ans;

#define query(x, y, z, w) (S[z][w] + S[x][y] - S[x][w] - S[z][y])

void init() {
    char ch;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            scanf(" %c", &ch);
            if(ch == 'o') a[i][j] = 1;
            if(ch == 'E') X = i, Y = j;
        }
    }
    if(X - 1 > n - X) {
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                if(i > n + 1 - i) swap(a[i][j], a[n + 1 - i][j]);
        X = n + 1 - X;
    }
    if(Y - 1 > m - Y) {
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                if(j > m + 1 - j) swap(a[i][j], a[i][m + 1 - j]);
        Y = m + 1 - Y;
    }
    for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) S[i][j] = a[i][j];
    for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) S[i][j] += S[i][j - 1];
    for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) S[i][j] += S[i - 1][j];
    _n = n - (X - 1) - (X - 1);
    _m = m - (Y - 1) - (Y - 1);
    for(int x = 0; x < X; x++)
        for(int y = 0; y < Y; y++) {
            f[0][1] = query(x, y, X + x - 1, Y + y); // (i, j) -> (i + X + x - 1, j + Y + y - 1);
            f[1][0] = query(x, y, X + x, Y + y - 1);
            for(int i = 1; i <= _n; i++) 
                for(int j = 1; j <= _m; j++) {
                    f[i][j] = max(
                        query(i - 2 + X + x, j - 1 + y, i - 1 + X + x, j - 1 + Y + y) + f[i - 1][j] ,
                        query(i - 1 + x, j - 2 + Y + y, i - 1 + X + x, j - 1 + Y + y) + f[i][j - 1]
                    ); 
                }
            ans = max(ans, f[_n][_m]);
        }
    cout << ans << endl;
    /*
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) printf("%d ", query(i - 1, j - 1, i, j));
        printf("\n");
    }
    printf("%d %d\n", X, Y);
    */
}

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

Measured memory_bytes: 384