akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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

	if(m%n==0)
		cout << m/n << endl;
	else
	{
		int ans=1;
		for(int i=1;i<=(m/n);i++)
		{
			if(m%i==0)
				ans=i;
		}
		cout << ans << endl;
	}





}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        count += 1
print(count)


Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b,c;
signed main()
{
	cin>>a>>b;
	if(a<b){
		c=a;
		a=b;
		b=c;
	}
	if(a-b>=2){
		cout<<a*2-1;
	}else{
		cout<<a+b;
	}
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
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);
        BCardGameForTwo solver = new BCardGameForTwo();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCardGameForTwo {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            Arrays.sort(a);
            int alice = 0;
            int bob = 0;
            for (int i = n - 1; i >= 0; i--) {
                if ((n - 1 - i) % 2 == 0) alice += a[i];
                else bob += a[i];
            }
            out.println(alice - bob);
        }

    }
}



Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

void solve()
{
	vector<int> W(10);
	vector<int> K(10);
	for(int i = 0; i < 10; ++i)
	{
		cin >> W[i];
	}
	for(int i = 0; i < 10; ++i)
	{
		cin >> K[i];
	}
	sort(W.begin(), W.end(), greater<int>() );
	sort(K.begin(), K.end(), greater<int>() );
	int sumW = 0;
	int sumK = 0;
	for(int i = 0; i < 3; ++i)
	{
		sumW += W[i];
		sumK += K[i];
	}
	cout << sumW << " " << sumK << endl;
}

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

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N, M; cin >> N >> M;
  vector<pair<int, int>> tmp;
  rep(i, M){
    int a, b;
    cin >> a >> b;
    if(a==1) tmp.push_back({b, a});
    if(b==N) tmp.push_back({a, b});
  }
  sort(tmp.begin(), tmp.end());
  bool can = false;
  rep(i, tmp.size()-1){
    if(tmp[i].first==tmp[i+1].first){
      can = true; break;
    }
  }
  if(can) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] ans = new int[4]; // AC, WA, TLE, RE

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            switch (s) {
                case "AC":  ans[0]++; break;
                case "WA":  ans[1]++; break;
                case "TLE": ans[2]++; break;
                case "RE":  ans[3]++; break;
            }
        }

        System.out.println("AC x " + ans[0]);
        System.out.println("WA x " + ans[1]);
        System.out.println("TLE x " + ans[2]);
        System.out.println("RE  x " + ans[3]);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 48888
# -*- coding: utf-8 -*-

import sys
tmp = input()

if (tmp[0] == tmp[1]) and (tmp[2] == tmp[3]) and (tmp[1] != tmp[3]):
	print("Yes")
	sys.exit()
if (tmp[0] == tmp[2]) and (tmp[1] == tmp[3]) and (tmp[2] != tmp[3]):
	print("Yes")
	sys.exit()
if (tmp[0] == tmp[3]) and (tmp[2] == tmp[1]) and (tmp[1] != tmp[3]):
	print("Yes")
	sys.exit()
print("No")



Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=2e6+5;
const int mod=1e9+7;
int f[N];
char c[N];
ll qpow(ll a,ll n){
	ll re=1;
	while(n>0){
		if(n&1){
			re*=a;
			re%=mod;
		}
		a*=a;
		a%=mod;
		n>>=1;
	}
	return re;
}
int main()
{
	f[0]=1;
	for(int i=1;i<N;i++){
		f[i]=1ll*f[i-1]*i%mod;
	}
	int k;
	scanf("%d",&k); 
	scanf("%s",c+1);
	int len=strlen(c+1);
	int ans=0;
	for(int i=len;i<=len+k;i++){
		ans+=1ll*f[len+k]*qpow(f[len+k-i],mod-2)%mod*qpow(f[i],mod-2)%mod*qpow(25,(len+k-i))%mod;
		ans%=mod; 
	}
	printf("%d",ans);
}


Measured memory_bytes: 12548
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first fi;
#define second se;
using namespace std;
typedef pair<int, int> P;

int d[100010];

signed main(){
    int n, a, b;
    cin >> n;
    rep(i, 0, n){
        cin >> a >> b;
        d[a]++;
        d[b + 1]--;
    }
    rep(i, 1, 100010){
        d[i] += d[i - 1];
    }
    int ans = 0;
    rep(i, 0, 100005){
        if(i <= d[i + 1]) ans = max(ans, i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3884
N = int(input())
H = list(map(int, input().split()))
H = H[::-1]
ans = 'Yes'
for i in range(N-1):
  if H[i+1] - H[i]> 1:
    ans = 'No'
    break
  elif H[i+1] - H[i]> 0:
    H[i+1] = H[i]
print(ans)

Measured memory_bytes: 20588
#include <bits/stdc++.h>
#include<cmath>
#include<cstring>
#define pb              push_back
#define pi              acos(-1.0)
#define loop(i,a,n)     for(int i=a;i<n;i++)
#define rloop(i,n,a)    for(int i=n;i>=a;i--)
#define ll              long long int
#define ff              first
#define ss              second
#define pii             pair<ll,ll>
#define sc1(a)          scanf("%d",&a)
#define sc2(a,b)        scanf("%d %d",&a,&b)
#define sc3(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define all(v)          v.begin(),v.end()
#define ms(a,b)         memset(a,b,sizeof a)
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define fileout         freopen("output.txt","w",stdout)
#define filein          freopen("input.txt","r",stdin)
#define inf             2e9+5
#define Q               int q;cin>>q;while(q--)
#define check           cout<<"HI"<<endl;

//int x[]= {-1,0,0,1};
//int y[]= {0,-1,1,0};

using namespace std;

int main()
{
        int n,m=0;
        cin >> n;

        int a[n+5];
        int b[n+5];

        loop(i,0,n)cin>> a[i];
        loop(i,0,n)cin>> b[i];

        loop(i,0,n) if((a[i]-b[i])>0)m+=a[i]-b[i];
        cout<<m<<endl;
    }














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

const int INF = (1LL<<31)-1;

class RMQ{
private:
    int N;
    vector<int> data;
    vector<int> rdata;
    
    int find(int a, int b, int k, int l, int r){
        if(r <= a || b <= l)
            return -1;
        if(a <= l && r <= b)
            return data[k];
        int x1 = find(a, b, 2*k+1, l, (l+r)/2);
        int x2 = find(a, b, 2*k+2, (l+r)/2, r);
        
        if(x1 == -1)
            return x2;
        if(x2 == -1)
            return x1;
        if(rdata[x1] < rdata[x2])
            return x1;
        else
            return x2;
    }
    
public:
    RMQ(vector<int> vec){
        N = 1;
        while(N < vec.size())
            N <<= 1;
        data.assign(2*N-1, -1);
        rdata.assign(N, INF);
        
        for(int i=0; i<vec.size(); i++){
            data[i+N-1] = i;
            rdata[i] = vec[i];
        }
        for(int p=N-2; p>=0; p--){
            if(rdata[data[p*2+1]] < rdata[data[p*2+2]])
                data[p] = data[p*2+1];
            else
                data[p] = data[p*2+2];
        }
    }
    int find(int a, int b){
        return find(a, b, 0, 0, N);
    }
};

void euler_tour(vector<vector<int>> &G, int u, int d, vector<int> &tour, vector<int> &depth){
    tour.push_back(u);
    depth.push_back(d);
    for(auto v: G[u]){
        euler_tour(G, v, d+1, tour, depth);
        tour.push_back(u);
        depth.push_back(d);
    }
}

int main(){
    int N; cin >> N;
    vector<vector<int>> G(N);
    
    for(int i=0; i<N; i++){
        int k; cin >> k;
        for(int j=0; j<k; j++){
            int c; cin >> c;
            G[i].push_back(c);
        }
    }
    
    vector<int> tour, depth;
    euler_tour(G, 0, 0, tour, depth);
    vector<int> rightmsot(N);
    for(int i=0; i<tour.size(); i++)
        rightmsot[tour[i]] = i;
    
    RMQ rmq(tour);
    
    int Q; cin >> Q;
    for(int i=0; i<Q; i++){
        int u, v; cin >> u >> v;
        int ru = rightmsot[u], rv = rightmsot[v];
        if(ru > rv)
            swap(ru, rv);
        rv++;
        int d = rmq.find(ru, rv);
        cout << tour[d] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 20276
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int a;
	cin >> a;

	cout << a + a * a + a * a * a << "\n";

	return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;

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

    ll sum = accumulate(A.begin(), A.end(), 0LL);

    if (sum > N) {
        cout << -1 << endl;
    } else {
        cout << N - sum << endl;
    }

    return 0;
}


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

signed main()
{
    int n, l[100], ans;
    
    cin >> n;
    for(int i=0 ;i<n ;i++ ){
        cin >> l[i];
    }
    
    ans = 0;
    sort(l, l+n);
    
    for(int i=0 ;i<n ;i++ ) {
        for (int j=i+1 ;j<n ;j++ ) {
            for (int k=j+1 ;k<n ;k++ ) {
                if (l[k] < l[i] + l[j] && l[i] != l[j] && l[j] != l[k] && l[i] != l[k]) {
                    ans ++;
                    
                }       
            }
        }
    }
    
    cout << ans << endl;
    
    return (0);
}

Measured memory_bytes: 3632
// ABC170-B
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

    int x,y;
    cin>>x>>y;
    if((y-2*x)%2==0){
        int b=(y-2*x)/2;
        int a=x-b;
        if(0<=a && 0<=b) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

size_t count(std::string::iterator begin, std::string::iterator end, const char* const t)
{
	int sum = 0;
	std::string buf(begin, end);
	std::string::size_type cur = buf.find(t, 0);

	while (cur != buf.npos)
	{
		cur = buf.find(t, cur + strlen(t));
		sum += 1;
	}

	return sum;
}

int main()
{
	std::vector<std::string> s = {};
	int n, i, sum;
	sum = 0;
	int ea = 0;
	int bb = 0;

	int match = 0;

	std::cin >> n;

	for (i = 0; i < n; i++)
	{
		s.push_back("");
		std::cin >> s[i];
		if (s[i].back() == 'A' && s[i].front() == 'B')
		{
			match += 1;
		}
		if (s[i].back() == 'A')
		{
			ea += 1;
		}
		if (s[i].front() == 'B')
		{
			bb += 1;
		}
		sum += count(s[i].begin(), s[i].end(), "AB");
	}

	if (ea <= 0 || bb <= 0)
	{
		std::cout << sum << std::endl;
	}
	else if (match == ea && ea == bb)
	{
		std::cout << sum + bb - 1 << std::endl;
	}
	else if (ea >= bb)
	{
		std::cout << sum + bb << std::endl;
	}
	else if (ea < bb)
	{
		std::cout << sum + ea << std::endl;
	}

	return 0;
}


Measured memory_bytes: 768
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    T = set('abcdefghijklmnopqrstuvwxyz')
    S = set(iss())
    s = sorted(T ^ S)
    print(s[0] if len(s) > 0 else 'None')



if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


int main() {
	cout << fixed << setprecision(18);

	long long int N,M,K,P[200005],mymin=INF,res=0,ten[10]={1,10,100,1000,10000,100000,1000000};
	cin>>N;
	
	for(int i=1;i<=N;i++){
		long long int fir=0,tmp=i,la=i%10;
		for(int j=0;tmp!=0;j++){
			fir=tmp%10;
			tmp/=10;
		}
		if(N<=9){cout<<N<<endl;return 0;}
		//cout<<fir<<" firla "<<la<<endl;
		if(fir==la){
			res++;
		}

		if(la==0){continue;}
		//cout<<res<<" res ";
		for(int k=1;k<=7;k++){
			tmp=la;
			for(int p=1;p<=k;p++){
				tmp*=10;
			}
			tmp+=fir;
			if(N-tmp<0){continue;}
			if((N-tmp)/10>=ten[k-1]){res+=ten[k-1];}
			else{res+=(N-tmp)/10+1;}
			//cout<<tmp<<" "<<(N-tmp)%ten[k]/10+1<<endl;
			//res+=(N-tmp)/10+1;
		}
		//cout<<res<<endl;
	}
	cout<<res;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int N = 0;
    int K = 0;
    int count = 0;

    scanf("%d %d", &N, &K);

    while (N > 0){

        N = N / K;
        count++;
    }

    printf("%d\n", count);

    return 0;
}

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

using namespace std;

string s;
int P, Q, R;
int NOT[3] = {2, 1, 0};
int AND[3][3] = {{0, 0, 0}, {0, 1, 1}, {0, 1, 2}};
int OR[3][3] = {{0, 1, 2}, {1, 1, 2}, {2, 2, 2}};

int calc(int& index) {
  int ret;
  if (s[index] == 'P')
    ret = P;
  else if (s[index] == 'Q')
    ret = Q;
  else if (s[index] == 'R')
    ret = R;
  else if (isdigit(s[index])) {
    ret = s[index] - '0';
  } else if (s[index] == '-') {
    return NOT[calc(++index)];
  } else if (s[index] == '(') {
    ret = calc(++index);
    if (s[index] == '*') {
      ret = AND[ret][calc(++index)];
    } else {
      ret = OR[ret][calc(++index)];
    }
  }
  index++;
  return ret;
}

int main() {
  while (cin >> s, s != ".") {
    int ans = 0;
    for (P = 0; P < 3; P++) {
      for (Q = 0; Q < 3; Q++) {
        for (R = 0; R < 3; R++) {
          int c = 0;
          if (2 == calc(c)) ans++;
        }
      }
    }
    cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

std::vector<long long> make_divisors(long long n)
{
	std::vector<long long> d;
	for (long long i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			d.push_back(i);
			if (i != n / i) {
				d.push_back(n / i);
			}
		}
	}
	return d;
}

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);

	for (auto& x : A) {
		cin >> x;
	}

	map<int, int> h;
	for (auto x : A) {
		++h[x];
	}

	sort(A.begin(), A.end());

	int ans = N;
	for (int i = N - 1; i >= 0; --i) {
		if (h[A[i]] >= 2) {
			--ans;
		}
		else {
			const auto divisors = make_divisors(A[i]);
			for (auto d : divisors) {
				if (binary_search(A.begin(), A.end() - (N - i), d)) {
					--ans;
					break;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 13344
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    //int a,b,c;
    string s;
    //cin>>a>>b>>c;
    //cin.ignore();
    cin>>s;
 
    s[3]='8';
    cout<<s<<endl;
 
    return 0;
 
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math

N = int(input())
a = list(map(int, input().split()))

aves = [sum(a) // N, math.ceil(sum(a) / N)]
ans = float('inf')
for am in aves:
    acc = 0
    for ai in a:
        acc += abs(am - ai) ** 2
    ans = min(ans, acc)

print(ans)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
 
  if(S=="a"||S=="e"||S=="i"||S=="o"||S=="u"){
  	cout << "vowel" << endl;
  }else{
  	cout << "consonant" << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;
int main()
{     long long a,b,c;
      cin>>a>>b>>c;
      if((a*100+b*10+c)%4==0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
	  return 0;
}


Measured memory_bytes: 256
<?php
$default = trim(fgets(STDIN));
$array = explode(" ", $default);
for($j=0; $j<$array[0]; $j++){
	$people[$j] = 0;
}
for($i=0; $i<$array[1]; $i++){
	$dust = trim(fgets(STDIN));
	$count = trim(fgets(STDIN));
	$count = explode(" ", $count);
	foreach($count as $value){
		$people[$value-1]++;
	}
}

$anser = 0;

foreach($people as $value){
	if($value == 0){
		$anser++;
	}
}

echo $anser;

Measured memory_bytes: 15976
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

val reader by lazy { BufferedReader(InputStreamReader(System.`in`)) }

@Suppress("ReplaceJavaStaticMethodWithKotlinAnalog")
fun main(a: Array<String>) {
    val args = reader.readArgs()
    val n = args[0].toInt()
    val m = args[1].toInt()

    if (m == 0) {
        when (n) {
            1 -> println(0)
            else -> println("1" + (1 until n).map { 0 }.joinToString(""))
            
        }
        return
    }

    val list = (1..m).map { reader.readArgs() }.map { (it[0].toInt() - 1) to it[1].toInt() }
    val s = list.map { it.first }
    val c = list.map { it.second }

    val scMap = HashMap<Int, MutableList<Int>>()

    s.forEachIndexed { i, digit ->
        val cList = scMap.getOrPut(digit) { ArrayList() }
        cList.add(c[i])
        scMap[digit] = cList.distinct().toMutableList()
    }

    scMap.map { it.value }.forEach {
        if (it.size > 1) {
            println(-1)
            return
        }
    }

    val answer = (1..n).map { -1 }.toMutableList()

    scMap.forEach { answer[it.key] = it.value.first() }
    answer.forEachIndexed { digit, number ->
        if (number == -1) answer[digit] = if (digit == 0) 1 else 0
    }

    if (answer.size == 1) {
        println(answer[0])
        return
    }

    if (answer[0] == 0) {
        println(-1)
        return
    }

    if (answer.filterNot { it == 0 }.isEmpty()) {
        println(-1)
        return
    }

    println(answer.joinToString(""))
}

fun BufferedReader.readArgs() = readLine().split(" ")
fun BufferedReader.readInt() = readLine().toInt()
fun BufferedReader.readLong() = readLine().toLong()
fun BufferedReader.readChar() = readLine().toInt().toChar()
fun BufferedReader.readString() = readLine().toInt().toString()


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define size_of(a) (int)a.size()

typedef double Double;

const Double EPS = 1e-9;

typedef struct Point {
	Double x, y;
	Point(Double _x, Double _y) : x(_x), y(_y) {}
} Vector;

Point operator - (const Point& a, const Point& b) { return Point(a.x - b.x, a.y - b.y); }
bool operator < (const Point& a, const Point& b) {
	return a.x != b.x ? a.x < b.x : a.y < b.y;
}
bool operator > (const Point& a, const Point& b) {
	return a.x != b.x ? a.x > b.x : a.y > b.y;
}
bool operator == (const Point& a, const Point& b) {
	return fabs(a.x - b.x) < EPS && fabs(a.y - b.y) < EPS;
}

Double norm(const Point& a) { return a.x * a.x + a.y + a.y; }
Double abs(const Point& a) { return sqrt(norm(a)); }
Double dot(const Vector& a, const Vector& b) { return a.x * b.x * a.y * b.y; }
Double cross(const Vector& a, const Vector& b) { return a.x * b.y - a.y * b.x; }

int ccw(const Point& a, const Point& b, const Point& c) {
	Vector ba = b - a, ca = c - a;
	if (cross(ba, ca) > EPS) return +1;
	if (cross(ba, ca) < -EPS) return -1;
	if (dot(ba, ca) < -EPS) return +2;
	if (abs(ba) + EPS < abs(ca)) return -2;
	return 0;
}

int convex_hull(vector< Point >& vp) {
	int n = size_of(vp), k = 0;
	
	sort(allof(vp));
	vector< Point > ch(2 * n, Point(0, 0));
	
	for (int i = 0; i < n; ch[k++] = vp[i++]) {
		while (k >= 2 && ccw(ch[k - 2], ch[k - 1], vp[i]) <= 0) --k;
	}
	
	for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = vp[i--]) {
		while (k >= t && ccw(ch[k - 2], ch[k - 1], vp[i]) <= 0) --k;
	}
	
	return k - 1;
}

int main() {
	int n;
	
	while (cin >> n, n) {
		vector< Point > vp;
		
		for_(i,0,n) {
			char c;
			Double x, y; cin >> x >> c >> y;
			vp.push_back(Point(x, y));
		}
		
		cout << n - convex_hull(vp) << endl;
	}
	
	return 0;
}

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

int main(){
   int x;
   cin>>x;
   if(x >= 30){
      cout << "Yes" << endl;
   }else{
      cout << "No" << endl;
   }
}

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

int main() {
	int n;
	cin>>n;
	int a[n];
	int b[n];
	for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	for(int i=0;i<n;i++){
	    b[i]=0;
	}
	if(n!=1){
	    for(int i=0;i<n;i++){
	        if(i%2==0){
	            b[n/2+i/2]=a[i];
	        }
	        else{
	            b[n/2-(i+1)/2]=a[i];
	        }
	    }
	    if(n%2==0){
	        for(int i=0;i<n-1;i++){
	            cout<<b[i]<<" ";
	        }
	        cout<<b[n-1]<<endl;
	    }
	    else{
	        cout<<b[n-1];
	        for(int i=n-2;i>=0;i--){
	            cout<<" "<<b[i];
	        }
	        cout<<endl;
	    }
	}
	else{
	    cout<<a[0]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3840
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=100005;

int N,M;
vector<int> adj[MAXN];
vector<int> ans;
bool vis[MAXN];

int main()
{
    scanf("%d%d",&N,&M);
    for(int i=1;i<=M;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    bool flag=false;
    ans.push_back(1);
    vis[1]=true;
    for(int i=0;i<(int)adj[1].size();i++)
    {
        int u=adj[1][i];
        if(vis[u])
            continue;
        vis[u]=true;
        bool go=true;
        while(go)
        {
            go=false;
            ans.push_back(u);
            for(int j=0;j<(int)adj[u].size();j++)
            {
                int v=adj[u][j];
                if(vis[v])
                    continue;
                vis[v]=true;
                go=true;
                u=v;
                break;
            }
        }
        if(!flag)
        {
            reverse(ans.begin(),ans.end());
            flag=true;
        }
        else
            break;
    }
    printf("%u\n",ans.size());
    for(int i=0;i<(int)ans.size();i++)
        printf("%d%c",ans[i]," \n"[i==(int)ans.size()-1]);

    return 0;
}


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

using namespace std;

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

  int64_t h, w;
  cin >> h >> w;

  if (h == 1 || w == 1) {
    cout << 1 << '\n';
    return 0;
  }

  int64_t ans = h * w;
  if (ans % 2 == 1) {
    ++ans;
  }
  cout << ans / 2 << '\n';

  return 0;
}


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

using namespace std;

long long arr[1000][100005];
vector<long long> vw(1),vv(1);


int main(){
    long long n,w,a,b;
    scanf("%lld%lld",&n,&w);
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&a,&b);
        vw.push_back(a);
        vv.push_back(b);
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(vw[i]>j) arr[i][j]=arr[i-1][j];
            else arr[i][j]=max(arr[i-1][j],arr[i-1][j-vw[i]]+vv[i]);
        }
    }
    /*for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++)
            printf("%lld ",arr[i][j]);
        printf("\n");
    }*/
    printf("%lld",arr[n][w]);
    return 0;
}


Measured memory_bytes: 79360
#include <iostream>
using namespace std;
bool bit[16],bit2[16];
int a[16];
int n,m;

int check(bool sta){
  int pos=0,ans=0;
  for(int i=0;i<m;i++){
    for(int j=0;j<a[i];j++){
      int k=pos;
      while(k<n&&bit[k] !=sta) k++;
      if(k==n) return 10000000;
      ans += k-pos;
      while(k !=pos) bit[k] = bit[k-1],k--;
      bit[pos] = sta;
      pos++;
    }
    sta =!sta;
  }
  return ans;
}

int main() {
  cin >> n >> m;
  for(int i=0;i<n;i++) cin>>bit[i], bit2[i] = bit[i];
  for(int i=0;i<m;i++) cin>>a[i]; 
  
  int ans = check(1);
  for(int i=0;i<n;i++) bit[i] = bit2[i];
  cout << min(ans,check(0))<<endl;

  return 0;
}

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

int main(void) {

    ll a, b, n;
    cin >> a >> b >> n;

    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }

    if (n >= b) {
        // x= b-1が最大。
        ll ans = floor((ld)a * (b - 1) / b);
        cout << ans << endl;
    }
    else {
        // x=nが最大。
        ll ans = floor((ld)a * n / b);
        cout << ans << endl;
    }

    return 0;

}


Measured memory_bytes: 3680
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

vint prime(int N) {
    int x = 2;
    vector<bool> is_prime(N + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    
    while (x * x <= N) {
        if (is_prime[x] == true) {
            for (int i = x + x; i <= N; i += x) {
                is_prime[i] = false;
            }
        }
        x++;
    }
    vint ans;
    rep(i, N + 1) {
        if (is_prime[i]) ans.push_back(i);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int Q;
    cin >> Q;
    vll l(Q), r(Q);
    rep(i, Q) {
        cin >> l[i] >> r[i];
    }

    auto p = prime(100000);
    vint S(100001);
    REP(i, 1, 100001){
        S[i] = S[i - 1] ;
        auto it = lower_bound(p.begin(), p.end(), i);
        if (it == p.end()) continue;
        if (*it != i) continue;
        it = lower_bound(p.begin(), p.end(), (i + 1)/2);
        if (it == p.end()) continue;
        if (*it != (i + 1)/2) continue;
        S[i]++;
    }


    rep(i, Q) {
        cout << S[r[i]] - S[l[i] - 1] << endl;
    }

   
    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define MAX 1e9


using namespace std;

bool sortinrev(const pair<int,int> &a,  		//for vector of pairs
               const pair<int,int> &b) 
{ 
       return (a.first < b.first); 
}

int binarySearch(int low,int high,int key,int a[]){
    int mid= low + (high-low)/2;
    while(low<=high){
        if(a[mid]<key)
            low=mid+1;
        else if(a[mid]>key)
            high=mid-1;
        else
            return mid+1;
    }
    return -1;
}

int stringToDecimal(string s){
	int ans=0;
	int base=1;
	for(int i=s.length()-1;i>=0;i--){
		ans = ans + (s[i] - '0')*base;
		base = base*2;
	}
	return ans;
}

int main(){
	ll n,k;
	cin>>n>>k;
	ll h[n];
	for(ll i=0;i<n;i++)		cin>>h[i];
	sort(h,h+n);
	for(ll i=n-1;i>n-1-k;i--){
		h[i]=0;
	}
	ll sum=0;
	for(ll i=0;i<n;i++){
		sum+=h[i];
	}
	cout<<sum;
}

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

int main() {
    int D;
    int N;
    cin >> D >> N;
    float ans = pow(100,D) * N;
    if (N == 100) {
        ans += pow(100,D);
    }
    cout << int(ans) << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }
    let n = s.len();
    let d = 1000000007;
    let mut b = 0;
    let mut ans = 0;
    for i in 0..n {
        if s[i] == '1' {
            ans = (ans + pow_m(2, b, d) * pow_m(3, n - i - 1, d) % d) % d;
        }
        if s[i] == '1' {
            b += 1;
        }
    }
    ans = (ans + pow_m(2, b, d)) % d;
    println!("{}", ans);
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N, A, B;

    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        A = cin.nextInt();
        B = cin.nextInt();
    }
    static void solve()
    {
        input();

        int max = Min(A, B);
        int min = Max(0, A + B - N);
        WriteLine($"{max} {min}");
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13268
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let mut s: Vec<char> = read::<String>().chars().collect();
    s.sort();
    println!(
        "{}",
        if s == vec!['a', 'b', 'c'] {
            "Yes"
        } else {
            "No"
        }
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define ceil_div(a,b) ((a+(b-1))/b)
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
    int k; IN(k);
    rep(i, 0, k){
        cout << "ACL";
    }
    cout << el;
    return 0;
}


Measured memory_bytes: 3036
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,k,i,j;
  cin>>n>>k;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int dp[n][k+1];
  for(i=0;i<n;i++)
    for(j=0;j<=k;j++)
      dp[i][j]=0;
  int m[k+1]={0};
  for(j=1;j<=k;j++)
  {
    for(i=0;i<n;i++)
    {
      if(j==a[i])
        dp[i][j]=1;
      else if(j<a[i])
      dp[i][j]=0;
      else
        dp[i][j]=!m[j-a[i]];
      m[j]=m[j] || dp[i][j];
    }
  }
  for(i=0;i<n;i++)
  {
     if(dp[i][k]==1)
     {
      cout<<"First";
      return;
     }
  }
  cout<<"Second";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
 
int main(){
    int n;cin>>n;
    vector<int> a(n),b(n);
    rep(i,n)cin>>a[i];
    ll ans=a[0];
    for(int i=1;i<n;i++){
        if(i%2)ans-=a[i];
        else ans+=a[i];
    }
    b[0]=ans;
    for(int i=1;i<n;i++){
        b[i]=(a[i-1]-b[i-1]/2)*2;
    }
    rep(i,n){
        cout<<b[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 4052
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

struct edge{int to; ll cost;};
//隣接リスト
vector<vector<edge>> G;
//最短距離
vec d;

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(all(d),INF); d[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.nd;
        if(d[v]<p.st) continue;
        each(e,G[v]){
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int N,M; cin>>N>>M;
    d.resize(N+1), G.resize(N+1);
    rep(i,M){
        int L,R; cin>>L>>R;
        ll C; cin>>C;
        G[L].pb({R,C});
    }
    FOR(i,1,N){
        G[i+1].pb({i,0});
    }
    dijkstra(1);
    if(d[N]==INF) cout<<-1<<endl;
    else          cout<<d[N]<<endl;
    return 0;
}


Measured memory_bytes: 9340
#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 co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N, M;
	cin >> N >> M;
	int to[100001], ne[100001], he[100001] = {};
	rep1(i, M) {
		int u, v;
		cin >> u >> v;
		to[i] = v;
		ne[i] = he[u];
		he[u] = i;
	}
	int S, T;
	cin >> S >> T;

	int D[300004];
	rep(i, 300004) D[i] = 1e9;
	D[3 * S] = 0;

	queue<int> que;
	que.push(3 * S);
	while (que.size()) {
		int i = que.front();
		que.pop();
		int i2 = i / 3;
		int d = D[i] + 1;
		for (int j = he[i2]; j; j = ne[j]) {
			int j2 = to[j] * 3 + (i + 1) % 3;
			if (D[j2] > d) {
				D[j2] = d;
				que.push(j2);
			}
		}
	}

	if (D[3 * T] == 1e9) co(-1);
	else co(D[3 * T] / 3);

	Would you please return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n, a[200002], b[200002], c=1e9;
    string s;
    cin>>n>>s;
    a[0]=b[0]=0;
    for(int i=1;i<=n;i++){
        a[i]=a[i-1];
        b[i]=b[i-1];
        if(s[i-1]=='#'){
            a[i]++;
        }else{
            b[i]++;
        }
    }
    c=min(a[n], b[n]);
    for(int i=1;i<=n;i++){
        c=min(c, a[i]+b[n]-b[i]);
    }
    cout<<c<<endl;
}


Measured memory_bytes: 2180
#include <iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        if(n==0)return 0;
    
    char a[n];
    char b[n];
    
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }

    
    int count;
    cin>>count;
    
    char ans[count];
    
    for(int p=0;p<count;p++)cin>>ans[p];
    if(a[1]==ans[3])cout<<"AAAAA"<<endl;
    
    for(int j=0;j<count;j++){
        for(int l=0;l<n;l++){
            if(ans[j]==a[l]){
                ans[j]=b[l];
                break;
            }
        }
    }
    
    for(int q=0;q<count;q++)cout<<ans[q];
    cout<<endl;
    }
}

Measured memory_bytes: 3092
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,z,w = Is()
a = Is()
ans = ""
if n == 1:
    ans = abs(a[n-1]-w)
else:
    ans = max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]))
print(ans)



Measured memory_bytes: 3564
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

struct blue_point {
    int num;
    vector<int> pairs;//ペア化可能な赤点の座標
    blue_point(int n){
        num = n;
    }

        bool operator<(const blue_point& another) const {
        return num < another.num;
    }
};

int main() {
    int n; cin >> n;
    vector<pii> red_point;
    vector<blue_point> list;
    rep(i, n){
        int x, y; cin >> x >> y;
        red_point.push_back(pii(x,y));
    }
    rep(i, n){
        int x, y; cin >> x >> y;
        blue_point blue(x);
        rep(j, red_point.size()){
            pii red = red_point[j];
            int rx = red.first; int ry = red.second;
            if(x > rx && y > ry){
                blue.pairs.push_back(ry);
            }
        }
        sort(all(blue.pairs), greater<int>());
        list.push_back(blue);
    }
    sort(all(list));
    /*デバッグ
    rep(i, list.size()){
        blue_point blue = list[i];
        vector<int> vc = blue.pairs;
        cout << blue.num << ":";
        rep(j, vc.size()){
            cout << vc[j] << " ";
        }
        cout << ln;
    } */
    set<int> already;
    rep(i, list.size()){
        blue_point blue = list[i];
        vector<int> vc = blue.pairs;
        rep(j, vc.size()){
            int num = already.size();
            already.insert(vc[j]);
            if(already.size() > num){
                break;
            }
        }
    }
    cout << already.size() << ln; 
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a, b;
    scanf("%d %d",&a, &b);
    
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else if(a==b){
        printf("a == b\n");
    }    
    
    return 0;
    
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  sort(s.begin(), s.end());
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (s.at(i) != s.at(i - 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 9600