akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)

const int M = 1000000007;
const int N = 2e5 + 5;
const long long INF = 1e9 + 12;

vector<double> v;
vector<vector<double> > dp;
int n;

void solve(){
    cin >> n;
    v.resize(n+1);
    dp.resize(n+1, vector<double>(n+1,0));
    for(int i=1; i<=n; i++){
        cin >> v[i];
    }
    for(int i=1; i<=n; i++) dp[0][i] = 0;
    dp[0][0] = 1;
    double ans = 0.0;
    for(int i=1; i<=n; i++){
        for(int j=0; j<=n; j++){
            dp[i][j] = (j>0? dp[i-1][j-1]*v[i]: 0) + dp[i-1][j]*(1.0 - v[i]);
        }
    }
    for(int j=(n+1)/2; j<=n; j++){
        ans+=dp[n][j];
    }
    setpre(12) << ans;
}

signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}


Measured memory_bytes: 73628
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 998244353;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;
using mint = static_modint<mod>;

struct S {
    mint a;
    int size;
};

S op(S a, S b) {
    return S{a.a+b.a, a.size+b.size};
}

S e() {
    return S{mint(0), (int)0};
}

struct F {
    mint a;
    mint b;
};

S mapping(F f, S s) {
    return S{f.a*s.a+f.b*s.size, s.size};
}

F composition(F a, F b) {
    return F{a.a*b.a, a.a*b.b+a.b};
}

F id() {
    return F{mint(1), mint(0)};
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, q;
    cin >> n >> q;
    vector<S> a(n);
    rep(i, n) {
        int x;
        cin >> x;
        a[i] = S{mint(x), 1};
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
    rep(qi, q) {
        int t;
        cin >> t;
        if (t==0) {
            int l, r, b, c;
            cin >> l >> r >> b >> c;
            seg.apply(l, r, F{b, c});
        }
        if (t==1) {
            int l, r;
            cin >> l >> r;
            S ans = seg.prod(l, r);
            pr(ans.a.val());
        }
    }
    return 0;
}


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

vector <int> a[100005];
bool b[100005];
int f[100005];
int n,m;


void inp()
{
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int u,v;
        cin >> u >>v;
        a[v].push_back(u);
    }
}


int tryyy(int u)
{
    if (a[u].size() == 0) return 1;
    if (b[u]) return f[u];
    int tmp = 0;
    for (int v : a[u])
    {
        tmp = max(tmp,tryyy(v)+1);
    }
    b[u] = true;
    f[u] = tmp;
    return tmp;
}


void proc()
{
    int ans = 1;
    for (int i = 1; i <= n; i++)
    {
        ans = max(ans,tryyy(i));
    }
    cout << ans-1;
}



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


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
const int N=500010,mod=19260817,qs=19491001;
#define ull unsigned long long
char c[N];
int n;
unsigned long long h[N],qp[N];
unsigned int h1[N],qp1[N];
ull gh(int l,int r)
{
	return (h[r]-1ll*h[l-1]*qp[r-l+1]%qs+qs)%qs;
}
unsigned int gh1(int l,int r)
{
	return (h1[r]-1ll*h1[l-1]*qp1[r-l+1]%mod+mod)%mod;
}
int len[N],len1[N];
int main()
{
	scanf("%s",c+1);
	n=strlen(c+1);
	qp[0]=1;
	for(int i=1;i<=n;i++)
		h[i]=1ll*h[i-1]*mod%qs+c[i]-'a'+1,h1[i]=1ll*h1[i-1]*qs%mod+c[i]-'a'+1;
	qp1[0]=1;
	for(int i=1;i<=n;i++)
		qp[i]=1ll*qp[i-1]*mod%qs,qp1[i]=1ll*qp1[i-1]*qs%mod;
	for(int i=1;i<=n/2;i++)
		if(!len[i*2] && gh(1,i)==gh(i+1,i*2) && gh1(1,i)==gh1(i+1,i*2))
		{
			len[i*2]=i;
			ull p=gh(1,i);
			unsigned int q=gh1(1,i);
			for(int j=i*3;j<=n;j+=i)
				if(gh(j-i+1,j)==p && gh1(j-i+1,j)==q)
					len[j]=i;
				else
					break;
		}
	for(int i=1;i<=n/2;i++)
		if(!len1[n-i*2+1] && gh(n-i+1,n)==gh(n-2*i+1,n-i) && gh1(n-i+1,n)==gh1(n-2*i+1,n-i))
		{
			len1[n-i*2+1]=i;
			ull p=gh(n-i+1,n);
			unsigned int q=gh1(n-i+1,n);
			for(int j=i*3;j<=n;j+=i)
				if(gh(n-j+1,n-j+i)==p && gh1(n-j+1,n-j+i)==q)
					len1[n-j+1]=i;
				else
					break;
		}
	if(len[n]==1)
	{
		printf("%d\n1\n",n);
		return 0;
	}
	if(!len[n])
	{
		printf("1\n1\n");
		return 0;
	}
	int ans=0;
	for(int i=1;i<n;i++)
		if(!len[i] && !len1[i+1])
			ans++;
	printf("2\n%d\n",ans);
	return 0;
}


Measured memory_bytes: 16384
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
C = Counter(A)
ans = sum(A)

for _ in range(Q):
    b, c = map(int, input().split())
    ans += c*C[b] - b*C[b]
    C[c] += C[b]
    C[b] = 0
    print(ans)

Measured memory_bytes: 23996
import sys
input=sys.stdin.readline
n=int(input())
h=list(map(int,input().split()))
m=0
ans=0
for i in range(n):
  if h[i]>=m-1:
    ans=1
    m=max(m,h[i])
  else:
    ans=0
    break

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

Measured memory_bytes: 14252
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long n = Long.parseLong(in.next());
            long ans = 0;

            ans = (n - 1) * n / 2;
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 22740
from collections import defaultdict
from bisect import bisect_left

S = input().rstrip()
T = input().rstrip()

LS = len(S)
index = defaultdict(list)

for i, s in enumerate(S):
  index[s].append(i)
  
x = -1
for t in T:
  arr = index[t]
  if len(arr) == 0:
    print(-1)
    exit()
  y = (x+1)%LS
  i = bisect_left(arr, y)
  if i < len(arr):
    next_x = (x+1) + arr[i] - y
  else:
    next_x = (x+1) + arr[0] + LS - y
  x = next_x
ans = x+1
print(ans)

Measured memory_bytes: 8044
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
long long gcd(long long a,long long b){
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int main(){
	int N,X;
	cin>>N>>X;
	vint A;
	A.pb(X);
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	sort(A.begin(),A.end());
	int G=0;
	for(int i=0;i<N;i++){
		int a=A[i+1]-A[i];
		G=gcd(G,a);
	}
	cout<<G<<endl;
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void){
    int i,j,n,w,kazu[30],a,b;
    cin >> w;
    cin >> n;
    for(i=0;i<30;i++){
        kazu[i]=i+1;
    }
    for(i=0;i<n;i++){
        scanf("%d,%d",&a,&b); 
        swap(kazu[a-1],kazu[b-1]);
    }
    for(i=0;i<w;i++){
        cout << kazu[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
using namespace std;
 
int main(void)
{
    int H, W;
    cin >> H >> W;
    vector<string> A(H);

    REP(i, H)
        cin >> A[i];
    
    vector<vector<int>> dp(H, vector<int>(W, H * W));

    REP(i, H) REP(j, W) {
        if (A[i][j] == '#')
            dp[i][j] = 0;
    }
    REP(i, H) REP (j, W){
        if (i > 0)
            dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
        if (j > 0)
            dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
    }
    RREP(i, H) RREP (j, W){
        if (i < H - 1)
            dp[i][j] = min(dp[i][j], dp[i + 1][j] + 1);
        if (j < W - 1)
            dp[i][j] = min(dp[i][j], dp[i][j + 1] + 1);
    }

    int ans = 0;
    REP(i, H) REP(j, W) {
        ans = max(ans, dp[i][j]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5248
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,m,i,j,k,u,mat[305][305],ans=0;
ll mod=998244353; 
ll pow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)scanf("%lld",&mat[i][j]);
	for(i=1;i<=m;i++)
	{
		for(j=ans+1;j<=n;j++)
		{
			if(mat[j][i])
			{
				ans++;
				for(k=j+1;k<=n;k++)if(mat[k][i])for(u=i;u<=m;u++)mat[k][u]=mat[k][u]^mat[j][u];
				for(k=i;k<=m;k++)swap(mat[j][k],mat[ans][k]);
				break;
			}
		}
	}
	printf("%lld\n",(pow(2LL,m+n-1)-pow(2LL,m-ans+n-1)+mod)%mod);
	return 0;
}

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

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

  if(a<b){
    cout << "a < b" << endl;
  }else if(a>b){
    cout << "a > b" << endl;
  }else{
    cout << "a == b" << endl;
  }

  return 0;
}

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

int main()
{
	//freopen("input16.txt","r",stdin);freopen("output16.txt","w",stdout);
	ll n,k,t;
	cin>>n>>k;
	t=k*pow(k-1,n-1);
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
using System;

class MyClass
{
    static void Main(string[] args)
    {
        int z;
        while ((z = int.Parse(Console.ReadLine())) != 0)
        {
            int max = 0;
            for (int x = 1; x < z; x++)
            {
                for (int y = 1; y < z; y++)
                {
                    int k = x * x * x + y * y * y;
                    if (k <= (z * z * z) && max < k)
                    {
                        max = k;
                    }
                }
            }
            Console.WriteLine(z * z * z - max);
        }
    }
}


Measured memory_bytes: 5596
#include <iostream>
#define NMAX 10000
#define QMAX 500
using namespace std;

void solve (int *S, int n, int *T, int q, int *c) {
    for (int i=0; i<q; i++) {
        for (int ii=0; ii<n; ii++) {
            if ( T[i] == S[ii] ) {
                *c += 1;
                break;
            }
        }
    }
}

int main () {
    // input
    int n;
    cin >> n;
    int S[NMAX];
    for (int i=0; i<n; i++) {
        cin >> S[i];
    }
    int q;
    cin >> q;
    int T[QMAX];
    for (int i=0; i<q; i++) {
        cin >> T[i];
    }
    // solve
    int c = 0;
    solve (S, n, T, q, &c);
    // output
    cout << c << endl;
}


Measured memory_bytes: 3096
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K;
	cin >> N >> K;

	vector<pii> A(N);
	rep(i, 0, N)
	{
		cin >> A[i].first >> A[i].second;
	}

	int ans = 0;
	int p = 0;

	rrep(i, 0, 32)
	{
		if ((K >> i) & 1)
		{
			int res = 0;
			rep(j, 0, N)
			{
				bool ok = true;
				rrep(k, i + 1, 32)
				{
					if (((A[j].first >> k) & 1) && !((K >> k) & 1))
					{
						ok = false;
					}
				}
				if ((A[j].first >> i) & 1)
				{
					ok = false;
				}
				if (ok)res += A[j].second;
			}

			chmax(ans, res);
		}
	}

	int res = 0;

	rep(j, 0, N)
	{
		bool ok = true;
		rrep(k, 0, 32)
		{
			if (((A[j].first >> k) & 1) && !((K >> k) & 1))
			{
				ok = false;
			}
		}
		if (ok)res += A[j].second;
		chmax(ans, res);
	}

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

Measured memory_bytes: 4768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;


class Unionfind{
public:
    vector<int> oya;
    Unionfind(int N){
        oya=vector<int>(N,-1);        
    }

    int root(int x){
        if(oya[x]<0) return x;
        return oya[x]=root(oya[x]);
    }

    int size(int x){
        return -oya[root(x)];
    }

    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(size(x)<size(y)) swap(x,y);
        oya[x]+=oya[y];
        oya[y]=x;
        return true;
    }
};

int main(){
    int N,M;   
    cin>>N>>M;
    vector<int> a(M),b(M);
    for(int i=0;i<M;i++) {
        cin>>a[i]>>b[i];
        a[i]--; b[i]--;
    }
    vector<long long> ans(M);    
    ans[M-1]=(long long)N*(N-1)/2;
    
    Unionfind island(N);
    
    for(int i=M-1;i>=1;i--){
        if(island.root(a[i]) != island.root(b[i])){
            ans[i-1]=ans[i]-(long long)island.size(a[i])*island.size(b[i]);
            island.unite(a[i],b[i]);
        }
        else ans[i-1]=ans[i];
    }
    
    for(int i=0;i<M;i++) cout<<ans[i]<<endl; 
    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
const int MAXN=200005,MAXA=8010,ZERO=2003,MOD=1000000007;

int PowMod(int a,int b)
{
    int ret=1;
    while(b)
    {
        if(b&1)
            ret=1LL*ret*a%MOD;
        a=1LL*a*a%MOD;
        b>>=1;
    }
    return ret;
}

int fac[MAXA],ifac[MAXA];

void Init()
{
    fac[0]=1;
    for(int i=1;i<MAXA;i++)
        fac[i]=1LL*fac[i-1]*i%MOD;
    ifac[MAXA-1]=PowMod(fac[MAXA-1],MOD-2);
    for(int i=MAXA-2;i>=0;i--)
        ifac[i]=1LL*ifac[i+1]*(i+1)%MOD;
}

int N;
int A[MAXN],B[MAXN];
int dp[MAXA/2][MAXA/2];

int main()
{
    Init();
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
    {
        scanf("%d%d",&A[i],&B[i]);
        dp[ZERO-A[i]][ZERO-B[i]]++;
    }
    for(int i=1;i<MAXA/2;i++)
        for(int j=1;j<MAXA/2;j++)
            dp[i][j]=((dp[i][j]+dp[i][j-1])%MOD+dp[i-1][j])%MOD;
    int ans=0;
    for(int i=1;i<=N;i++)
        ans=(ans+dp[ZERO+A[i]][ZERO+B[i]])%MOD;
    for(int i=1;i<=N;i++)
        ans=(ans-1LL*fac[2*(A[i]+B[i])]*ifac[2*A[i]]%MOD*ifac[2*B[i]]%MOD)%MOD;
    ans=(ans+MOD)%MOD;
    ans=1LL*ans*PowMod(2,MOD-2)%MOD;
    printf("%d\n",ans);

    return 0;
}



Measured memory_bytes: 64384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    string s, t;
    cin >> s >> t;
    ll ssize = s.size();
    s += s;
    vector<vector<ll>>z(26, vector<ll>(ssize,-1));
    for (int i = 0; i < 26; i++) {
        ll ima = 0;
        for (ll j = 0; j < s.size(); j++) {
            if (s[j] - 'a' == i) {
                for (int k = ima; k < min(j,ssize);k++) {
                    z[i][k] = j-k;
                }
                ima = j;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < t.size(); i++) {
        if (z[t[i] - 'a'][(ans-1+ssize) % ssize] == -1) {
            ans = -1;
            
            break;
        }
        ans += z[t[i] - 'a'][(ans - 1 + ssize) % ssize];
    }
    cout << ans << endl;
}

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

int main() {
	long long N;
	cin >> N;
	for (int i = 0; i <= N; i++) {
		if ((int)((double)(i) * 1.08) == N) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b = list(map(str, readline().rstrip().decode('utf-8').split()))
    if a * int(b) < b * int(a):
        print(a * int(b))
    else:
        print(b * int(a))


if __name__ == '__main__':
    solve()


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

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n, m, t, a[MAX];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        scanf("%d", &t);
        int x;
        for(int j = 1; j <= t; j++){
            scanf("%d", &x);
            a[x] += i;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!a[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;

template<class T>
T gcd(T a, T b){
    return b==0 ? a:gcd(b, a%b);
}

int main(){
    int x, y; cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}


Measured memory_bytes: 3128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int i = 0;
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0)
                break;
            for (int y = 0; y < H; y++) {
                int binary = i % 2;
                    i += 1;
                for (int x = 0; x < W; x++) {
                    if (x % 2 == binary) {
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 35324
#include <stdio.h>

int main() {

    int a, b;
    int sum = 0;
    int num = 1;

    scanf("%d %d", &a, &b);

    sum = a;

    for (; sum < b ;) {
        sum += (a - 1);
        num++;
    }
    
    if(b == 1) {
        num = 0;
    }

    printf("%d", num);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string T,S;

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

  cin >> S >> T;

  cout << T+S << "\n";
  return 0;
}

Measured memory_bytes: 256
s = input()
k = int(input())
x = set()
n = len(s)
for i in range(k):
    for j in range(n-i):
        t = s[j:j+i+1]
        if not t in x:
            x.add(t)
x=list(x)
x.sort()
print(x[k-1])

Measured memory_bytes: 4464
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        ss: [Chars; n]
    };
    let mut vv = vec![vec![0; n]; 26];
    for (index, s) in ss.iter().enumerate() {
        for &c in s {
            vv[((c as u8) - b'a') as usize][index] += 1;
        }
    }
    let mut s = String::new();
    for (index, v) in vv.iter().enumerate() {
        for _ in 0..*v.iter().min().unwrap() {
            s.push((b'a' + index as u8) as char);
        }
    }
    println!("{}", s);
}


Measured memory_bytes: 2172
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (register ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (register ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 2e6 + 5 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;
template <class T = int> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

ll n, ans;

ll a[maxn], b[maxn], suma, sumb;

pair <ll, pair <ll, ll> > c[maxn];

ll pre[maxn];

ll rnka[maxn], rnkb[maxn];

signed main()
{
	scanf("%lld", &n);
	rep(i, 1, n) scanf("%lld %lld", &a[i], &b[i]), suma += a[i], sumb += b[i], c[i] = mp(a[i], mp(i, 0)), c[n + i] = mp(b[i], mp(i, 1));
	ans = min(suma,sumb);
	sort(c + 1, c + 2 * n + 1);
	rep(i, 1, 2 * n) pre[i] = pre[i - 1] + c[i].fi;
	rep(i, 1, n)
	{
		rnka[i] = lb(c + 1, c + n + n + 1, mp(a[i], mp(i, 0ll))) - c;
		rnkb[i] = lb(c + 1, c + n + n + 1, mp(b[i], mp(i, 1ll))) - c;
	}
	rep(i, 1, n)
	{
		ll x = rnka[i], y = rnkb[i];
		if(x > y) swap(x, y);
		ll sum = pre[n - 2] + a[i] + b[i];
		if(x <= n - 2)
		{
			sum += c[n - 1].fi;
			sum -= c[x].fi;
			if(y <= n - 1) sum += c[n].fi, sum -= c[y].fi;
		}
		ans = min(ans, sum);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 23552
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const n = nextInt()
    const a = nextIntArray()
    let m = {}
    let maxVal = 0
    for(let val of a){
        if(!m[val]) m[val] = 1
        else m[val]++
        maxVal = Math.max(maxVal, val)
    }
    let cnt = {}

    for(let i = 0; i<= maxVal; i++){
        let curr = m[i] ? m[i] : 0
        let prev = m[i-1]? m[i-1] : 0
        let next = m[i+1]? m[i+1] : 0
        cnt[i] = curr + prev + next
    }
    let ans = 1
    for(let key of Object.keys(cnt)){
        ans = Math.max(ans, cnt[key])
    }
    console.log(ans)
}
Main()


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	string s=readString(),t=readString();
	vi x(s.size(),1),y(t.size(),1);
	REP(i,s.size()){
		x[i]+=(s[i]=='B');
		if(i)x[i]+=x[i-1];
	}
	REP(i,t.size()){
		y[i]+=(t[i]=='B');
		if(i)y[i]+=y[i-1];
	}
	int q=read();
	REP(i,q){
		int a=read()-1,b=read()-1,c=read()-1,d=read()-1;
		int e=x[b];if(a)e-=x[a-1];
		int f=y[d];if(c)f-=y[c-1];
		if(abs(e-f)%3==0)printf("YES\n");
		else printf("NO\n");
	}
}


Measured memory_bytes: 4480
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int n,a[100005],b[100005],c[100005],f[100005][5];

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d %d %d",&a[i],&b[i],&c[i]);
	f[1][1]=a[1];
	f[1][2]=b[1];
	f[1][3]=c[1];
	for(int i=2;i<=n;i++){
		f[i][1]=max(f[i-1][2],f[i-1][3])+a[i];
		f[i][2]=max(f[i-1][1],f[i-1][3])+b[i];
		f[i][3]=max(f[i-1][1],f[i-1][2])+c[i];
	}
	printf("%d",max(f[n][1],max(f[n][2],f[n][3])));
}

Measured memory_bytes: 3328
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	fmt.Println(min(a, b) + min(c, d))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int main() {
    int n;
    char s[105],t[105],str[210];
    cin >> n;

    scanf("%s %s/n",s,t);

    for (int i = 0; i <= (int)(n); i++){
        str[2*i]=s[i];
        str[2*i+1]=t[i];
    }

    printf("%s",str);
}

Measured memory_bytes: 3808
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String b = sc.next();
    if(a<3200){
      System.out.println("red");
    }else{
      System.out.println(b);
    }
  }
}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main()
{
    int a, b;
    std::cin >> a >> b;
    if (a % 2 == 0 && b % 2 == 0 || a % 2 != 0 && b % 2 == 0 || a % 2 == 0 && b % 2 != 0)
    {
        cout << "Even\n" << endl;
    }
    else if (a % 2 != 0 && b % 2 != 0)
    {
        cout << "Odd\n" << endl;
    }
}

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

using namespace std;

int main ()
{
    int a , b , sum , cnt=0;
    scanf("%d%d" , &a , &b);
    for(int i=a ; i<=b ; ++i)
    {
        sum=0;
        int temp=i;
        while(temp != 0)
        {
            int a= temp%10;
            sum = sum*10+a;
            temp /=10;
        }
        if(sum == i) ++cnt;
    }
    printf("%d" , cnt);
}


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

void solve(std::string S) {
    vector<ll> a(S.length() + 1, 0);
    for (ll i = 0; i < S.length(); i++) {
        if (S[i] == '<') {
            a[i + 1] = max(a[i + 1], a[i] + 1);
        }
    }
    for (ll i = S.length() - 1; i >= 0; i--) {
        if (S[i] == '>') {
            a[i] = max(a[i], a[i + 1] + 1);
        }
    }
    cout << accumulate(a.begin(), a.end(), 0LL) << endl;
}

int main() {
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 5252
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i];

  vector<long long> num(N + 1);
  for (int i = 0; i < N; ++i)
    ++num[A[i]];

  long long sum = 0;
  for (int i = 0; i <= N; ++i)
    sum += num[i] * (num[i] - 1) / 2;

  for (int k = 0; k < N; ++k)
    cout << sum - (num[A[k]] * (num[A[k]] - 1) / 2 -
                   (num[A[k]] - 1) * (num[A[k]] - 2) / 2)
         << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
//const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n, m, k;
/******* define variable end *******/
const ll MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++) {
	fac[i] = fac[i - 1] * i % MOD;
	inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
	finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
	if (n & 1)
	  res = res * a % mod;
	a = a * a % mod;
	n >>= 1;
  }
  return res;
}
// 二項係数計算
long long COM(ll n, ll k) {
  if (n < k)
	return 0;
  if (n < 0 || k < 0)
	return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int solve() {
	COMinit();
	cin >> n >> m >> k;
	ll ans = 0;
	for(ll i = 0; i <= k; i++){
		ll anstmp = m * modpow(m-1, n - i - 1, MOD);
		anstmp %= 998244353;
		anstmp *= COM(n-1, i);
		anstmp %= 998244353;
		ans += anstmp;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

int main() {
	clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 237980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
typedef unsigned long long int ull;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a;
  cout <<3*a*a;
}

Measured memory_bytes: 3660
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		
		int ans = 0;
		for(int i = 0; i < s.length();i++) {
			int cnt = 0;
			
			if(s.charAt(i)== 'A' ||s.charAt(i)== 'C' ||s.charAt(i)== 'G' || s.charAt(i)=='T') {
				cnt++;
				for(int j = i+1 ;j < s.length();j++) {
					if(s.charAt(j)== 'A' ||s.charAt(j)== 'C' ||s.charAt(j)== 'G' || s.charAt(j)=='T') {
						cnt++;
					}else {
						//ans = Math.max(ans, cnt);
						break ;
					}
				}
			}
			
			ans = Math.max(ans, cnt);
		}
		System.out.println(ans);
		
		
		
	}

}


Measured memory_bytes: 22612
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string T;
  std::cin >> T;
  std::transform(T.begin(), T.end(), T.begin(), [](const i64& T_i) { return T_i == '?' ? 'D' : T_i; });
  std::cout << T << std::endl;
  return 0;
}

Measured memory_bytes: 3760
import java.util.*;

import static java.lang.System.*;

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

        Map<Integer, Integer> cnts = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();

            int cnt = 1;
            if(cnts.containsKey(a)) {
                cnt += cnts.get(a);
            }

            cnts.put(a, cnt);

        }

        int remove = 0;
        for(Map.Entry entry : cnts.entrySet()){
            int num = (int)entry.getKey();
            int cnt = (int)entry.getValue();

            if(num > cnt){
                remove += cnt;
            } else {
                remove += cnt - num;
            }
        }

        out.println(remove);
    }
}

Measured memory_bytes: 62488
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;



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

	cout << max(10 * a + b + c, max(10*b + a + c, 10*c + a + b)) <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int p;
    int q;
    int r;

    scanf("%d",&p);
    scanf("%d",&q);
    scanf("%d",&r);

    if(p>=q && p>=r){
        printf("%d",q+r);
    }else if(q>=p && q>= r){
        printf("%d",p+r);
    }else{
        printf("%d",p+q);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 500005;
const ll MOD = 1000000007;

/*********************GoodLuck***********************/
int main () {
    IOS();
    int n;
    cin >> n;
    vector<pair<int,int> > vec;
    REP1 (i, n) {
        int a;
        cin >> a;
        vec.emplace_back(a, i);
    }
    sort(vec.begin(), vec.end());

    for (auto v : vec) {
        cout << v.second << " ";
    }
}


Measured memory_bytes: 1780
#include<stdio.h>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int n;
char s[maxn];
int main(){
	scanf("%d",&n);scanf("%s",s);
	int cnt=1;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1])continue;
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<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; }

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const int INF = 1001001001;

int main(){
    int n;
    string s;
    cin >> n >> s;
    char prev = s[0];
    int ans = 1;
    rep(i, n-1) {
        char cur = s[i+1];
        if (cur!=prev) ans++, prev=cur;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#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 erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int h,w;
  cin >> h >> w;
  vstring mass(h);
  rep(i,0,h) cin >> mass[i];
  vint dx = {-1,0,0,1};
  vint dy = {0,-1,1,0};
  bool ans = true;
  rep(i,0,h){
    rep(j,0,w){
      if(mass[i][j] == '#'){
        bool flag = false;
        rep(s,0,4){
          if(0 <= i + dx[s] && 0 <= j + dy[s] && i + dx[s] < h && j + dy[s] < w){
            if(mass[i + dx[s]][j + dy[s]] == '#') flag = true;
          }
        }
        if(!(flag)) ans = false; 
      }
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std; 
int main(void){
    string S,T;
  	cin >> S;
  	cin >> T;
  	int n = S.length();
  	int hoge=0;
  for(int i =0; i<n;i++){
	if(S[i]==T[i]){
      	hoge++;
    }else{
    	break;
    }
  }
  if(hoge == n){
    cout << "Yes";
  }else{
    cout << "No";
}
}

Measured memory_bytes: 3036
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int  i=0;i<n;i++) {
            p[i] = sc.nextInt();
        }
        Arrays.sort(p);
        int half = p.length / 2;
        if (p[half - 1] == p[half]) {
            System.out.println("0");
        } else {
            System.out.println(p[half] - p[half -1]);
        }
    }
}

Measured memory_bytes: 49872
import java.util.Scanner;

class Solver {
    public void Solve() {
        int h = sc.nextInt();
        int n = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        for (int i = 0; i < b.length; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        int dp[] = new int[h + 11111];
        for (int i = 1; i < dp.length; i++) {
            dp[i] = 1_000_000_000;
        }
        for (int i = 0; i < dp.length; i++) {
            for (int j = 0; j < n; j++) {
                if (i - a[j] < 0) {
                    continue;
                }
                dp[i] = Math.min(dp[i], dp[i - a[j]] + b[j]);
            }
        }
        int min = 1_000_000_000;
        for (int i = h; i < dp.length; i++) {
            min = Math.min(min, dp[i]);
        }
        System.out.println(min);
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 27692
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")

#define fi first
#define se second

const int N = 100100;

using namespace std;


int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        ios_base::sync_with_stdio(0);


        long long n;
        cin >> n;
        if(n & 1){
                cout << 0 << "\n";
        } else{
                long long res = 0;
                n /= 2;
                while(n > 0){
                        res += n / 5;
                        n /= 5;
                }
                cout << res << "\n";
        }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    priority_queue<int> q;
    string s;
    while (cin >> s && s != "end") {
        if (s[0] == 'i') {
            int a; cin >> a;
            q.push(a);
        } else {
            cout << q.top() << endl;
            q.pop();
        }
    }
    return 0;
}



Measured memory_bytes: 7056
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())

result = -1
count = 0
unreached = True
reached_list = {}
i = 1
while unreached:
    if reached_list.setdefault(i, 0) == 1:
        unreached = False
    else:
        count += 1
        next_button = a[i-1]
        if next_button == 2:
            result = count
            break
        else:
            reached_list[i] = 1
            i = next_button

print(result)

Measured memory_bytes: 16236
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
using namespace std;
#define MOD 1000000007
ll comb[2010][2010];
int main() {
	ll n, k;
	scanf("%lld %lld", &n, &k);
	ll a = n - k;
	ll b = k;
	comb[1][0] = 1;
	comb[1][1] = 1;
	for (int i = 2; i <= 2000; i++) {
		comb[i][0] = 1;
		for (int j = 1; j <= 2000; j++) {
			comb[i][j] = (comb[i - 1][j - 1] % MOD) + (comb[i - 1][j] % MOD);
			comb[i][j] %= MOD;
		}
	}
	if (n == 1)
		printf("%lld\n", k);
	else {
		for (int i = 1; i <= b; i++) {
			printf("%lld\n", (((comb[b - 1][b - i] % MOD) * (comb[a + 1][i] % MOD)) % MOD));
		}
	}
}

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

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

int main(void) {
    int n, p, max_p = 0, sum = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> p;
        max_p = max(max_p, p);
        sum += p;
    }

    cout << sum - max_p / 2 << "\n";
    return 0;
}


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

int main()
{
    int N, K;
    cin>>N>>K;
    vector<int> A(N-1), B(N-1);
    vector<vector<int>> E(N);
    for (int i=0; i<N-1; i++)
    {
        cin>>A[i]>>B[i];
        A[i]--, B[i]--;
        E[A[i]].push_back(B[i]);
        E[B[i]].push_back(A[i]);
    }

    function<int(int, int, int)> f;
    f = [&](int c, int p, int d) -> int
    {
        int ans = 0;
        for (int e: E[c])
        if (e != p)
            ans += f(e, c, d-1);
        return ans + int(d<0);
    };

    int ans = N;
    if (K%2==0)
        for (int i=0; i<N; i++)
            //cout<<i<<" "<<f(i,-1,K/2)<<endl,
            ans = min(ans, f(i,-1,K/2));
    else
        for (int i=0; i<N-1; i++)
            //cout<<i<<" "<<f(A[i],B[i],K/2)+f(B[i],A[i],K/2)<<endl,
            ans = min(ans, f(A[i],B[i],K/2)+f(B[i],A[i],K/2));
    cout<<ans<<endl;
}


Measured memory_bytes: 512