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

using namespace std;

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

    int q;
    cin>>q;

    set<int> Set;
    while(q--)
    {
        int op,x;
        cin>>op>>x;

        if(!op)
        {
            Set.insert(x);
            cout<<Set.size()<<endl;
        }else if(op==1)
        {
            cout<<(Set.find(x)!=Set.end())<<endl;
        }else if(op==2)
        {
            Set.erase(x);
        }else if(op==3)
        {
            int l=x,r,cnt=0;
            cin>>r;
            for(auto i=Set.lower_bound(l);i!=Set.end()&&*i<=r;i++)
                cout<<*i<<endl;
        }
    }

    return 0;
}



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

int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if ( abs(c - a) <= d || abs(b - a) <= d && abs(c - b) <= d ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return (0);
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: i32,
        a_n: [i32; n]
    };
    println!("{}", solve(n, a_n));
}

fn solve(n: i32, a_n: Vec<i32>) -> String {
    // write solution here
    let average = (a_n.iter().map(|iter| *iter as f32).sum::<f32>() / n as f32).round() as i32;
    let result = a_n.iter().map(|iter| (iter - average) * (iter - average)).sum::<i32>();
    // return answer
    format!("{}", result)
}

#[test]
fn test(){
    assert_eq!("5".to_string(), solve(3, vec![4,2,5]))
}

Measured memory_bytes: 4476
num = int(input())
b = list(map(int,input().split()))
a = [0]*num
a_fix = [-1]*num

for i in range(0,num-1):
    if b[i] >= max(a[i],a[i+1]):
        if a_fix[i] == -1: 
            a[i] = a[i+1] = b[i]
            a_fix[i] = a_fix[i+1] = 1 
        else:
            a[i+1] = b[i]
            a_fix[i+1] = 1
    else:
        a[i] = a[i+1] = b[i]
        a_fix[i] = a_fix[i+1] = 1

print(sum(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int n;
    cin >> n;
    int arr[n];
    int i;
    for(i=0;i<n;i++)
        cin >> arr[i];
    int maxi = arr[0], sum = 0;
    for(i=1;i<n;i++)
    {
        if(arr[i] >= maxi)
        {
            maxi = arr[i];
            continue;
        }
        else
        {
            sum+=(maxi-arr[i]);
        }
    }
    cout << sum;
}

Measured memory_bytes: 5156
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <iomanip>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int in() { int x; cin >> x; return x; }

struct V {
    int x, y, r;
    V(int x,int y,int r):x(x),y(y),r(r){
        //cout<<"x="<<x<<",y="<<y<<",r="<<r<<endl;
    }
};

typedef pair<double, int> P;

vector<V> G;
double d[1010];

signed main()
{
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    G.PB(V(x1, y1, 0));
    G.PB(V(x2, y2, 0));

    int N; cin >> N;

    rep(i, N) {
        int x, y, r; cin >> x >> y >> r;
        G.PB(V(x, y, r));
    }

    priority_queue<P,vector<P>,greater<P>> q;
    fill_n(d, 1010, linf);
    d[0] = 0;
    q.push(P(0.0, 0));

    while (q.size()) {
        P p = q.top(); q.pop();

        int num = p.scd, c = p.fst;

        if (d[num] < c) continue;

        V v = G[num];

        for (int i = 0; i < G.size(); ++i) {
            if (i == num) continue;

            V u = G[i];

            double dist = max(sqrt(pow(v.x - u.x, 2) + pow(v.y - u.y, 2)) - (v.r + u.r), 0.0);

            if (d[i] > d[num] + dist) {
                d[i] = d[num] + dist;
                q.push(P(d[i], i));
            }
        }
    }

    cout << fixed << setprecision(10) << d[1] << endl;
}


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

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

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

fn main() {
  let mut map: Vec<Vec<char>> = vec![];
  for i in 0..3 {
    let a = read::<String>();
    map.push(a.chars().collect());
  }

  println!("{}{}{}", map[0][0], map[1][1], map[2][2]);
}


Measured memory_bytes: 4352
import numpy as np

N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.empty((N,M))

count = 0
for n in range(N):
    A[n] = [int(m) for m in input().split()]
    count += (sum(A[n] * B)+C > 0)
print(count)


Measured memory_bytes: 13500
#include "bits/stdc++.h"
using namespace std;
string s;
 
int main() {
  cin >> s;
  string res = "Yes";
  for(int i=0;i<s.length();i++){
    if((i%2==0) && s[i] == 'L'){
      res = "No";
    }else if((i%2==1) && s[i] == 'R'){
      res = "No";
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections

N, = map(int, sys.stdin.readline().rstrip().split(" "))
Ds = list(map(int, sys.stdin.readline().rstrip().split(" ")))
if Ds.pop(0) != 0:
    print(0)
else:
    Ds.sort()
    leaf_count = collections.defaultdict(int)
    leaf_count[0] = 1
    result = 1
    for D in Ds:
        if leaf_count[D - 1] == 0:
            result = 0
            break
        else:
            result *= leaf_count[D - 1]
            result %= 998244353
            leaf_count[D] += 1
    print(result)
exit(0)


Measured memory_bytes: 19928
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

bool Lunlun(ll x){
    ll pre=x%10;
    x/=10;
    while(x>0){
        ll n=x%10;
        if(abs(pre-n)>1) return false;
        x/=10;
        pre=n;
    }
    return true;
}

int main(){
    fast_io
    
    ll k;
    cin>>k;
    
    queue<ll> que;
    for(int i=1;i<=9;i++){
        que.push(i);
    }
    ll ans;
    rep(i,k){
        ll x=que.front(); que.pop();
        if(x%10!=0) que.push(10*x+x%10-1);
        que.push(10*x+x%10);
        if(x%10!=9) que.push(10*x+x%10+1);
        ans=x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int a[101];
int main(){
	ull sum=0,i,n,bad=0,min=101;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
		if(a[i]%10==0)
			bad++;
		if(a[i]<min&&a[i]%10!=0)
			min=a[i];
	}
	if(sum%10!=0)
		cout<<sum;
	else if(bad==n)
		cout<<"0";
	else if(sum%10==0&&bad!=n)
		cout<<sum-min;
	return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	int a[30]={};
	for(int i=0;i<n;i++)
	{
		int b;
		cin>>b;
		int c=-1;
		for(int j=0;j<b;j++)
		{
			cin>>c;
			a[c-1]++;
		}
	}
	int cnt=0;
	for(int i=0;i<m;i++)
	{
		if(a[i]==n)
			cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    string s; cin >> s;
    int n = s.size();
    for(int i = 0; i < n; ++i){
        if( (i + 1) % 2 == 0){
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;

            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
int cnt0,cnt1;
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		if(read()&1)++cnt1;
		else ++cnt0;
	}
	while(cnt1>1)++cnt0,cnt1-=2;
	puts(cnt1&&cnt0?"NO":"YES");
	return 0;
}



Measured memory_bytes: 3580
import java.util.*;
import java.awt.geom.*;
public class Main {
	
	private void doit(){
		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		while(n-- > 0){
			String s = sc.nextLine();
			System.out.println(s.replaceAll("Hoshino", "Hoshina"));
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] R = new int[N];
		Arrays.fill(R, -1);
		for (int i = 0; i < K; ++i) {
			int A = sc.nextInt() - 1;
			int B = sc.nextInt() - 1;
			R[A] = B;
		}
		int[][][] dp = new int[3][3][N];
		if (R[0] == -1) {
			dp[1][0][0] = dp[2][1][0] = dp[0][2][0] = 1;
		} else {
			dp[(R[0] + 1) % 3][R[0]][0] = 1;
		}
		for (int i = 1; i < N; ++i) {
			if (R[i] == -1) {
				for (int j = 0; j < 3; ++j) {
					for (int k = 0; k < 3; ++k) {
						dp[j][k][i] += dp[(j + 1) % 3][j][i - 1];
						dp[j][k][i] += dp[(j + 2) % 3][j][i - 1];
						if (j != k) dp[j][k][i] += dp[j][j][i - 1];
						dp[j][k][i] %= 10000;
					}
				}
			} else {
				for (int j = 0; j < 3; ++j) {
					dp[j][R[i]][i] += dp[(j + 1) % 3][j][i - 1];
					dp[j][R[i]][i] += dp[(j + 2) % 3][j][i - 1];
					if (j != R[i]) dp[j][R[i]][i] += dp[j][j][i - 1];
					dp[j][R[i]][i] %= 10000;
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				ans += dp[i][j][N - 1];
			}
		}
		System.out.println(ans % 10000);
	}
}

Measured memory_bytes: 18088
#include<cstdio>
#include<algorithm>
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
#define per(i,x,y) for(int i=(x);i>=(y);--i)
int n;
int main(){
	scanf("%d",&n);
	int lst=0,dir=0;
	int ans=1;
	rep(i,1,n){
		int x;scanf("%d",&x);
		if(dir==0){
			if(lst){
				if(lst<x)dir=1;
				if(lst>x)dir=-1;
			}
		}else{
			if((dir==1&&lst>x)||(dir==-1&&lst<x)){
				lst=0;++ans;dir=0;
			}
		}
		lst=x;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define PB push_back
#define MP make_pair
#define F first
#define S second

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

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

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

int main(){
	ll K,ans=0;
	cin >> K;
  	for(int i=1;i<=K;i++){
    	for(int j=1;j<=K;j++){
        	for(int k=1;k<=K;k++){
            	ans+= gcd(gcd(i,j),k);
            }
        }
    }
  	cout << ans << endl;
  
}

Measured memory_bytes: 3196
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []
for i in range(N):
	A.append(list(map(int, input().split())))
	
def main():
	cnt = 0
	for i in range(N):
		val = C
		for j in range(M):
			val += A[i][j] * B[j]
		if val > 0:
			cnt += 1
	return cnt
print(main())


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int x[1180][118][118],n,m,p,a,b,c;
int main(){
while(true){
memset(x,0,sizeof(x));
cin>>n>>m>>p;if(!n){break;}
for(int i=0;i<m;i++){
cin>>a>>b>>c;
x[a][b][c]=1;x[a][c][b]=1;
}
for(int i=1000;i>0;i--){
for(int j=1;j<=n;j++){
if(x[i][p][j]==1){
p=j;
break;
}
}
}
cout<<p<<endl;
}
}

Measured memory_bytes: 65348
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
#include <map>
#include <queue>
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int mn = a[0];
	int ans = 0;
	int ret = 0;
	for (int i = 1; i < n; i++) {
		if (mn >= a[i]) {
			ret++;
			
		}

		else {
			
			ans = max(ans, ret);
			ret = 0;
		}
		ans = max(ans, ret);
		mn = a[i];

	}
	ans = max(ans, ret);
	cout << ans;


}

Measured memory_bytes: 640
/*
8 9
7 9 3 2 3 8 4 6
*/
#include <bits/stdc++.h>
using namespace std;
void print() { cout << '\n'; } template<class T, class ...U> void print(T x, U ...y) { cout << x << ' '; print(y...); }
typedef long long ll; const int N = 2e5 + 5, M = 1e9 + 7; typedef vector<int> vi; typedef vector<vi> vii; void Main();
int main(int argc, char **argv) {
  ios::sync_with_stdio(0), cin.tie(0); cout << setprecision(10) << fixed;
  #ifdef Zmm
  freopen((string(*(argv)).substr(2, string(*(argv)).size() - 6) + string(".cpp")).c_str(), "r", stdin); string x; cin >> x;
  #endif
  Main();
}
int a[N];
void Main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int i = n - 1;
  for (; i >= 0 && k > 0; i--, k--);
  ll sum = 0;
  for (; i >= 0; i--) sum += a[i];
  cout << sum << '\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
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; }


int main(){

    string num; cin >> num;
  	bool ex = false;
  	rep(i,num.size()) if(num.at(i) == '7') ex = true;
  	ex? cout<< "Yes" : cout << "No";
  	cout << endl;
    return 0;   

}


Measured memory_bytes: 3612
#include <stdio.h>
int main(void)
{
  int n, x;
  int i = 1;
  scanf("%d", &n);
  while (n >= i) {
    x = i;
    if (x % 3 == 0) {
        printf(" %d", i);
        i++;
        continue;
   }
    while (x != 0) {
      if (x % 10 == 3) {
        printf(" %d", i);
        break;
      }
      x /= 10;
    }
    i++;
  }
  putchar('\n');
  return 0;
}

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


s = input()
t = input()
i = 0
count = 0

while i < len(s):
    s = list(s)
    a = s.pop(0)
    s.append(a)
    s = ''.join(s)

    if s == t:
        count += 1

    i += 1


if count >= 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int N, R[10];
string S, T;

bool ok(int *r) {
  REP(i, 0, N) if(r[i] != 0) return false;
  return true;
}

int dfs(int *r, int k, int n) {
  if(ok(r)) return n;
  if(r[k] == 0) {
    return dfs(r, k + 1, n);
  } else {
    int ret = N;
    int d = r[k];
    REP(i, k, N) {
      r[i] = (r[i] - d + 10) % 10;
      if(ret > n + 1) ret = min(ret, dfs(r, k + 1, n + 1));
    }
    REP(i, k, N) r[i] = (r[i] + d) % 10;
    return ret;
  }
}

int main(void) {
  while(cin >> N, N) {
    cin >> S >> T;
    REP(i, 0, N) R[i] = (S[i] - T[i] + 10) % 10;
    cout << dfs(R, 0, 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 3144
#!/usr/bin/env python3

n = int(input())
s = [input() for _ in range(n)]

nac = nwa = ntle = nre = 0 
for i in range(n):
    if s[i] == 'AC':
        nac += 1
    if s[i] == 'WA':
        nwa += 1
    if s[i] == 'TLE':
        ntle += 1
    if s[i] == 'RE':
        nre += 1

print('AC x {}'.format(nac))
print('WA x {}'.format(nwa))
print('TLE x {}'.format(ntle))
print('RE x {}'.format(nre))


Measured memory_bytes: 16272
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
bool dp[2005][100005];
int main(){
  ll n,sum=0;
  cin>>n;
  for(ll i=0;i<2005;i++){
    for(ll j=0;j<100005;j++) dp[i][j]=false;
  }
  dp[0][0]=true;
  if(n==1){
    ll a;
    cin>>a;
    cout<<a<<endl;
    return 0;
  }
  else if(n<25){
    ll array[27];
    for(int i=0;i<n;i++) cin>>array[i];
    vector<ll> v;
    for(int b=0;b<(1<<n);b++){
      ll kans=0;
      for(int i=0;i<n;i++){
        if(((b>>i)&1)==1) kans+=array[i];
      }
      v.push_back(kans);
    }
    sort(v.begin(),v.end());
    int idx=1;
    for(int i=1;i<n;i++) idx*=2;
    cout<<v[idx]<<endl;
    return 0;
  }
  for(ll i=0;i<n;i++){
    ll a;
    cin>>a;
    sum+=a;
    for(ll j=0;j<100005;j++){
      if(dp[i][j]){
        if(j+a<100005) dp[i+1][j+a]=true;
        if(abs(j-a)<100005) dp[i+1][abs(j-a)]=true;
      }
    }
  }
  ll ans=1e15;
  for(ll i=0;i<100005;i++){
    if(dp[n][i]) ans=min(ans,i);
  }
  cout<<(sum+ans)/2<<endl;
}


Measured memory_bytes: 204652
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <set>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef vector<DT> vec;
typedef list<DT> li;



int main() {
	ifstream fin("Text.txt");
	int i, j, k=0 , l,r,z=0;
	string s1, s2;
	cin >> k;
	cin >> s1 >> s2;
	l = s2.size();
	r = s1.size();
	forn(i, min(l,r)) {
		forc(j, r - 1 - i, r - 1) {
			if (s1[j] != s2[j - r + 1 + i])
				break;
		}
		if (j == r)
			z = max(z, i + 1);
	}
	cout << l+r-z << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int ans = -1;
  int A, B; cin>>A>>B;
  if(A < 10 && B < 10) ans = A*B;
  cout << ans << endl;
  return 0;
}


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

int main() {
 string S;
  cin >> S;
 
  string T;
  if(S.size() % 2 == 0) {
  for(int i = 0; i < S.size() / 2; i++) {
    T += S.at(2 * i);
  }
  }
  
    else {
      for(int i = 0; i < (S.size() + 1) / 2; i++) {
        T += S.at(2 * i);
      }
    }
  cout << T << endl;
  
  
}
  

Measured memory_bytes: 512
n = input()
U = [raw_input() for _ in range(n)]
m = input()
T = [raw_input() for _ in range(m)]

isOpen = False

for t in T:
    if t in U:
        if isOpen:
            isOpen = False
            print "Closed by " + t
        else:
            isOpen = True
            print "Opened by " + t
    else:
        print "Unknown " + t

Measured memory_bytes: 6440
#include <iostream>
#include <regex>
#include <string>
#include <vector>

using namespace std;

int main() {
  string S;
  regex re("(A|C|G|T)+");
  smatch match;
  vector<string> results;
  int max = 0;

  cin >> S;

  for (auto it = S.cbegin(); regex_search(it, S.cend(), match, re); it++) {
    results.push_back(match[0]);
  }

  for (auto r : results) {
    if (r.length() >= max) {
      max = r.length();
    }
  }

  cout << max << endl;
  return 0;
}

Measured memory_bytes: 888
n,m=map(int,input().split())
c=[0]*m
for i in range(n):
    li=list(map(int,input().split()))
    for j in range(li[0]):
        c[li[j+1]-1]+=1
        ans=0
for i in range(m):
    if c[i]==n:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,K;
	cin>>N>>K;
	vector<int> s(N);
	rep(i,N)cin>>s[i];
	sort(all(s));
	int ans = 0;
	rep(i,K){
		ans += s[N-1-i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
var body = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  body += chunk;
});
 
readable.on( 'end', function() {
  var data = body.split( '\n' );
  var output = [];
  for( var i=0; i<data.length; i++ ) {
    if( 0 != data[i] ) {  
      output.push( 'Case '+(i+1)+': '+data[i] );
    }
  }
  console.log( output.join( '\n' )  );
});

Measured memory_bytes: 11180
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanLines)
	max := 0.0
	min := 1000000.0
	for sc.Scan() {
		n, _ := strconv.ParseFloat(sc.Text(), 64)
		if max < n {
			max = n
		}
		if min > n {
			min = n
		}
	}
	fmt.Println(max - min)
}


Measured memory_bytes: 1092
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int n;
    cin>>n;
    bool flag=false;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                flag=true;
                break;
            }
        }
        if(flag)break;
    }
    if(flag)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    char c;
    cin>>c;
    cout<<(c=='A'?'T':c=='T'?'A':c=='G'?'C':'G')<<endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
points=[int(input()) for _ in range(N)]
points=sorted(points)

MAX_P=sum(points)
if MAX_P%10==0:
    for i in points:
        if i%10!=0:
            MAX_P=MAX_P-i
            break

if MAX_P%10==0:
    print(0)
else:
    print(MAX_P)

Measured memory_bytes: 3060
H, W = map(int, input().split())
a = [input() for _ in range(H)]
grid = [[True]*W for _ in range(H)]
for i in range(H):
    flag = True
    for j in range(W):
        if a[i][j] == '#':
            flag = False
    if flag:
        for k in range(W):
            grid[i][k] = False

for i in range(W):
    flag = True
    for j in range(H):
        if a[j][i] == '#':
            flag = False
    if flag:
        for k in range(H):
            grid[k][i] = False  

for i in range(H):
    for j in range(W):  
        if grid[i][j]:
            print(a[i][j], end="")
    print()
        


Measured memory_bytes: 43112
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b;
    cin>>a>>b;
    string s[a];
    for(int i=0;i<a;i++)
    {
        cin>>s[i];
    }
    int dp[a][b];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<b;j++)
        {
            if(s[i][j]=='.'){
                if(i==0 && j==0)dp[i][j]=1;
                else if(i==0)dp[i][j]=dp[i][j-1];
                else if(j==0)dp[i][j]=dp[i-1][j];
                else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[a-1][b-1]<<"\n";
}

Measured memory_bytes: 5248
#include<stdio.h>
int main(void){
  
  int a;
  scanf("%d",&a);
  if(a % 1000 == 0){
    printf("0");
  }else{
  int b = a / 1000;
    printf("%d",(b+1)*1000 - a);
  }
  
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int main ()
{
	int a, result{0}, max{0}, n;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		result+=a;
		if (max<a) max=a;
	}
	if (max<result-max) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

ll pow_mod(ll x,ll y){
    if(y==0)return 1;
    if(y%2==1)return (x*pow_mod(x,y-1))%MOD;
    ll t=pow_mod(x,y/2);return (t*t)%MOD;
}
//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

const int MXN=200001;//変更可
ll fac[MXN],inv[MXN],finv[MXN];

void COMinit(int M) {
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<MXN;i++){
        fac[i]=fac[i-1]*i%M;
        inv[i]=M-M/i*inv[M%i]%M;
        finv[i]=finv[i-1]*inv[i]%M;
    }
}

ll COMBI(int N,int K,int M){
    if(N<K){
        return 0;
    }
    if(N<0||K<0){
        return 0;
    }
    return fac[N]*finv[N-K]%M*finv[K]%M;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,A,B,C;//Cは別物として考えていい（線形性より）
    cin >> N >> A >> B >> C;
    COMinit(MOD);
    ll resA=0,resB=0,powa=1,powb=1;
    rep(i,N){//aoki が i 回勝つ
        resA+=(N+i)*((powb*COMBI(N-1+i,i,MOD))%MOD)%MOD;
        powb*=(B*inv[A+B])%MOD;
        powb%=MOD;
        resA%=MOD;
    }
    resA*=pow_mod(A,N);
    rep(i,N){//takahashi が i 回勝つ
        resB+=(N+i)*((powa*COMBI(N-1+i,i,MOD))%MOD)%MOD;
        powa*=(A*inv[A+B])%MOD;
        powa%=MOD;
        resB%=MOD;
    }
    resB*=pow_mod(B,N);
    resA%=MOD;resB%=MOD;
    ll res=(resA+resB)%MOD;
    res*=pow_mod(inv[A+B],N);
    res%=MOD;
    res*=100;
    res%=MOD;
    res*=inv[100-C];
    res%=MOD;
    cout << res << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector< pair<int,int> > v(m);
    for (int i=0; i<m; i++) {
        cin >> v[i].first >> v[i].second;
    }

    int cnt = 0;
    int pos = 1;
    int nxt = pos;
    while (1) {
        cnt++;
        nxt = pos;
        for (int i=0; i<m; i++) {
            if (v[i].first <= pos && v[i].second >= nxt) {
                nxt = v[i].second + 1;
            }
        }
        if (nxt==pos) {
            cout << "Impossible" << endl;
            return 0;
        } else if (nxt==n+1) {
            cout << cnt << endl;
            return 0;
        }
        pos = nxt;
    }
}

Measured memory_bytes: 1200
n = gets.to_i
a = gets.strip.split.map(&:to_i)
answer = []

if n % 2 == 0

    for i in 0..n-1

        if i % 2 == 0

            answer[(n / 2) + (i / 2)] = a[i]

        else

            answer[(n / 2) - (i / 2) - 1] = a[i]

        end

    end

else

    for i in 0..n-1

        if i % 2 == 0

            answer[(n / 2) - (i / 2)] = a[i]

        else

            answer[(n / 2) + (i / 2) + 1] = a[i]

        end

    end

end

puts answer.join(' ')



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

int main(){
    std::string s;
    auto k = 0LL;
    std::cin >> s >> k;
    
    char ans = '1';
    for(int i = 0; i < s.size() && i < k; i++){
        if(s[i] != '1'){
            ans = s[i];
            break;
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (u == s)
		a--;
	else
		b--;
	cout << a << " " << b;
	return 0;
}

Measured memory_bytes: 256
//Volume1-0108
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	//declare
	private static TreeMap<Integer,Integer> tm = new TreeMap<Integer,Integer>();
    private static int[] a,b;
    private static int   n;

	public static void main(String[] args) {

		String[] s;
		int cnt;

        //input
        Scanner sc = new Scanner(System.in);
        while((n = Integer.parseInt(sc.nextLine())) != 0){
        	a  = new int[n];
        	s = sc.nextLine().split("\\s");
        	for(int i=0;i<n;i++){
        		a[i] = Integer.parseInt(s[i]);
        	}

        	//calculate
        	cnt = 0;
        	while(true){
        		tm.clear();
            	b  = new int[n];
        		cnt++;
        		for(int i=0;i<n;i++){b[i] = freq(i);}
        		if (Arrays.equals(a, b)){break;}
        		a = b;
       		}

        	//output
        	System.out.println(--cnt);
        	for(int i=0;i<n;i++){
        		System.out.print(a[i]);
        		if(i < n - 1){
        			System.out.print(" ");
        		} else {
                	System.out.println();
        		}
        	}
        }
	}

	private static int freq(int i){
		if(tm.get(i) != null){return tm.get(i);}
		int sum = 0;
		for(int k=0;k<n;k++){
			if(a[i] == a[k]){sum++;}
		}
		tm.put(i,sum);
		return sum;
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long

int main(void)
{
  ll l;
  int n;
  cin >> l >> n;
  vec<ll> x(n), y(n);
  rep(i, n) cin >> x[i];
  rep(i, n) y[i] = l - x[n - 1 - i];
  vec<ll> sx(n + 1), sy(n + 1);
  sx[0] = 0; sy[0] = 0;
  rep(i, n) {
    sx[i + 1] = sx[i] + x[i];
    sy[i + 1] = sy[i] + y[i];
  }

  //a,b,c,dで b->a->c->d < b->c->a->d なので
  //２手目からはreverse

  ll maxL = 0, maxR = 0;

  rep(i, n) {
    ll temp;
    if ((n - i) % 2) {
      temp = (sx[(n + i - 1) / 2] - sx[i]) * 2 + x[(n + i - 1) / 2] + sy[(n - i - 1) / 2] * 2;
    } else {
      temp = (sx[(n + i) / 2] - sx[i]) * 2 + sy[(n - i) / 2] * 2 - y[(n - i) / 2 - 1];
    }
    if (maxL < temp) maxL = temp;
  }

  rep(i, n) {
    ll temp;
    if ((n - i) % 2) {
      temp = (sy[(n + i - 1) / 2] - sy[i]) * 2 + y[(n + i - 1) / 2] + sx[(n - i - 1) / 2] * 2;
    } else {
      temp = (sy[(n + i) / 2] - sy[i]) * 2 + sx[(n - i) / 2] * 2 - x[(n - i) / 2 - 1];
    }
    if (maxR < temp) maxR = temp;
  }

  if (maxL > maxR) cout << maxL << endl;
  else cout << maxR << endl;
  return 0;
}


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

using namespace std;
typedef int long long ill;
typedef long long ll;

int main(){
    int S; cin >> S;
    int h, m, s;
    h = S/3600;
    S = S % 3600;
    m = S / 60;
    s = S % 60;

    cout  << h << ":" << m << ":" << s << endl;

}


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

using namespace std;
long long MOD=1000000007;
long long MOD2=998244353;

int N,Ta,Ao;
int d[2][101010];
vector<vector<int>> G(101010);

void dfs(int v,int p,int flag){
  for(int u:G[v]){
    if(u==p) continue;
    d[flag][u]=d[flag][v]+1;
    dfs(u,v,flag);
  }
}

int main(){
  cin>>N>>Ta>>Ao; Ta--,Ao--;
  for(int i=0;i<N-1;i++){
    int A,B; cin>>A>>B; A--,B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  d[0][Ta]=d[1][Ao]=0;
  dfs(Ta,-1,0);
  dfs(Ao,-1,1);
  int ans=0;
  for(int i=0;i<N;i++){
    if(d[0][i]<d[1][i]){
      ans=max(ans,d[1][i]-1);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12928
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
m=int(n/1.08)
if int(m*1.08)==n:
    print(m)
elif int((m+1)*1.08)==n:
    print(m+1)
else:
    print(":(")

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;

    for(int i=0; i<N; i++){
        if(i==K-1){
            cout << "abc"[(S[i]-'A')];
        }else{
            cout << S[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";repi(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";repi(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);cerr<<"  "<<name<<"\t:"<<x<<endl;dump_f(nx,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,Ts&&... ts){cerr<<"[ln:"<<ln<<"]"<<endl;dump_f(nm,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))


int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    //-----------------------------------
    int t=1,ans=0;
    rep(i,N){
        if(A[i]==t){
            t++;
        }else{
            ans++;
        }
    }
    if(ans==N)ans=-1;


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

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int main() {
	int k,x,y;
	cin>>k;
	x=0;
	y=0;
	for(int i=1;i<=k;i++){
		if(i%2==0){
			x++;
		}
		else{
			y++;
		}
	}
	cout<<x*y<<endl;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int N; cin >> N;
    ll ans = 0, cnt = 0;
    rep(i, N) {
        int x; cin >> x;
        if (x == 0) {
            ans += cnt / 2;
            cnt = 0;
        }
        cnt += x;
    }
    ans += cnt / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll N, K;
    cin >> N >> K;
    ll A[N + 10];
    for(ll i = 0; i < N; i++)
    {
        cin >> A[i];   
    }    
    bool dp[K + 10] = {false};
    for(ll i = 0; i < A[0]; i++)
    {
        dp[i] = false;
    }
    for(ll i = 0; i < N; i++)
    {
        dp[A[i]] = true;
    }
    for(ll i = A[0] + 1; i <= K; i++)
    {
        ll state = false;
        for(ll j = 0; j < N; j++)
        {
            ll pos = i - A[j];
            if((pos >= 0)&&(!dp[pos]))
            {
                state = true;
            }
        }
        dp[i] = state;
    }
    if(!dp[K])
        cout << "Second" << endl;
    else
        cout << "First" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

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

int main(){
  string s;
  int fx = 0;

  cin >> s;
  
  rep(i, s.length()){
   	fx += s[i] - '0';
  }
  
  if(atoi(s.c_str()) % fx){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
  return 0;
}

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

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

	long long c = a + b;
	long long d = n / c;
	long long e = n % c;

	long long ret = d * a;

	if (a <= e) {
		ret += a;
	}
	else {
		ret += e;
	}

	cout << ret << endl;

	return 0;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

const int mxn = 5e5;
const int M = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % M;
		b = (b * b) % M;
		e >>= 1; // e/=2;
	}
	return res;
}

ll iv[mxn + 1], f1[mxn + 1], f2[mxn + 1];
ll nck(int n, int k)
{
	return f1[n] * f2[k] % M * f2[n - k] % M;
}

int main()
{
	fast;
	int n, m, k;
	cin >> n >> m >> k;
	cout << m / k - (n - 1) / k;
}

Measured memory_bytes: 3592
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

int d,cnt[19],ans=0;
ll pw[19];

void dfs(int p,ll s,int c,int lim) {
	if (p>=lim/2) {
		if (s==d) ans+=c*(lim&1?10:1);
		return;
	}
	int x=-9;
	while (x<9&&s+(x+1)*(pw[lim-p-1]-pw[p])<=d) ++x;
	dfs(p+1,s+x*(pw[lim-p-1]-pw[p]),c*(p==0&&x>=0?cnt[x+9]-1:cnt[x+9]),lim);
	if (++x<=9) dfs(p+1,s+x*(pw[lim-p-1]-pw[p]),c*(p==0&&x>=0?cnt[x+9]-1:cnt[x+9]),lim);
}

int main() {
	d=read();
	for (int i=0;i<=9;++i)
		for (int j=0;j<=9;++j) ++cnt[i-j+9];
	pw[0]=1;
	for (int i=1;i<=18;++i) pw[i]=10ll*pw[i-1];
	for (int i=1;i<=18;++i) dfs(0,0,1,i);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3780
#include<stdio.h>

int main()
{
 char fest[60];
 int i;
 int count=0;

 scanf("%s",&fest);
 for(i=0;i<55;i++)
 {
  if((fest[i]>='A')&(fest[i]<='Z'))
  {
   count++;
  }else{
   break;
  }
 }

 for(i=0;i<(count-8);i++) printf("%c",fest[i]);
 printf("\n");

 return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
int N; cin >> N;
VI A(N); rep(i,0,N) scanf("%d", &A[i]);
unordered_map<int, bool> paper; // {言われた数，言われたことがあったらtrue,なかったらfalse}

rep(i, 0, N){
    paper[A[i]] = !paper[A[i]];
}
int cnt=0;
for(pair<int,bool> p : paper) {
    if (p.second) ++cnt;
}

cout << cnt << "\n";

return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.


Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
char s[100007];
int vis[37];
const long long mod =1e9+7;
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<26;i++)
        vis[i]++;
    for(int i=0;i<n;i++)
        vis[s[i]-'a']++;
    long long ans=1;
    for(int i=0;i<26;i++){
        ans*=vis[i];
        ans%=mod;
    }
    ans=(ans+mod-1)%mod;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 384