akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
  int n, m;
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    char num[10], upper[26], lower[26];
    for (int i = 0; i < 10; i++)
      num[i] = i+'0';
    for (int i = 0; i < 26; i++)
      upper[i] = i+'A';
    for (int i = 0; i < 26; i++)
      lower[i] = i+'a';

    char bef, aft;
    for (int i = 0; i < n; i++) {
      cin >> bef >> aft;
      if ('0' <= bef && bef <= '9')
        num[bef-'0'] = aft;
      else if ('A' <= bef && bef <= 'Z')
        upper[bef-'A'] = aft;
      else if ('a' <= bef && bef <= 'z')
        lower[bef-'a'] = aft;
    }

    cin >> m;
    string result  = string("");
    char c;
    for (int i = 0; i < m; i++) {
      cin >> c;
      if ('0' <= c && c <= '9')
        result += num[c-'0'];
      else if ('A' <= c && c <= 'Z')
        result += upper[c-'A'];
      else if ('a' <= c && c <= 'z')
        result += lower[c-'a'];
    }

    cout << result << endl;
  }
  return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    
    if((a*b)%2==0){
        cout<<"Even"<<endl;
    }
    
    else if((a*b)%2==1){
        cout<<"Odd"<<endl;
    }
}

Measured memory_bytes: 3644
X,Y = map(int,input().split())
if 2 * X > Y:
    ret = 'No'
else:
    if (Y - 2 * X) % 2 == 1:
        ret = 'No'
    else:
        if (Y - 2 * X) // 2 <= X:
            ret = 'Yes'
        else:
            ret = 'No'
print(ret)


Measured memory_bytes: 9112
import itertools as it
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
a = 0
b = 0
array = list(it.permutations(i for i in range(1,N+1)))
for i,ar in enumerate(array):
    if ar == P:
        a = i
    if ar == Q:
        b = i
print(abs(a-b))

Measured memory_bytes: 13972
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; scanf("%d",&n);
	vector<int> c(26);
	for(int i=0;i<c.size();++i) scanf("%d",&c[i]);
	vector<vector<int> > s(n);
	for(int i=0;i<n;++i){
		s[i].resize(26);
		for(int j=0;j<26;++j)
			scanf("%d",&s[i][j]);
	}
	for(int i=0;i<n;++i){
		int k=0;
		for(int j=1;j<26;++j)
			if(s[i][j]>s[i][k]) 
				k=j;
		printf("%d\n",k+1);
	}
	return 0;
}


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


typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vi a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll kane=1000;
    ll kabu=0;
    if(a[0]<=a[1]){
        kabu+=kane/a[0];
        kane=kane%a[0];
    }
    for(int i=1;i<n-1;i++){
        if(a[i]>=a[i-1]){
            kane+=kabu*a[i];
            kabu=0;
        }
        if(a[i]<=a[i+1]){
            kabu+=kane/a[i];
            kane=kane%a[i];
        }      
    }
    if(a[n-1]>=a[n-2]){
        kane+=kabu*a[n-1];
        kabu=0;
    }
    cout << kane << endl;
    return 0;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n;
  string s;
  cin>>n>>s;
  int cnt=0;
  int cnw=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='.')cnw++;
  }
  if(cnw==s.size()){
    cout<<0<<endl;
    return 0;
  }
  int mi=min(cnw,(int)s.size()-cnw);
  for(int i=0;i<s.size();i++){
    mi=min(cnt+cnw,mi);
    if(s[i]=='#')cnt++;
    else cnw--;
  }
  cout<<mi<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int digit(ll bit, int i){
    return ((bit >> i) & 1);
}

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll s = a[0] + a[1], x = 0;
    FOR(i,2,n) x ^= a[i];

    if(x > s || (s-x)%2 == 1){
        cout << "-1" << endl;
        return 0;
    }

    ll y = (s-x)/2;
    ll tmp = 0;

    rrep(i, 45){
        int xi = digit(x, i), yi = digit(y, i);
        if(xi == 1 && yi == 1){
            cout << "-1" << endl;
            return 0;
        }
        if(xi == 0 && yi == 1) tmp += (1LL << i);
    }

    if(tmp > a[0]){
        cout << "-1" << endl;
        return 0;
    }

    ll u = tmp;

    rrep(i,45){
        int xi = digit(x, i), yi = digit(y, i);
        if(xi == 1 && yi == 0){
            if(u + (1LL << i) < a[0]) u += (1LL << i);
        }
    }

    if(u == 0){
        cout << "-1" << endl;
        return 0;
    }
    ll ans = a[0] - u;
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;



int main() {
	int N, C; cin >> N >> C;
	vector<vector<int>> cost(C + 2, vector<int>(C + 2));
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> cost[i][j];
		}
	}
	vector<vector<int>> cnt(5, vector<int>(C + 2));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			int c; cin >> c;
			cnt[(i + j) % 3][c - 1]++;
		}
	}

	int ans = 2e9;
	for (int a = 0; a < C; a++) {
		for (int b = 0; b < C; b++) {
			if (a == b) continue;
			for (int c = 0; c < C; c++) {
				if (a == c || b == c) continue;
				int s = 0;
				for (int i = 0; i < C; i++) {
					s += cost[i][a] * cnt[0][i];
					s += cost[i][b] * cnt[1][i];
					s += cost[i][c] * cnt[2][i];
				}
				ans = min(ans, s);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string S; cin >> S;
  int ans1 = 0, ans2 = 0;
  rep(i,S.size()) {
    if (i%2==0 && S[i]=='0') ++ans1;
    if (i%2==0 && S[i]=='1') ++ans2;
    if (i%2==1 && S[i]=='1') ++ans1;
    if (i%2==1 && S[i]=='0') ++ans2;
  }
  cout << min(ans1, ans2) << endl;

  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k;
	cin>>n>>k;
	vector<ll> h(n);
	for(auto &x : h){
		cin>>x;
	}
	sort(h.begin(), h.end());
	while(k--){
		if(h.empty())break;
		h.pop_back();
	}
	ll ans = accumulate(h.begin(), h.end(), 0LL);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Linq;
namespace ARC096
{
    class Program
    {
        static void Main()
        {
            long[] abcxy = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long a, b, c, x, y;
            a = abcxy[0];
            b = abcxy[1];
            c = abcxy[2];
            x = abcxy[3];
            y = abcxy[4];
            long ans = 0;

            if (a + b > c * 2)
            {
                ans += Math.Min(x, y) * 2 * c;
                if (Math.Max(x, y) == x)
                {
                    x -= y;
                    if (c * 2 > a)
                        ans += x * a;
                    else
                        ans += x * 2 * c;
                    Console.WriteLine(ans);
                }
                else
                {
                    y -= x;
                    if (c * 2 > b)
                        ans += y * b;
                    else
                        ans += y * 2 * c;
                    Console.WriteLine(ans);
                }
            }
            else
            {
                ans += Math.Min(x, y) * (a + b);
                if (Math.Max(x, y) == x)
                {
                    x -= y;
                    if (c * 2 > a)
                        ans += x * a;
                    else
                        ans += x * 2 * c;
                    Console.WriteLine(ans);
                }
                else
                {
                    y -= x;
                    if (c * 2 > b)
                        ans += y * b;
                    else
                        ans += y * 2 * c;
                    Console.WriteLine(ans);
                }
            }
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int main()
{
    int n, a, v, a_res=21, v_res=0;
    while(cin>>n) {
        while(n--) {
            cin >> a >> v;
            if ((v_res == v && a_res > a) || (v_res < v)) {
                a_res = a;
                v_res = v;
            } 
        }
        cout << a_res << " " << v_res << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>

int main()
{
	int a, b;
	char op;

	while (std::cin >> a >> op >> b) {
		if		(op == '?') break;
		else if (op == '+') printf("%d\n", a + b);
		else if (op == '-') printf("%d\n", a - b);
		else if (op == '*') printf("%d\n", a * b);
		else if (op == '/') printf("%d\n", a / b);
	}

	return 0;
}


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

void push(int);
int pop(void);

/*外部変数*/
int top,S[100];

int main()
{
 
  int top,x,y,z;
  char s[100];


  top=0;
  while(scanf("%s",s) != EOF){

    if(s[0] == '+'){
      x = pop();
      y = pop();
      push(x+y);
    }
    else if(s[0] == '-'){
      y = pop();
      x = pop();
      push(x-y);
    }
    else if(s[0] == '*'){
      x = pop();
      y = pop();
      push(x*y);
    }
    else{ 
      z = atoi(s);
      push(z);
    }
  }

  printf("%d\n",pop());
  return 0;
}

/*数字を入れる*/
void push(int x)
{
  S[++top] = x;
}
/*数字を取り出す*/
int pop()
{

  top--;

  return S[top+1];
}

Measured memory_bytes: 548
import java.io.*;
import java.util.Arrays;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));
        String[] str = bf.readLine().split(" ");
        int N = Integer.parseInt(str[0]),
            M = Integer.parseInt(str[1]);
        if(N >= M){
            System.out.println("0");
            return;
        }
        int[] X = new int[M];
        str = bf.readLine().split(" ");
        for(int i = 0; i < M; i++){
            X[i] = Integer.parseInt(str[i]);
        }
        Arrays.sort(X);
        int[] L = new int[M-1];
        for(int i = 0; i < M-1; i++){
            L[i] = X[i+1] - X[i];
        }
        Arrays.sort(L);
        int sumL = 0;
        for(int i = 0; i < N-1; i++){
            sumL += L[M-i-2];
        }
        System.out.println(X[M-1]-X[0]-sumL);
    }
}

Measured memory_bytes: 35632
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
ll gcd(ll a, ll b) {
    if(a < b)
        gcd(b, a);
    ll r = 1;
    while(r != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
int main() {
    ll k;
    cin >> k;
    ll ans = 0;
    for(ll i = 1; i <= k; i++) {
        for(ll j = 1; j <= k; j++) {
            for(ll m = 1; m <= k; m++) {
                ans += gcd(gcd(i, j), m);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
typedef double db;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	return x*f;
}
const int N=607,INF=1e9;
int n,m,a[N*N],b[N*N];
vector <int> V[N];
db f[N],ans;
inline db calc(int p)
{
	for(int i=1;i<=n;i++) f[i]=0;
	f[n]=0;
	for(int i=n-1;i>=1;i--)
	{
		int len=V[i].size();
		if(p==i&&len==1) { f[i]=INF; continue; }
		db t=1.0/(len-(p==i)),mx=0;
		for(int j=0;j<len;j++)
		{
			int v=V[i][j]; mx=max(mx,(f[v]+1)*t);
			f[i]+=(f[v]+1)*t;
		}
		if(p==i) f[i]-=mx;
	}
	return f[1];
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		a[i]=read(),b[i]=read();
		V[a[i]].push_back(b[i]);
	}
	ans=calc(0);
	for(int i=1;i<=n;i++)
		ans=min(ans,calc(i));
	printf("%.9lf\n",ans);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  VV<> g(n);
  V<> d(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v; cin >> u >> v, --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
    ++d[u];
    ++d[v];
  }
  queue<int> que;
  for (int v = 0; v < n; ++v) if (d[v] == 1) {
    que.push(v);
  }
  V<bool> b(n);
  while (!que.empty()) {
    int v = que.front(); que.pop();
    if (b[v]) continue;
    b[v] = true;
    int p;
    for (int w : g[v]) if (!b[w]) {
      p = w;
      break;
    }
    b[p] = true;
    for (int w : g[p]) if (!b[w]) {
      if (--d[w] == 0) return cout << "First" << '\n', 0;
      if (d[w] == 1) que.push(w);
    }
  }
  cout << "Second" << '\n';
}

Measured memory_bytes: 7900
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const double PI = 3.14159265359;

double area(double a,double b,double angle){
    if(angle < atan2(b,a))return ((b - tan(angle) * a) + b) * a / 2;
    return (tan(PI / 2 - angle) * b) * b / 2;
}

int main(){
    double a,b,x;

    cin >> a >> b >> x;
    x /= a;

    double begin = 0;
    double end = PI / 2;
    double ans = 0;

    for(int i = 0;i < 10000;i++){
        double m = (begin + end) / 2;
        if(x < area(a,b,m)){
            begin = m;
            ans = m;
        }else{
            end = m;
        }
    }

    cout << fixed << setprecision(11) << (180 / PI) * ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
s_list = list(s)
s_set = set(s_list)

s_list.count(s_set)
flag = 0
for S in s_set:
    if( s.count(S) != 1):
        flag = 1
        break

if flag == 1:
    print("no")
else:
    print("yes")

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	ll a[114514];
	cin>>k;
	REP(i, k){
		cin>>a[i];
	}
	ll lb=2, ub=2;
	bool ok=true;
	FORR(i, 0, k){
		ll lb2=((lb-1)/a[i]+1)*a[i];
		ll ub2=ub/a[i]*a[i]+a[i]-1;
		if(lb2>ub){
			ok=false;
			break;
		}
		lb=lb2;
		ub=ub2;
		// DEBUG(lb);
		// DEBUG(ub);
	}
	if(ok){
		cout<<lb<<' '<<ub<<'\n';
	}
	else{
		cout<<-1<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;


int main(void){
    int n;
    cin>>n;

    int base[4]={0};
    int score=0;
    int out=0;
    char s[100];
    while(scanf("%s",s,stdin)!=EOF){
        if(strcmp(s,"HIT")==0){
            score+=base[3];
            base[3]=base[2];
            base[2]=base[1];
            base[1]=1;
        }
        if(strcmp(s,"HOMERUN")==0){
            score+=(base[3]+base[2]+base[1]+1);
            base[1]=0;
            base[2]=0;
            base[3]=0;
        }
        if(strcmp(s,"OUT")==0){
            out+=1;
            if(out==3){
                out=0;
                base[1]=0;
                base[2]=0;
                base[3]=0;
                cout<<score<<endl;
                score=0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	pair<long long int, long long int> A[200010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i].second >> A[i].first; 
	}
	sort(A, A+N); 
	long long int time = 0; bool possible = true; 
	for(int i = 0; i < N; i++){
		time += A[i].second; 
		if(time > A[i].first){
			possible = false; break; 
		} 
	}
	if(possible) cout << "Yes" << endl; 
	else cout << "No" << endl; 
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define all(x) x.begin(), x.end()

int binpow(int a, int b)
{
    int ans = 1;
    if (b == 0)
        return 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        int a[n];
        int sum = 0;
        for (int i = 0; i < n; ++i)
        {
            sum += s[i] - '0';
        }
        if (sum % 9 == 0)
            cout << "Yes"
                 << "\n";
        else
        {
            cout << "No"
                 << "\n";
        }
    }
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    string s;
    cin >> s;

    vector<pair<char, int>> v;
    v.emplace_back(s[0], 1);
    REP(i, 1, s.length()){
        if(v.back().first == s[i]){
            v.back().second++;
        }
        else{
            v.emplace_back(s[i], 1);
        }
    }

    int idx = 0;
    REP(i, 1, s.size()){
        if(s[i-1] == 'R' && s[i] == 'L'){
            int a = (v[idx].second + 1) / 2;
            int b = (v[idx+1].second + 1) / 2;
            cout << a + v[idx+1].second / 2 << " " << b + v[idx].second / 2 << " ";
            i++;
            idx += 2;
            if(i == s.size()-1){
                cout << 0 << " ";
            }
        }
        else{
            if(i == s.size()-1){
                cout << 0 << " ";
            }
            cout << 0 << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 1528
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

int cal(int n){
	int ret = 0;
	while(n){
		ret += (n%10);
		n /= 10;
	}
	return ret;
}
void solve(){
	int N;
	cin >> N;
	int res = cal(N);
	cout << (N%res==0?"Yes":"No") << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

using namespace std;

int c[3][3];
int a[3],b[3];
bool ans;

bool check() {
    for (int i = 0;i < 3;i++){
        for (int j = 0;j < 3;j++){
            if (a[i]+b[j] != c[i][j]) return false;
        }
    }
    return true;
}

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

    for (int i = 0;i < 3;i++){
        for (int j = 0;j < 3;j++){
            cin >> c[i][j];
        }
    }

    for (int i = 0;i <= c[0][0];i++){
        a[0] = i;
        b[0] = c[0][0] - a[0];
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0]; 
        if (check()) {
            ans = true;
            break;
        }
    }

    cout << (ans?"Yes":"No") << endl;

    return 0;

}

Measured memory_bytes: 256
K = int(input())
A = [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]

print(A[K - 1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e7+10;
ll f[N];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<N;i++)
		for(int j=i;j<N;j+=i) f[j]++;
	ll ans=0;
	for(ll i=1;i<=n;i++) ans=ans+f[i]*i;
	cout<<ans<<endl;
 } 

Measured memory_bytes: 81760
#include<stdio.h>

int main(){
  int i, j, n, minJ, tmp, cnt=0;
  int A[100];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  for(i=0; i<n; i++){
    minJ = i;
    for(j=i+1; j<n; j++){
      if(A[j] < A[minJ]){
	minJ = j;
      }
    }
    if(minJ != i){
      tmp = A[i];
      A[i] = A[minJ];
      A[minJ] = tmp;
      cnt++;
    }
  }

  for(i=0; i<n-1; i++){
    printf("%d ", A[i]);
  } printf("%d\n", A[i]);
  printf("%d\n", cnt);
}



Measured memory_bytes: 2124
#include <stdio.h>

int main(void)
{
	int n, c;
	
	while (scanf("%d", &n), n != 0){
		c = 0;
		while (n != 1){
			c++;
			if (n % 2 == 0){
				n /= 2;
			}
			else {
				n *= 3;
				n++;
			}
		}
		printf("%d\n", c);
	}
	
	return 0;
}

Measured memory_bytes: 600
// https://atcoder.jp/contests/abc132/tasks/abc132_c
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  vlli d(n);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  SORT(d);
  cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    if (x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>
#include <unordered_map>
#include <vector>
using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int count = 0;
  for (int i = 0; i < N-2; i++) {
    if(S[i] == 'A' ){
      if(S[i+1] == 'B'){
        if(S[i+2] == 'C'){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
  
}


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

// {{{ Li Chao Tree
// 順番の関係ない Convex hull Trickの実装
// 直線追加と最小値計算がどちらも O(long N)
// Nはxの取りうる座標
struct LiChaoTree {
  const ll INF = ((ll)1) << 62;

  ll f(pair<ll, ll> line, ll x) {
    return line.first * x + line.second;
  }

  vector< ll > xs;
  vector< pair<ll, ll> > seg;
  int sz;

  LiChaoTree(const vector< ll > &x) : xs(x) {
    sz = 1;
    while(sz < xs.size())
      sz *= 2;
    while(xs.size() < sz)
      xs.push_back(xs.back() + 1);
    seg.assign(2 * sz - 1, pair<ll,ll>(0, INF));
  }

  void add_line(pair<ll, ll> line, int k, int l, int r) {
    ll m = (l + r) / 2;
    bool left = f(line, xs[l]) < f(seg[k], xs[l]);
    bool mid = f(line, xs[m]) < f(seg[k], xs[m]);

    if(mid)
      swap(seg[k], line);

    if(l + 1 >= r)
      return;
    else if(left != mid)
      add_line(line, 2 * k + 1, l, m);
    else
      add_line(line, 2 * k + 2, m, r);
  }

  void add_line(ll a, ll b) {
    add_line({a, b}, 0, 0, sz);
  }

  ll get_min(ll x) {
    ll k = lower_bound(begin(xs), end(xs), x) - begin(xs);
    k += sz - 1;
    ll ret = f(seg[k], x);
    while(k > 0) {
      k = (k - 1) >> 1;
      ret = min(ret, f(seg[k], x));
    }
    return ret;
  }
};
// }}}

ll N, C;
vector<ll> h;
ll dp[300000];

signed main() {
  cin >> N >> C;
  h.resize(N);
  rep(i, N) {
    cin >> h[i];
  }

  LiChaoTree lct(h);
  dp[0] = 0;
  lct.add_line(-2 * h[0], dp[0] + h[0] * h[0]);
  for (int i=1; i<N; i++) {
    dp[i] = lct.get_min(h[i]) + h[i] * h[i] + C;
    lct.add_line(-2 * h[i], dp[i] + h[i] * h[i]);
  }
  cout << dp[N-1] << endl;

  return 0;
}



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll H, W, h, w;
  IN(H,W,h,w);

  if(H%h==0 && W%w==0){
    OUT("No");
    return 0;
  }

  ll P =   99999999;
  ll N = -100000000;


  printf("Yes\n");
  REP(i,H){
    REP(j,W){
      if(i%h==h-1 && j%w==w-1){
        printf("%lld ", N);
      }else if(i%h==0 && j%w==0){
        printf("%lld ", P);
      }else{
        printf("0 ");
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int X = scan.nextInt();
    int Y = scan.nextInt();
    
    int max_x =scan.nextInt();
    for(int i=1;i<n;i++){
      int tmp = scan.nextInt();
      if(tmp>max_x){max_x=tmp;}
    }
    
    int min_y =scan.nextInt();
    for(int i=1;i<m;i++){
      int tmp = scan.nextInt();
      if(tmp<min_y){min_y=tmp;}
    }
    scan.close();
    
    if(max_x<min_y&&max_x>=X&&min_y<=Y){
      System.out.println("No War");
    }else{
      System.out.println("War");
    }
    
    return;
  }
}

Measured memory_bytes: 23252
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long a[200005],b[200005];
long long cnta=0,cntb=0;
long long n,k,t,ans=2345241124;
int main() {
	scanf("%lld%lld",&n,&k);
	for(int i=1; i<=n; i++) {
		scanf("%lld",&t);
		if(t>=0)a[++cnta]=t;
		else b[++cntb]=-t;
		}
	a[0]=b[0]=0;
	sort(a,a+cnta+1);
	sort(b,b+cntb+1);
	for(int i=0; i<=k&&i<=cnta; i++) {
		if((k-i)<=cntb)ans=min(ans,2*min(a[i],b[k-i])+max(a[i],b[k-i]));
		}
	cout<<ans;
	}

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

int main() {
    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }
  return 0;


    
}


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

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

using namespace std;

const int width = 7;

bool dfs(const int len,unordered_set<string>& S,string pas) {
  if( (int)pas.size() >= len ) {
    if( S.count(pas) == 0 ) {
      cout << pas << endl;
      return true;
    }
    return false;
  }
  rep(i,26) {
    string npas = pas + string(1,(char)('a'+i));
    if( dfs(len,S,npas) ) return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  unordered_set<string> S;
  rep(i,n) {
    string s;
    cin >> s;
    rep(j,(int)s.size()) {
      rep(k,width) {
        if( j + k >= (int)s.size() ) break;
        S.insert(s.substr(j,k+1));
      }
    }
  }
  REP(len,1,width) if( dfs(len,S,"") ) break;
  return 0;
}

Measured memory_bytes: 146588
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>

using namespace std;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

const long double Pi=acos(-1),e=2.718;
const int N=1e6+10,mod=1e9+7;



int main ()
{
    FASTIO
    int n ;
    cin >> n;
    vll a(n);
    vll cnt(n+1);
    for(auto &x:a){
        cin >> x;
        cnt[x]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans += (cnt[i]-1)*cnt[i]/2;
    }
    for(auto x:a){
        cout << ans - cnt[x]*(cnt[x]-1)/2 + (cnt[x]-2)*(cnt[x]-1)/2 << endl;
    }
    return 0;
}
/**
*/


Measured memory_bytes: 5760
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	if (a[0]+a[1]+a[2]>=22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
(n,),*x=$<.map{_1.split.map &:to_i}
h={}
(0..200).map{h[_1**2]=0}
p (0..n-2).sum{|i|(i+1...n).count{|j|h[x[i].zip(x[j]).sum{(_1-_2)**2}]}}

Measured memory_bytes: 14072
import fractions

a,b,c,d = map(int,input().split())
total = b-a+1

def count(x):
    if x>b:
        x_count = 0
    elif x<a:
        if a%x==0:
            tmp = 1
        else:
            tmp = 0

        x_count = (b-x)//x - (a-x)//x +tmp

    else:
        x_count = 1 + (b-x)//x

    return x_count

def lcd(x,y):
    return(x*y//fractions.gcd(x,y))

cd_count  = count(c)+count(d)-count(lcd(c,d))
answer = total-cd_count

print(answer)

Measured memory_bytes: 5048
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,0,n) {
        cin >> p[i];
        p[i]++;
    }
    queue<int> q;
    int m=0,tot=0;
    rep(i,0,n) {
        tot+=p[i];
        q.push(p[i]);
        if (q.size()>k) {
            tot-=q.front();
            q.pop();
        }
        if (q.size()==k) {
            m=max(tot,m);
        }
    }
    double ans=m;
    ans/=2;
    printf("%.10f\n",ans);
}

Measured memory_bytes: 1792
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func modPow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if (n & 1) > 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func main() {
	mod := int(1e+9) + 7
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	sort.Ints(A)
	// no bit
	S := make([]int, 61)
	// bit
	M := make([]int, 61)
	pows := make([]int, 61)
	for i := 0; i < 61; i++ {
		pows[i] = modPow(2, i, mod)
	}
	ans := 0
	for i := 0; i < N; i++ {
		for j := 0; j < 61; j++ {
			if A[i]&(1<<uint(j)) == 0 {
				S[j]++
				ans += M[j] * pows[j]
				ans %= mod
			} else {
				M[j]++
				ans += S[j] * pows[j]
				ans %= mod
			}
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 6912
#include <iostream>

using namespace std ;

int main(void) 
{
	int inN ;
	cin >> inN ;

	if (inN < 1 || inN > 1998) {
		cout << "error\n" ;
		return -1 ;
	}

	if (inN <= 999)
		cout << "ABC\n" ;
	else
		cout << "ABD\n" ;

	return 0 ;
}

Measured memory_bytes: 256
import fractions
import sys
from functools import reduce

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    N = int(readline())
    T = list(map(int, read().split()))
    print(lcm(*T))


main()


Measured memory_bytes: 5204
#include<stdio.h>

int main(){
  int h, w;
  int i, j;
  
  while(1){
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0) break;

    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
	if((i + j) % 2 == 0){
	  printf("#");
	}
	else {
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}


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

int main() {
  int n, x;
  cin >> n;
  x = n%10;
  if (x==2 || x==4 || x==5 || x==7 || x==9) cout << "hon" <<endl;
  else if (x==0 || x==1 || x==6 || x==8) cout << "pon" << endl;
  else if (x==3) cout << "bon" << endl;
  return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int N;
  cin >> N;

  vector<int> X(N, 0);
  vector<int> Y(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }

  sort(Y.begin(), Y.end());
  int mid = Y.at(N / 2);
  for (int i = 0; i < N; i++) {
    if (X.at(i) < mid) {
      cout << Y.at(N / 2) << "\n";
    } else {
      cout << Y.at(N / 2 - 1) << "\n";
    }
  }
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int cnt = 0;
    rep(i,n) if(p[i] == i+1){
        cnt++;
        if(i != n-1)swap(p[i],p[i+1]);
        else swap(p[i], p[i-1]);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3780
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

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

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    int cnt = 1;
    for(int i = 0; i < n; i++) {
        if(arr[i] == cnt) cnt++;
    }
    if(cnt == 1) cout << -1 << endl;
    else
    cout << n-cnt+1 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // メインプログラムここから
    ll n,a,sum=0;
    vector<ll> v;
    
    cin >> n;
    
    for(int i=0; i<3*n; i++){
        cin >> a;
        v.push_back(a);
    }
    
    sort(v.begin(), v.end());
    
    for(int i=n; i<3*n; i+=2){
        sum += v[i];
    }
    
    cout << sum << endl;
    // ここまで
}

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

int main()
{
  int n;
  cin >> n;
  int x[n], y[n], h[n];

  for (auto i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  const int pos_max = 100;
  for (auto py = 0; py <= pos_max; py++) {
    for (auto px = 0; px <= pos_max; px++) {
      int interim_h = 0;
      for (auto i = 0; i < n; i++) {
	if (h[i] > 0) {
	  int guess_h = h[i] + abs(px - x[i]) + abs(py - y[i]);
	  if (interim_h == 0) {
	    interim_h = guess_h;
	  } else if (interim_h != guess_h) {
	    interim_h = -1;
	    break;
	  }
	}
      }
      if (interim_h < 0) continue;
      for (auto i = 0; i < n; i++) {
	if (h[i] == 0) {
	  int guess_h = abs(px - x[i]) + abs(py - y[i]);
	  if (interim_h > guess_h) {
	    interim_h = -1;
	    break;
	  }
	}
      }
      if (interim_h < 0) continue;
      cout << px << " " << py << " " << interim_h << endl;
      return 0;
    }
  }
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef long long ll;
 
//const int INF = 1001001001;
const long long INF = 2e18;
const int MOD = 1000000007;
const double PI=acos(-1);


//-------------------------------------------------
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    for(int i=0; i<V; i++){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    for(int i=0; i<V; i++){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que; //first:dist from start, second:next v
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};

int main() {
    int n,m,s,t;
    cin >> n >> m >> s >> t;
    s--,t--;
    graph g1(n), g2(n);

    rep(i,m) {
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        u--,v--;
        g1.add_edge(u,v,a);
        g1.add_edge(v,u,a);
        g2.add_edge(u,v,b);
        g2.add_edge(v,u,b);
    }
    
    g1.dijkstra(s);
    g2.dijkstra(t);

    priority_queue<P, vector<P>> d;
    ll total = 1000000000000000;
    rep(i,n) {
        d.push(P(total-(g1.d[i] + g2.d[i]),i));
    }

    rep(i,n) {
        while (d.top().second<i) {
            d.pop();
        }
        auto ans = d.top();
        cout << ans.first << endl;
    }


}

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

using namespace std;

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

    auto chk = [=]() {
        if (s[a] != '-') return false;
        if (!all_of(s.begin(), s.begin() + a, ::isdigit)) return false;
        return all_of(s.cbegin() + a + 1, s.cend(), ::isdigit);
    };

    if (chk()) {
        cout << "Yes";
    } else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#define INFTY 10000
#define int long long
using namespace std;
int n;
int x[101];

signed main() {
    int mid = 0;
    int ans = 10000000000000;
    int sum = 0;
    cin >> n;
    for(int i = 0; i < 101; i ++){
        x[i] = INFTY;
    }
    for(int i = 0; i < n; i ++){
        cin >> x[i];
    }
    sort(x,x+n);

    for(int i = x[0]; i <= x[n-1]; i ++){
        sum = 0;
        for(int t = 0; t < n; t ++){
            sum += (x[t] - i)*(x[t] - i);
        }
        if(sum < ans) ans = sum;

    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3588
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

s=input()
for i in range(1,len(s)):
    if s[i]!=s[i-1]:
        count+=1
print(count)

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class BIT:

    def __init__(self, n):
        # 0-indexed
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    def get(self, l, r=None):
        """ 区間和の取得 [l, r) """
        # 引数が1つなら一点の値を取得
        if r is None: r = l + 1
        res = 0
        if r: res += self.sum(r-1)
        if l: res -= self.sum(l-1)
        return res

    def bisearch_left(self, l, r, x):
        """ 区間[l,r]で左からx番目の値がある位置 """
        l_sm = self.sum(l-1)
        ok = r + 1
        ng = l - 1
        while ng+1 < ok:
            mid = (ok+ng) // 2
            if self.sum(mid) - l_sm >= x:
                ok = mid
            else:
                ng = mid
        if ok != r + 1:
            return ok
        else:
            return -1

    def bisearch_right(self, l, r, x):
        """ 区間[l,r]で右からx番目の値がある位置 """
        r_sm = self.sum(r)
        ok = l - 1
        ng = r + 1
        while ok+1 < ng:
            mid = (ok+ng) // 2
            if r_sm - self.sum(mid-1) >= x:
                ok = mid
            else:
                ng = mid
        if ok != l - 1:
            return ok
        else:
            return -1

N = INT()
A = LIST()
# aの昇順に処理できるようにindexで並べておく
idxs = [0] * (N+1)
for i, a in enumerate(A):
    idxs[a] = i + 1

bit = BIT(N+2)
# 先頭と末尾に番兵を仕込む
bit.add(0, 2)
bit.add(N+1, 2)
ans = [0] * (N+1)
# 大きいaから見ていく
for a in range(N, 0, -1):
    # a(N~1)が格納されているindex
    idx = idxs[a]
    # 自分より小さいindexで2回目に自分より大きい値がある直前の場所
    p = bit.bisearch_right(0, idx, 2) + 1
    # 自分より小さいindexで最初に自分より大きい値がある直前の場所
    q = bit.bisearch_right(0, idx, 1) + 1
    # 自分より大きいindexで最初に自分より大きい値がある直前の場所
    r = bit.bisearch_left(idx, N+1, 1) - 1
    # 自分より大きいindexで2回目に自分より大きい値がある直前の場所
    s = bit.bisearch_left(idx, N+1, 2) - 1
    # aを使う回数 * a = (左に自分より大きい値がある時の通り数 + 右に自分より大きい値がある時の通り数) * a
    ans[a] = ((q-p)*(r-idx+1) + (idx-q+1)*(s-r)) * a
    # aを出現済とする
    bit.add(idx, 1)
# 全てのaについての合計
print(sum(ans))


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

int N, M;
int c;
int main( ) {
    
    scanf("%d %d", &N, &M); 
    
    if (M==0 && N==0){
        c = 0;
    }
    else if(M==1 && N==1){
        c =0;
    }
    else if(M==1 && N==0){
        c =0;
    }
    else if(M==0 && N==1){
        c =0;
    }
    else{
        c = N*(N-1)/2+M*(M-1)/2;
    }
    printf("%d\n", c);

    return 0;
}

Measured memory_bytes: 256