akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VI C(N-1),S(N-1),F(N-1);
    REP(i,N-1) cin >> C[i] >> S[i] >> F[i];
    REP(i,N)
    {
        int start = 0;
        FOR(j,i,N-1)
        {
            if(start < S[j]) start = S[j] + C[j];
            else{
                int add = (start - S[j]+ F[j]-1) / F[j];
                start = S[j] + add * F[j] + C[j];
            }
        }
        cout << start << endl;
    }

}

Measured memory_bytes: 256
fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: usize = rd.get();
    let m: usize = rd.get();
    let ab: Vec<(usize, usize)> = (0..m)
        .map(|_| {
            let a: usize = rd.get();
            let b: usize = rd.get();
            (a - 1, b - 1)
        })
        .collect();

    let mut uf = UnionFind::new(n);
    for (a, b) in ab {
        uf.unite(a, b);
    }
    let mut leader = vec![false; n];
    for i in 0..n {
        leader[uf.find(i)] = true;
    }
    let size = leader.iter().filter(|&&f| f).count();
    println!("{}", size - 1);
}

pub struct UnionFind {
    par: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            par: (0..n).map(|i| i).collect::<Vec<_>>(),
            size: vec![1; n],
        }
    }
    pub fn find(&mut self, i: usize) -> usize {
        if self.par[i] == i {
            self.par[i]
        } else {
            self.par[i] = self.find(self.par[i]);
            self.par[i]
        }
    }
    pub fn unite(&mut self, i: usize, j: usize) {
        let i = self.find(i);
        let j = self.find(j);
        if i == j {
            return;
        }
        let (i, j) = if self.size[i] >= self.size[j] {
            (i, j)
        } else {
            (j, i)
        };
        self.par[j] = i;
        self.size[i] += self.size[j];
    }
    pub fn get_size(&mut self, i: usize) -> usize {
        let p = self.find(i);
        self.size[p]
    }
    pub fn same(&mut self, i: usize, j: usize) -> bool {
        self.find(i) == self.find(j)
    }
}

pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    int flag=0;
    for(int i=0; i<n; i++)
    {
      if(b[i]==a[n-1])
        cout<<a[n-2]<<endl;
      else
        cout<<a[n-1]<<endl;
    }
}


Measured memory_bytes: 3200
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	return B;
}

ll _gcd(ll A, ll B) {
	return (B == 0) ? A : gcd(A % B, B);
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
	}
	return res;
}


ll fibs[100] = { 0 };
ll fib(int n) {
	if (fibs[n] == 0) {
		return fibs[n] = fib(n - 1) + fib(n - 2);
	}
	return fibs[n];
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	ll N, K, Q;
	cin >> N >> K >> Q;

	vector<ll> A(N, K - Q);
	int tmp;
	rep(i, Q) {
		cin >> tmp;
		A[tmp - 1]++;
	}

	rep(i, N) {
		cout << (A[i] > 0 ? "Yes" : "No") << endl;
	}


ProgramEndPointLabel:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG


	return 0;
}




Measured memory_bytes: 1656
/* ex7_1
    sachiyan */

#include <stdio.h>
#include <stdlib.h>
//構造体宣言
typedef struct point{
    int x_elem;
    int y_elem;
}point;

//座標yを中心とし、xを-90度回転させるコード
point shift_point(point x, point y){
    point z;
    //回転させるベクトルを求める
    point dif = {(x.x_elem - y.x_elem), (x.y_elem - y.y_elem)};
    //回転させるベクトルdifを-90度回転後回転中心の座標を足す
    z.x_elem = dif.y_elem + y.x_elem;
    z.y_elem = -dif.x_elem + y.y_elem;
    return z;
}

int main(void){
    int x_1, y_1;
    int x_2, y_2;
    scanf("%d %d %d %d", &x_1, &y_1, &x_2, &y_2);
    //座標1,2を初期化
    point coor_1 = {x_1, y_1};
    point coor_2 = {x_2, y_2};
    //shift_point関数を用いて座標3,4を求める
    point coor_3 = shift_point(coor_1, coor_2);
    point coor_4 = shift_point(coor_2, coor_3);
    //出力
    printf("%d %d %d %d\n", coor_3.x_elem, coor_3.y_elem, coor_4.x_elem, coor_4.y_elem);
    return 0;
}

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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

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

    ll ans = 0;
    if(n % 2 == 0){
        for(ll i = 0;i < n;i++){
            if(i < n / 2 - 1){
                ans += a[i] * -2;
            }
            else if(i > n / 2){
                ans += a[i] * 2;
            }
            else if(i == n / 2 - 1){
                ans += a[i] * -1;
            }
            else{
                ans += a[i];
            }
        }
    }
    else{
        for(ll i = 0;i < n;i++){
            if(i < n / 2 - 1){
                ans += a[i] * -2;
            }
            else if(i > n / 2){
                ans += a[i] * 2;
            }
            else{
                ans += a[i] * -1;
            }
        }
        ll t = 0;
        for(ll i = 0;i < n;i++){
            if(i < n / 2){
                t += a[i] * -2;
            }
            else if(i > n / 2 + 1){
                t += a[i] * 2;
            }
            else{
                t += a[i];
            }
        }
        ans = max(ans, t);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;


int main() {
 
  int64_t N,ans=0;
  cin>>N;
  vector<int> A(N+1);
  unordered_map<int64_t,int> um;
  for(int i=0; i<N; i++){
    int a;
    cin>>a;
    A[i+1]=a;
    if(um.count(a+i+1))um[a+i+1]++;
    else um[a+i+1]=1;
  }
  for(int i=0; i<N; i++){
   if(um.count(i+1-A[i+1]))ans+=um[i+1-A[i+1]];
  }
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}

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

int main(){
    int n;cin>>n;
    ll ans=0;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n;i++) cin>>c[i];
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        auto iter=lower_bound(a.begin(),a.end(),b[i]);
        ll index1=iter-a.begin();
        auto it=upper_bound(c.begin(),c.end(),b[i]);
        ll index2=it-c.begin();
        ans+=index1*(n-index2);
    }
    cout<<ans<<endl;
}


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

#define MAX 10

void res(int);

int main(void){
  int n,num;

  while( cin >> n, n ){
    int ice[MAX]={0};

  for( int i = 0 ; i < n ; i++ ){
    cin >> num;
    ice[num]++;
  }

  for( int i = 0 ; i < MAX ; i++ ) res(ice[i]);

  }

  return 0;
}

void res(int n){

  if( n == 0 ) cout << '-' << endl;
  else{
    while( n > 0 ){
      cout << '*';
      n--;
    }
    cout << endl;
  }

}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, x, n) for(ll i=x; i<(ll)n; ++i)
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()

int main(){
    ll N, K;
    cin >> N >> K;

    vvll dp(K+1, vll((ll)sqrt(N)*2+1, -1));
    vll t;
    t.push_back(N/1);
    REP(i, 2, (ll)sqrt(N)+1){
        if(N/i<t[t.size()-1]) t.push_back(N/i);
    }
    for(ll i=sqrt(N); i>=1; --i){
        if(i<t[t.size()-1]) t.push_back(i);
    }
    function<ll(ll, ll)> solve = [&](ll k, ll n){
        if(n<0) return 0ll;
        if(dp[k][n]>=0) return dp[k][n];
        if(k==1){
            ll r = solve(k, n-1) + N/t[n] - N/(t[n]+1);
            r %= 1000000007;
            dp[k][n] = r;
            return r;
        }
        ll p = N/t[n] - N/(t[n]+1);
        ll b = lower_bound(all(t), N/t[n], [](auto l, auto r){ return l>r; }) - t.begin();
        ll count = b>=t.size()? 0 : solve(k-1, b) * p % 1000000007;
        dp[k][n] = (solve(k, n-1) + count) % 1000000007;
        return dp[k][n];
    };
    ll a = solve(K, t.size()-1);
    cout << a << endl;
}


Measured memory_bytes: 59280
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,i;
  cin>>n;
  int h[n],dp[n];
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(i=0;i<n-2;i++){
    dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]));
  }
  cout<<dp[n-1];
}


Measured memory_bytes: 1024
n,m,s,t=map(int,input().split())

en=[[]for i in range(n+1)]
sn=[[]for i in range(n+1)]

for i in range(m):
    u,v,a,b=map(int,input().split())
    en[v].append((u,a))
    en[u].append((v,a))
    sn[v].append((u,b))
    sn[u].append((v,b))
#print(en)

import numpy as np
INF=10**20

def dijkstra(S, N, paths):
    from heapq import heappush,heappop
    q=[(0,S)]
    shortest=[INF]*N
    shortest[S]=0
    while len(q)>0:
        d0, src=heappop(q)
        if d0>shortest[src]:
            continue
        for dst, d1 in paths[src]:
            if d0+d1<shortest[dst]:
                shortest[dst]=d0+d1
                heappush(q, (d0+d1, dst))
    return np.array(shortest)
    
en=dijkstra(s,n+1,en)
sn=dijkstra(t,n+1,sn)

cost=[]
for i in range(1,n+1):
    cost.append(en[i]+sn[i])
cost=cost[::-1]
#print(cost)

ans=[]
mi=cost[0]
for i in range(n):
    ans.append(min(mi,cost[i]))
    mi=min(mi,cost[i])
ans=ans[::-1]
#print(ans)
for i in ans:
    print(10**15-i)


Measured memory_bytes: 81596
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
using namespace std;
typedef pair<int, int> P;
signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    if (i)
      a[i] += a[i - 1];
  }
  int out = LLONG_MAX;
  rep(i, 2) {
    int cnt = 0, ans = 0;
    rep(j, n) {
      if (j % 2 == i) {
        ans += max(1 - (a[j] + cnt), 0ll);
        cnt += max(1 - (a[j] + cnt), 0ll);
      } else {
        ans += max((a[j] + cnt) + 1, 0ll);
        cnt += min(-(a[j] + cnt) - 1, 0ll);
      }
    }
    out = min(out, ans);
  }
  cout << out << endl;
}

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

int main() {
    int v;
    cin >> v;
    int A = v / 1000;
    int B = (v % 1000) / 100;
    int C = (v % 100) / 10;
    int D = (v % 10);
    int l[3] = {B, C, D};
    unsigned int bit;
    for (bit=0; bit<8; bit++) {
        int sum = A;
        for (int i=0; i<3; i++) {
            if (bit & (1<<i)) {
                sum += l[i];
            } else {
                sum -= l[i];
            }
        }
        if (sum == 7) break;
    }
    cout << A;
    for (int i=0; i<3; i++) {
        if (bit & (1<<i)) {
            cout << '+';
        } else {
            cout << '-';
        }
        cout << l[i];
    }
    cout << "=7" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<string>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;
	string ans;
	int x = s.size();

	if (s[x - 1] == 's') {
		cout << s << "es" << endl;
	}else
	cout << s << 's' << endl;

	return 0;
}


Measured memory_bytes: 3624
from collections import deque
h, w = map(int, input().split())
A = [list(input()) for _ in range(h)]
V = [[-1]*w for _ in range(h)]
que = deque([])
for i,a in enumerate(A):
    for j,_a in enumerate(a):
        if _a == '#':
            que.append([i,j])
            V[i][j] = 0
dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
while que:
    nwh,nww = que.popleft()
    for dh, dw in dhdw:
        if not (0<=nwh+dh<h and 0<=nww+dw<w): continue
        if V[nwh+dh][nww+dw] != -1: continue
        V[nwh+dh][nww+dw] = V[nwh][nww]+1
        que.append([nwh+dh, nww+dw])
print(max(map(max, V)))

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int long long i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 50 + 1;
const i64 MAXM = 5'000 + 1;

i64 n, m;
i64 s;

struct cedge {
    i64 u;
    i64 v;
    i64 a;
    i64 b;
};

struct edge {
    pair<i64, i64> v;
    i64 c;
};

i64 c[MAXN];
i64 d[MAXN];

vector<cedge> z;

vector<edge> e[MAXN][MAXM];

i64 r[MAXN][MAXM];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> m;
    cin >> s;

    for (i64 tt = 0; tt < m; tt++) {
        z.push_back(cedge());
        auto& t = z.back();
        cin >> t.u >> t.v >> t.a >> t.b;
    }

    for (i64 i = 1; i <= n; i++) {
        cin >> c[i] >> d[i];
    }

    for (auto& t : z) {
        for (i64 j = t.a; j < MAXM; j++) {
            e[t.u][j].push_back({{t.v, j - t.a}, t.b});
            e[t.v][j].push_back({{t.u, j - t.a}, t.b});
        }
    }

    for (i64 i = 1; i <= n; i++) {
        for (i64 j = 0; j < MAXM; j++) {
            if (j + c[i] >= MAXM) {
                break;
            }
            e[i][j].push_back({{i, j + c[i]}, d[i]});
        }
    }

    s = min(s, MAXM - 1);

    set<pair<i64, pair<i64, i64>>> q;
    q.insert({1, {1, s}});
    r[1][s] = 1;

    while(!q.empty()) {
        auto cost = q.begin()->first;
        auto vertex = q.begin()->second.first;
        auto money = q.begin()->second.second;
        q.erase(q.begin());

        for (auto te : e[vertex][money]) {
            auto ncost = cost + te.c;
            auto nvertex = te.v.first;
            auto nmoney = te.v.second;

            auto& tcost = r[nvertex][nmoney];
            if (!tcost || tcost > ncost) {
                q.erase({tcost, {nvertex, nmoney}});
                tcost = ncost;
                q.insert({ncost, {nvertex, nmoney}});
            }
        }
    }

    stringstream ss;
    for (i64 i = 2; i <= n; i++) {
        i64 R = 0;
        for (i64 j = 0; j < MAXM; j++) {
//            cerr << r[i][j] << " ";
            if (!R || R > r[i][j]) {
                R = r[i][j];
            }
        }
//        cerr << endl;
        ss << R - 1 << endl;
    }
    cout << ss.str();
    return 0;
}

Measured memory_bytes: 59624
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n;
    cin>>n;
    vector<int >v;

    for(int i=0;i<n;i++)
    {
        int k;
         cin>>k;
         v.push_back(k);
    }
    int k=1;
    int j=0;
    int cnt=0;
        while(j<n)
        {
            if(v[j]==k)
            {
                k++;
                j++;
                continue;
            }
            j++;
            cnt++;
        }
        if(cnt==n)cout<<-1<<endl;
        else
            cout<<cnt<<endl;
}


Measured memory_bytes: 1400
#[allow(unused_macros)]
macro_rules! debug {
	($($a:expr),*) => {
		println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
	}
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(dead_code)]
const MOD: usize = 1e9 as usize + 7;

fn divisor(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res
}

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();

    let divs = divisor(n);
    let ans = divs
        .into_iter()
        .map(|d| n / d - 1)
        .filter(|&x| x != 0 && n / x == n % x)
        .sum::<usize>();
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}

#[allow(dead_code)]
fn yn(flag: bool) {
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2192
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int main() {
    int A, B, H, M; cin >> A >> B >> H >> M;
    int minutes = H * 60 + M;
    double tha = 6 * M * PI / 180, thb = minutes * 0.5 * PI / 180;
    double ax = A * cos(tha), ay = A * sin(tha);
    double bx = B * cos(thb), by = B * sin(thb);
    double dx = ax - bx, dy = ay - by;
    double ans = sqrt(dx * dx + dy * dy);
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 4092
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
h.sort()

min_diff = 10**9
for hl, hr in zip(h, h[k-1:]):
    min_diff = min(min_diff, hr - hl)
print(min_diff)

Measured memory_bytes: 7884
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N = int(input())
    A = read_list()
    D = {}
    for a in A:
        D[a] = D.setdefault(a, 0) + 1
    
    for n in range(1, N + 1):
        print(D.setdefault(n, 0))


if __name__ == "__main__":
    main()


Measured memory_bytes: 37660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;
ll k;

int main(){
	cin >> s >> k;
	rep(i,s.size()){
		ll cnt = ('z'-s[i]+1) % 26;
		// cout << k <<" " << cnt << endl;
		if(cnt <= k){
			s[i] = 'a';
			k -= cnt;
		}
	}
	if(k != 0)s[s.size()-1] += k % 26;
	cout << s << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 int main() {
    vector<int>a(12);
    a ={0,1,3,1,2,1,2,1,1,2,1,2,1};
	int x,y;
    cin >> x >>y;
    cout << (a.at(x) == a.at(y) ? "Yes" : "No" ) <<endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF=1e9;
typedef pair<int,int> P;
int dp[223456][35];//dp[i][j]:i番目まででj個行った時の最小タイム
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
bool cmp(P u,P v){
  return u.first*(v.second+1)>v.first*(u.second+1);
}

signed main(){
  int n,t;cin>>n>>t;
  vector<P> v;
  vector<int> w;
  w.push_back(0);
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;if(a+b>t)continue;
    if(a)v.push_back(P(a,b));
    else w.push_back(b);
  }
  sort(v.begin(),v.end(),cmp);
  sort(w.begin(),w.end());
  for(int i=0;i<223456;i++)for(int j=0;j<30;j++)dp[i][j]=INF+10;
  dp[0][0]=0;
  n=v.size();
  for(int i=0;i<n;i++){
    int a=v[i].first,b=v[i].second;
    for(int j=0;j<30;j++){
      if(dp[i][j]>t)continue;
      chmin(dp[i+1][j],dp[i][j]);
      chmin(dp[i+1][j+1],dp[i][j]+1+(dp[i][j]+1)*a+b);
    }
  }
  for(int i=1;i<w.size();i++)w[i]+=w[i-1]+1;
  int ans=0;
  for(int j=0;j<30;j++){
    int res=t-dp[n][j];
    if(res<0)continue;
    int l=0,r=w.size();
    while(r-l>1){
      int mid=(r+l)>>1;
      if(w[mid]<=res)l=mid;
      else r=mid;
    }
    chmax(ans,j+l);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 65516
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    int K;
    cin >> A >> B >> K;
    int i;
    int ans;
    int count =0;
    for(i=min(A,B);i>=1;i--)
    {
        if(A % i == 0 && B % i ==0)
        {
            count++;
            ans = i;
        }
        if(count == K)
        {
            break;
        }
    }
    cout << ans << endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    int cntAC= 0;
    int cntWA= 0;
    int cntTLE= 0;
    int cntRE= 0;
    rep(i,N){
        string S; cin >> S;
        if(S == "AC") cntAC++;
        else if(S == "WA") cntWA++;
        else if(S == "TLE") cntTLE++;
        else cntRE++;
    }
    printf("AC x %d\n", cntAC);
    printf("WA x %d\n", cntWA);
    printf("TLE x %d\n", cntTLE);
    printf("RE x %d\n", cntRE);
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    int n;
    cin >> n;

    for (int i = n; ; ++i) {
        int x = i;
        vector<int> a;
        while (x) {
            a.push_back(x % 10);
            x /= 10;
        }
        bool ok = true;
        rep(i, a.size() - 1) if (a[i] != a[i+1]) ok = false;
        if (ok) {
            cout << i << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 3632
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    in k;
    cin>>n>>k;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
        rep(i,n) a[i] --;
    vector<int> kai(n,-1);
    kai[0]=0;
    int now=0;
    int cnt=-1;
    rep(i,n){
        now=a[now];
        if(kai[now]==-1) kai[now]=i+1;
        else{
            cnt=i+1;
            break;
        }
    }
    int s=0;
    if(k>=kai[now]){
        k -=(in)kai[now];
        k %=(in)(cnt-kai[now]);
        s=now;
    }
    rep(i,k){
        s=a[s];
    }
    cout<<s+1<<endl;
}/*
./problem.exe
*/

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    ll n,m;
    cin >> n >> m;

    string ans = "Yes";

    if(n != m)ans = "No"; 

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

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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int MOD = 1000000007;
ll dp[101][1000001];
int main() {
    IOS;
    int N, W;
    cin >> N >> W;
    std::vector<int> weight(N + 1), value(N + 1);
    for(int i = 1; i <= N; i++) cin >> weight[i] >> value[i];

    for(int i = 1; i <= N; i++) {
        for(int w = 1; w <= W; w++) {
            if(w < weight[i]) dp[i][w] = dp[i - 1][w];
            else dp[i][w] = MAX(value[i] + dp[i - 1][w - weight[i]], dp[i - 1][w]);
        }
    }
    cout << dp[N][W];
    return 0;
}

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

using namespace std;
long long k, a, b;

int main() {
    cin >> k >> a >> b;
    if (a >= b)cout << k + 1;
    else {
        if (k + 1 <= a)cout << k + 1;
        else {
            if (b - a <= 2)cout << k + 1;
            else {
                cout << (k - (a - 1)) / 2 * (b - a) + a + ((k - a + 1) % 2);
            }
        }
    }
    return 0;
}

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

const int mxN = 1e6 + 5;
long long dp[mxN][2];

int main() {
	string s;
	cin >> s;
	int n = s.size();
	dp[0][1] = 1;
	for(int i = 0; i < n; ++i) {
		int cur = s[i] - '0';
		dp[i + 1][0] = min(dp[i][0] + cur, dp[i][1] + 10 - cur);
		dp[i + 1][1] = min(dp[i][0] + cur + 1, dp[i][1] + 10 - cur - 1);
	}
	cout << dp[n][0];
}


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

int main()
{
	int H, W, i, j;
	
	while(1)
	{
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		
		for(i = 0; i < H;i++)
		{
			for(j = 0; j < W; j++)
			{
				if(i == 0 || i == H - 1)
				cout << "#";
				else if(j == 0 || j == W - 1)
				cout << "#";
				else 
				cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;
void fail(){cout << "NO"<<endl;exit(0);}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t[4]={"dream","dreamer","erase","eraser"};
    cin >>s;
    int p=0,l=s.size();
    while(p<l){
        if(s[p]=='d'){
            if(s.substr(p,5)!=t[0])fail();
            if(s[p+5]!='e'){
                p=p+5;
                continue;
            }else if(p==l-7 and s.substr(p,7)=="dreamer"){
                cout << "YES"<<endl;
                return 0;
            }else if(s.substr(p+5,3)=="ere"  or s.substr(p+5,3)=="erd"){
                p=p+7;
                continue;
            }else if(s.substr(p+5,3)=="era"){
                p=p+5;
                continue;
            }else{
                fail();
            }
        }else if(s[p]=='e'){
            if(s.substr(p,5)!=t[2])fail();
            if(s[p+5]=='r'){
                p=p+6;
            }else if(s[p+5]!='e' or s[p+5]!='d'){
                p=p+5;
                continue;
            }else{
                fail();
            }
        }else{
            fail();
        }
    }
    cout << "YES"<<endl;



    return 0;
}


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

int main(void){
	int m,f,r;
	while(true){
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1){
			break;
		}
		if(m == -1 || f == -1){
			cout << "F" << endl;
		}else if(m+f >= 80){
			cout << "A" << endl;
		}else if(m+f >= 65){
			cout << "B" << endl;
		}else if(m+f >= 50){
			cout << "C" << endl;
		}else if(m+f >= 30){
			if(r >= 50){
				cout << "C" << endl;
			}else{
				cout << "D" << endl;
			}
		}else{
			cout << "F" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
//suhan lee,saitama university

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <complex>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<  vector<double>  > vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef complex<double> zahyo;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n) for(int i=0;i<n;i++)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define pb push_back 
#define pf push_front
zahyo toshi[21];
double kyori[21][21];
double kakgyo[21][21];
int newdo[21][21][21];
bool newdotest(int i,int j,int k,double kakdo){
  if(newdo[i][j][k]!=100) return newdo[i][j][k];
  zahyo a=toshi[j]-toshi[i];
  zahyo b=toshi[k]-toshi[j];
  double kak= (a.real()*b.real()+a.imag()*b.imag())/  (abs(a)*abs(b));
  //cout<<kak<<endl;
  if (cos(kakdo*3.14159265/180.0)<=kak){
    newdo[i][j][k]=true;

  }
  else newdo[i][j][k]= false;
 
  return newdo[i][j][k];
}
bool kakdotest(zahyo a,zahyo b,double kakdo){
  double kak= (a.real()*b.real()+a.imag()*b.imag())/  (abs(a)*abs(b));
  if (cos(kakdo*3.14159265/180.0)<=kak)
    return true;
  else return false;
}
int main(){
  int n,k;
  double r,kakdo,xza,yza;
  cin>>n>>r>>kakdo;
  for(int i=1;i<=n;i++){
    cin>>xza>>yza;
    toshi[i]=zahyo(xza,yza);
  }
  for(int i=0;i<(n+1);i++)
    for(int j=0;j<(n+1);j++)
      for(int k=0;k<(n+1);k++)
	newdo[i][j][k]=100;
  
  for(int i=1;i<(n+1);i++)
	kyori[i][0]=abs(toshi[i]);
  for(int i=1;i<(n+1);i++)
    for(int j=1;j<(n+1);j++){
      kyori[i][j]=abs(toshi[i]-toshi[j]);
   
    }


  vvd nokori(n+1);
  for(int i=0;i<n+1;i++){
    nokori[i]=vector<double>(21,-1);
  }
  vvd prevnokori=nokori;
  for(int i=2;i<n+1;i++){
    prevnokori[1][i]=r-abs(toshi[i]-toshi[1]);
  }
  int maxcarrot=0;
  k=1;
  while(k-maxcarrot==1){
    vvd nextnokori=nokori;  
    for(int i=1;i<(n+1);i++)
      for(int j=1;j<(n+1);j++){
	if(i==j) continue;
	if(prevnokori[i][j]<0) continue;
	maxcarrot=k;
	//	cout<<i<<" "<<j<<" "<<k<<" "<<abs(prevnokori[i][j])<<endl;
	for(int l=1;l<(n+1);l++){
	  // if(kakdotest(toshi[i]-toshi[j],
	  // 	       toshi[j]-toshi[l],kakdo)){
	  if(newdotest(i,j,l,kakdo)){
	  nextnokori[j][l]=
	      max(prevnokori[i][j]-kyori[j][l],
				 nextnokori[j][l]);
	    //	    cout<<i<<" "<<j<<" "<<l<<endl;
	  }
	}

      }
    prevnokori=nextnokori;
    k++;
  }
  cout<<maxcarrot<<endl;

  return 0;
}

Measured memory_bytes: 1360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u==s) a--;
    else b--;
    cout<<a<<" "<<b;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  string s;
  cin >> s;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;


public class Main{
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int k = sc.nextInt();
		int[] s = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		System.out.println(s[k - 1]);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21972
N = int(input())
A = [int(e) for e in input().split()]
A_even = []
A_1 = []
A_2 = []
for i in range(N):
    if A[i] % 2 == 0:
        A_even.append(A[i])
for i in range(len(A_even)):
    if A_even[i] % 3 != 0:
        A_1.append(A_even[i])
for i in range(len(A_1)):
    if A_1[i] % 5 != 0:
        A_2.append(A_1[i])
if len(A_2) == 0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INFTY (1<<30)

int n;
vector<int> color(101,0),d(101,INFTY),p(101);
vector<vector<int>> M(101,vector<int>(101,INFTY));

void prim(){
    d[0]=0;
    p[0]=-1;

    while(1){
        int u;
        int mincost=INFTY;
        for(int i=0;i<n;i++){
            if(color[i]!=2&&d[i]<mincost){
                mincost=d[i];
                u=i;
            }
        }
        if(mincost==INFTY) break;
        color[u]=2;

        for(int v=0;v<n;v++){
            if(color[v]!=2&&M[u][v]<INFTY){
                if(M[u][v]<d[v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=1;
                }
            }
        }

    }

}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>M[i][j];
            if(M[i][j]==-1) M[i][j]=INFTY;
        }
    }

    prim();

    int ans=0;
    for(int i=0;i<n;i++){
        ans+=d[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int main(int argc,char const* argv[])
{
  ll N,K;
  cin >> N >> K;
  double totalpro=0.0;
  
  for(int D=1;D<=N;D++)
    {
      double tmppro=1.0/double(N);
      //cout << tmppro << endl;
      ll now=D;
      while(now<K)
	{
	  now*=2;
	  tmppro*=0.5;
	}
      totalpro+=tmppro;
    }
  cout << fixed << setprecision(12) << totalpro << endl;
  return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
S = S()
if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4012
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define _max(_x, _y) ((_x)>(_y)?(_x):(_y))
#define _min(_x, _y) ((_x)>(_y)?(_y):(_x))
#define _abs(_x) ((_x)>0?(_x):(-(_x)))

int main(void)
{
char Nc[10];
long H, N, A[100000], index;

  scanf("%ld %ld", &H, &N);
  for (index = 0; index < N; ++index) {
    scanf("%ld", &A[index]);
    H -= A[index];
    if (H <= 0) {
      printf("Yes\n");
      return 0;
    };
  }
  printf("No\n");
  
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> sum(n);
  rep(i, n) {
    cin >> a[i];
    if (i == 0) {
      sum[i] = a[i];
    } else {
      sum[i] += sum[i-1] + a[i];
    }
  }

  ll total = SUM(a);

  ll ans = INFL;
  rep(i, n-1) {
    chmin(ans, abs(sum[i] - (total - sum[i])));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328