akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int D, G;
int p[11],c[11];

signed main()
{
	cin>>D>>G;
	G/=100;
	rep(i,D)cin>>p[i]>>c[i],c[i]/=100;

	int mn = 5000;

	for (int s = 0; s < (1 << D); ++s) {
		int score = 0, counter = 0;
		for (int i = 0; i < D; ++i) {
			if (s >> i & 1) {
				counter += p[i];
				score += (i+1)*p[i];
				score += c[i];
			}
		}

		for (int i = D - 1; i >= 0; --i) {
			if (s >> i & 1) continue;
			int zan = max(G - score, 0ll);
			int solve = min(zan / (i + 1), p[i]);
			counter += solve;
			score += (i + 1) * solve;
		}

		mn = min(mn, counter);
	}

	cout << mn << endl;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define int long long
using namespace std;
const int INF = 10000000000000;//5000000000000000

bool prime(int N) {
	bool ok = true;
	for (int i = 2; i * i <= N; i++) {
		if (N % i == 0) ok = false;
	}
	if (ok == true) return true;
	else return false;
}
signed main() {
	int X;
	cin >> X;
	int ans = 0;
	while (true) {
		if (prime(X)) break;
		X++;
	}
	cout << X << endl;
}

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

int n,a,b,t;
multiset<int>seta;
map<int,vector<int> >mapa;

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a>>b;
        seta.insert(b);
        mapa[b].push_back(a);
    }
    set<int>::iterator aux=seta.begin();
    for(int i=1;i<=seta.size();i++){
        a=mapa[*aux].size();
        a=mapa[*aux][a-1];
        t+=a;
        mapa[*aux].pop_back();
        if(t>*aux) {
            cout<<"No";
            break;
        }
        if(i==seta.size()){
            cout<<"Yes";
            break;
        }
        aux++;
    }
}


Measured memory_bytes: 31488
import sys
from collections import deque
sys.setrecursionlimit(10**6)


def main(input, print):
    vx = [0, 1, 0, -1]
    vy = [-1, 0, 1, 0]

    H, W, K = map(int, input().split())
    x1, y1, x2, y2 = map(int, input().split())
    table = [[] for _ in range(H)]
    for i in range(H):
        table[i] = list(input().strip())
    q = deque()
    q.append((x1-1, y1-1, 0))
    table[x1-1][y1-1] = 0
    while len(q) > 0:
        x, y, cnt = q.popleft()
        for i in range(4):
            for k in range(1, K+1):
                nx = x + vx[i] * k
                ny = y + vy[i] * k
                if nx < 0 or ny < 0 or nx >= H or ny >= W:
                    break
                if table[nx][ny] == '@':
                    break
                if table[nx][ny] != '.':
                    if table[nx][ny] < cnt + 1:
                        break
                    else:
                        continue
                table[nx][ny] = cnt+1
                q.append((nx, ny, cnt+1))
    if table[x2-1][y2-1] == '.':
        print(-1)
    else:
        print(table[x2-1][y2-1])


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 223732
#!/usr/bin/env python

def solve():
    K, A, B = map(int, input().split())
    Ki = K
    
    # Aまでふやす
    ans = 1
    if ans < A:
        if K < (A-ans):
            print(1+K)
            return
        K -= (A-ans)
        ans = A

    # あとは交互
    print(max(ans+(K//2)*(B-A)+K%2, 1+Ki))

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"ABC"<<endl;
    }
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
	int n, m;
	cin>>n>>m;
	int a[n], sum = 0;
	for (auto &i : a) {
		cin>>i;
		sum += i;
	}
	sort(a, a+n, greater<int>());
	int ans = 0, aux;
	if (sum % (4*m) == 0) aux = sum/(4*m);
	else aux = sum/(4*m) + 1;
	for (int i = 0; i < m; ++i) {
		if (a[i] >= aux) ans++;	
	}
	ans == m ? cout<<"Yes\n" : cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
from collections import deque
v, que, k = set(), deque([(1, 1)]), input()
while que:
    n, c = que.popleft()
    if n in (0, k):
        print c
        break
    if n not in v:
        que.append((n + 1, c + 1))
        que.appendleft((n * 10 % k, c))
        v.add(n)

Measured memory_bytes: 20080
#include <iostream>

using namespace std;
#define MAXN 100001
#define rep(i,n) for(int i=0;i<n;i++)
int par[MAXN];
int runk[MAXN];

void init(int N){
    rep(i,N)par[i] = -1;
}
int find(int x){
    if(par[x]<0)return x;
    return par[x] = find(par[x]);
}

bool issame(int a,int b){
    return find(a) == find(b);
}
void merge(int a,int b){
    a = find(a);
    b = find(b);
    if(a==b)return;
    if(par[a]>par[b])swap(a,b);
    par[a] += par[b];
    par[b] = a;
}
int size(int x){
    return -par[find(x)];
}

int main(){
    int N,M;
    int p[MAXN];
    cin >> N >> M;
    init(N);
    bool q[MAXN];
    rep(i,N)q[i] = false;
    for(int i=0;i<N;i++){
        cin >> p[i];
        p[i]--;
        if(p[i]==i)q[i] = true;
    }
    int x,y;
    for(int i=0;i<M;i++){
        cin >> x >> y;
        x--,y--;
        merge(x,y);
    }

    int ans = 0;
    rep(i,N){
        if(!q[i]){
            if(issame(i,p[i])){
                q[i] = true;
            }
        }
    }
    rep(i,N){
        if(q[i])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[201];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    char c;
    string s,s1;
    //priority_queue<int> pq;
    cin>>n>>m;
    for(i=n;i<=m;i++)
    {
        a=i/10000+i/1000%10*10;
        if(i%100==a) sum++;
    }
    cout<<sum;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    int ans = 0;
    
    for(int i=0;i<N;i++){
      a[i] = sc.nextInt();
    }
    for(int i=0;i<N;i++){
      b[i] = sc.nextInt();
    }
    
    for(int i=0;i<N;i++){
      if(a[i]>=b[i]){
        ans += a[i] - b[i];
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	vector<int> a;
	inputVector(a, n);
	
	map<int, int> m;
	rep(i, n) m[a[i]]++;

	int ret = 0;
	itrep(it, m) {
		int num = (*it).first;
		int cnt = (*it).second;
		if (cnt < num) {
			ret += cnt;
		} else {
			ret += cnt - num;
		}
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = 4;
		int num = scanner.nextInt();
		int[] k = new int[N];
		for(int i=0;i<N;i++){
			int division = (int) (1000 / (Math.pow(10, i)));
			k[i] = num / division;
			num = num % division;
		}
		if((k[0] == k[1] && k[1] ==k[2]) || (k[1] == k[2] && k[2] == k[3])){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22228
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <time.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int main(){
	while(1){
		int n;
		cin>>n;
		if(!n) break;
		vi a(n);
		for(int i=0;i<n;i++) cin>>a[i];
		vvi dp(n,vi(n+1));
		for(int j=1;j<=n;j++) for(int i=0;i<j;i++){
			dp[i][j]=dp[i][j-1];
			for(int k=j-2;k>=i;k--) if(abs(a[j-1]-a[k])<2&&dp[k+1][j-1]==j-k-2) dp[i][j]=max(dp[i][j],dp[i][k]+j-k);
		}
		cout<<dp[0][n]<<endl;
	}
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
	ll t;
	cin>>t;
	if(t>=30)
    {
      cout<<"Yes\n";
    }
  else{
     cout<<"No\n";
  }
}


Measured memory_bytes: 3632
from collections import deque
N,M = map(int,input().split())
G = {i:[0,[]] for i in range(1,N+1)}
for _ in range(N+M-1):
    a,b = map(int,input().split())
    G[a][1].append(b)
    G[b][0] += 1
hist = [0 for _ in range(N+1)]
for i in range(1,N+1):
    if G[i][0]==0:
        cur = i
        break
que = deque([cur])
hist[cur] = 1
T = [-1 for _ in range(N+1)]
T[cur] = 0
while que:
    i = que.popleft()
    for j in G[i][1]:
        if hist[j]==0:
            G[j][0] -= 1
        if G[j][0]==0:
            que.append(j)
            T[j] = i
            hist[j] = 1
for i in range(1,N+1):
    print(T[i])

Measured memory_bytes: 87652
//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define int long long

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

const int M = 998244353;
const int maxn = 200100;

int n;

int L[maxn], R[maxn];

int ans;

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

  cin >> n;

  for (int i = 0; i < n; i ++)
    {
      int l, r;
      cin >> l >> r;
      l += 100000;
      r += 100000;
      L[l] ++;
      R[r] ++;
    }

  L[100000] ++;
  R[100000] ++;

  for (int i = 1; i < maxn; i ++)
    R[i] += R[i - 1];

  for (int i = maxn - 1; i --; )
    L[i] += L[i + 1];

  for (int i = 0; i + 1 < maxn; i ++)
    ans += min(R[i], L[i + 1]);

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


Measured memory_bytes: 3328
def main():
    n = int(input())
    ans = set()
    divisors = get_divisors(n)
    ans |= set(get_divisors(n-1))
    ans |= set([divisor for divisor in divisors if is_ok(n, divisor)])
    ans -= set([1])
    print(len(ans))

def is_ok(n, d):
    if d < 2:
        return False
    while n%d == 0:
        n //= d
    return n%d == 1

def get_divisors(n):
    out = []
    if n < 1:
        return out
    m = int(n**0.5)
    for i in range(1, m+1):
        if not n%i:
            out.append(i)
            if n != i**2:
                out.append(n//i)
    return out


if __name__ == "__main__":
    main()

Measured memory_bytes: 39280
N,K=map(int,input().split())
p=list(map(int,input().split()))
exp0 = (sum(p[:K])+K)/2
MAX=exp0
old = exp0
for i in range(1,N-K+1):
  new = old + (p[K+i-1]+1)/2 - (p[i-1]+1)/2
  if new > MAX: MAX = new
  old = new
print(MAX)

Measured memory_bytes: 32156
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
vector<pair<int,int>>stop; vector<int>pr;
int main() {
    quick
int n,x,y; cin>>n; long double ans=0;
for(int i=0;i<n;i++){pr.push_back(i);}
for(int i=0;i<n;i++){cin>>x>>y; stop.emplace_back(x,y);}
for(int i=0;i<pr.size()-1;i++){
    ans+=hypot((stop[pr[i]].first-stop[pr[i+1]].first),
               (stop[pr[i]].second-stop[pr[i+1]].second)
            );
}
int how=1;
while(next_permutation(pr.begin(),pr.end())){
    how++;
    for(int i=0;i<pr.size()-1;i++){
        ans+=hypot((stop[pr[i]].first-stop[pr[i+1]].first),
                   (stop[pr[i]].second-stop[pr[i+1]].second)
        );
    }
}
cout<<fixed<<setprecision(10)<<ans/how;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  map<char,int> c;
  for(int i=0;i<4;i++) c[s[i]]++;
  if(c.size()==2) cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ALL(a) (a).begin(),(a).end()
#define F first
#define S second
typedef pair<int,int> PI;


int m,t,p,r;

int app[400][400];
int pena[400];


void solve(){
  memset(app,0,sizeof(app));
  memset(pena,0,sizeof(pena));  
  
  vector<int> sol(10000);
  
  rep(i,r){
    int mk,tk,pk,jk;
    cin >> mk >> tk >> pk >> jk;
    if(jk==0){
      pena[tk] += app[tk][pk]*20+mk;
      ++sol[tk];
    }else{
      ++app[tk][pk];
    }
  }

  vector<pair<PI,int> > team;
  
  rep(i,t){
    team.pb(mp(mp(-sol[i+1],pena[i+1]),-i-1));
  }

  
  sort(ALL(team));
  rep(i,t){
    if(i){
      if(team[i-1].F == team[i].F) cout << "=";
      else cout << ",";
    }
    cout << -team[i].S;
  }
  cout << endl;
}

int main(){
  while(cin >> m >> t >> p >> r && m) solve();
}

Measured memory_bytes: 1872
#include <stdio.h>

int main()
{
  int i;
  int N,K;
  int input;
  int count=0;

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

  for(i=0;i<N;i++){
    scanf("%d",&input);
    if(input>=K){
      count++;
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = str(input())
cnt = 0

for i in range(1000):
    j = 0
    flag1 = False
    flag2 = False
    flag3 = False
    istr = str(i)
    istr = istr.rjust(3, '0')
    #print(istr)
    while j < N:
        if not flag1 and S[j] == istr[0]:
            flag1 = True
        elif flag1 and (not flag2) and S[j] == istr[1]:
            flag2 = True
        elif flag1 and flag2 and S[j] == istr[2]:
            flag3 = True
            #print(istr)
            break
        j += 1
    if flag1 and flag2 and flag3:
        cnt += 1
print(cnt)

Measured memory_bytes: 42972
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
string s,t;
int main()
{
	cin >>s>>t;
	s+=t[t.size()-1];
	cout <<(s==t ? "Yes" : "No");
	return 0;
} 

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        int ans = Math.max(Math.max(a + b, a - b), a * b);
        System.out.println(ans);
    }

}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28) 
#define MAX 3003
using namespace std;
typedef pair<int,int> ii;
int dp[MAX],N,T,S;

bool cmp(const ii &a,const ii &b)
{
  if(a.second != b.second)return a.second < b.second;
  return a.first > b.first;
}

int main()
{
  while(cin >> N >> T >> S)
    {
      vector<ii> vec(N);
      rep(i,N)cin >> vec[i].first >> vec[i].second;
      //sort(vec.begin(),vec.end(),cmp);
      int mexico = 0;
      rep(i,N+1)dp[i] = 0;
      

      rep(i,N)
	{//どの店
	  for(int j=T;j>=0;j--)
	    {//時間
	      if(!(S <= j || j+vec[i].second <= S))continue;
	      if(j+vec[i].second > T)continue;
	      dp[j+vec[i].second] = max(dp[j+vec[i].second],
					dp[j]+vec[i].first);
		 
	      mexico = max(mexico,dp[j+vec[i].second]);

	    }
	}

      cout << mexico << endl;
    }
  return 0;
}

Measured memory_bytes: 1232
#include <stdio.h> 
 
 
 int main(){ 
     char number[1001]; 
    int i, sum; 
     while(1){ 
         scanf("%s", number); 
         if(number[0]=='0')break; 
         sum=0; 
         for(i=0;number[i]!='\0';i++){ 
             sum+=number[i]-'0'; 
         } 
         printf("%d\n", sum); 
     } 
 
 
     return 0; 
 } 


Measured memory_bytes: 2740
import sys
MOD=10**9+7
N,M=map(int,input().split())
if N==1:
    print(1)
    sys.exit()

a=[0]*(N+1)
for i in range(M):
  a[int(input())]=-1

pat=[0 for i in range(N+1)]
pat[0]=1
if a[1]==0: pat[1]=1

for i in range(2,N+1):
    if a[i]==0:
        if a[i-1]==0 and a[i-2]==0: pat[i]=pat[i-1]+pat[i-2]
        elif a[i-1]==0 and a[i-2]==-1: pat[i]=pat[i-1]
        elif a[i-1]==-1 and a[i-2]==0: pat[i]=pat[i-2]
        else:
            print(0)
            sys.exit()

    pat[i]%=MOD
print(pat[N])

Measured memory_bytes: 7832
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n,k; cin >> n >> k;
  cout << (n+k-3)/(k-1) << endl;
}

Measured memory_bytes: 256
#[test]
fn test_solve() {
    assert_eq!(solve("3\n2 1 2\n"), "1\n");
    assert_eq!(solve("3\n2 2 2\n"), "-1\n");
    assert_eq!(solve("10\n3 1 4 1 5 9 2 6 5 3\n"), "7\n");
    assert_eq!(solve("1\n1\n"), "0\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let a: Vec<usize> = (0..n).map(|_| sc.read()).collect();

    let mut c = 1;
    for i in 0..n {
        if a[i] == c {
            c += 1;
        }
    }

    if c == 1 {
        format!("-1\n")
    } else {
        format!("{}\n", n + 1 - c)
    }
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.get().chars().collect()
    }
}


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

int main() {
    std::string s, t;
    std::cin >> s >> t;

    std::vector<char> s2, t2;
    for (int i = 0; i < s.size(); ++i) {
        s2.push_back(s[i]);
    }

    for (int i = 0; i < t.size(); ++i) {
        t2.push_back(t[i]);
    }

    std::sort(s2.begin(), s2.end());
    std::sort(t2.rbegin(), t2.rend());

    bool result = true;
    for (int i = 0; i < t2.size(); ++i) {
        if (i >= s2.size() || s2[i] < t2[i]) {
            break;
        } else if (s2[i] > t2[i]) {
            result = false;
            break;
        }

        if (i == t2.size() - 1) {
            result = false;
        }
    }

    std::cout << (result ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>
 
 
 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
   ll n;
   cin>>n;
   
   cout<< 10 - n/200;
  
return 0;
    
 }  

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    bool ok = false;
    REP(n, 0, N + 1) {
        REP(m, 0, M + 1) {
            if (K == M * n + N * m - 2 * n * m) {
                ok = true;
                break;
            }
        }
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
let n = stdin.ReadLine() |> float

let ans =
  [ let x = n / 1.08 |> floor
    yield x
    yield x + 1. ]
  |> List.filter (fun x -> (floor (x * 1.08)) = n)
  |> (fun l ->
        match l with
        | [] -> ":("
        | x :: _ -> sprintf "%d" (int x))

ans |> stdout.WriteLine

Measured memory_bytes: 14044
#include <bits/stdc++.h>
using namespace std;
 
int N, M;
#define MAX_N 100000
int P[MAX_N];
 
int Rank[MAX_N], Par[MAX_N];
map<int, set<int>> G;
int R;
 
int find(int v) {
  if(Par[v] == v) return v;
  else return Par[v] = find(Par[v]);
}
void unite(int v, int w) {
  v = find(v); w = find(w);
  if(v == w) return;
  if(Rank[v] > Rank[w]) swap(v, w);
  Par[v] = w;
  if(Rank[v] == Rank[w]) ++Rank[w];
}
int main() {
  cin >> N >> M;
  for(int v = 0; v < N; ++v) { Par[v] = v; cin >> P[v]; --P[v]; }
  for(int i = 0; i < M; ++i) {
    int x, y; cin >> x >> y; --x; --y; unite(x, y);
  }
  for(int v = 0; v < N; ++v) {
    G[find(v)].insert(P[v]);
  }
  for(int v = 0; v < N; ++v) {
    R += G[find(v)].count(v);
  }
  cout << R << endl;
  return 0;
}

Measured memory_bytes: 15360
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); ++i)

using namespace std;

int main(){
  string S;
  ll N, M=1, l, x, ans = 1;

  l = pow(10, 18);
  cin >> N;

  vector<ll> A(N);

  rep(i, N){
    cin >> A[i];
  }

  rep(i, N){
    if(A[i]==0){
      ans = 0;
      cout << ans << endl;
      break;
    }
    if(ans == -1) continue;

    x = l/M;
    if(A[i] > x){
      ans = -1;
    }else{
      if(M != -1) M *= A[i];
      if(M > l) ans = -1;
    }
  }

  if(ans == -1){
    cout << -1 << endl;
  }else if(ans != 0){
    cout << M << endl;
  }

  return 0;
}


Measured memory_bytes: 4052
int main(void){
  int n,a[20],b[20],c[20];
  
  scanf("%d",&n);
  
  int i,sum=0;
  
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }
  for(i=0; i<n; i++){
    scanf("%d",&b[i]);
  }
  for(i=0; i<n-1; i++){
    scanf("%d",&c[i]);
  }
  
  for(i=0; i<n-1; i++){
    sum += b[a[i]-1];
    if(a[i+1]-a[i] == 1)
      sum += c[a[i]-1];
  }
  
  sum += b[a[n-1]-1];
  
  printf("%d",sum);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
  char a,b,D,H;
  D='D';
  H='H';
  int tmp[4];
  scanf("%c %c",&a,&b);
  tmp[0]=a;
  tmp[1]=b;
  tmp[2]=H;
  tmp[3]=D;

  if(tmp[0]==tmp[2])
    {
      printf("%c\n",b);
    }
  if(tmp[0]==tmp[3]&&tmp[1]==tmp[2])
    {
      printf("D\n");
    }
  if(tmp[0]==tmp[3]&&tmp[1]==tmp[3])
    {
      printf("H\n");
    }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,m,s;
    s=0;
    cin>>n>>m;
    if(n>=2)
    {
        s=s+(n*(n-1))/2;
    } 
    if(m>=2)
    {
        s=s+(m*(m-1))/2;
    }
    cout<<s<<"\n";
}

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

int main() {
  ll n; cin >> n;
  vector<ll> d(n);
  rep(i,n) cin >> d.at(i);
  sort(d.begin(), d.end());
  
  cout << d.at(n/2) - d.at((n/2)-1) << endl;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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 end



int main(){
    int n,a,b; scanf("%d%d%d",&n,&a,&b);
    if(a+b-1>n||1LL*a*b<n){
        printf("-1\n"); return 0;
    }
    vector<int> ans;
    int cur=1;
    rep(rot,0,a){
        int len=min(b,(n-cur+1)-(a-rot-1));
        rrep(i,cur+len-1,cur-1)ans.push_back(i);
        cur+=len;
    }
    rep(i,0,n)printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 3440
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = 100111;
int n;
pair<ll,ll> a[maxn];
ll b[maxn];
ll divdown(ll p, ll q) {return p/q;}
ll divup(ll p, ll q) {return (p+q-1)/q;}

pair<ll,ll> solve(ll k, ll p, pair<ll,ll> seg)
{
	pair<ll,ll> ret;
	ret.FF = divup(seg.FF*p, k);
	ret.SS = divdown(seg.SS*p+p-1, k);
	return ret;
}
int main()
{
	geti(n);
	for (int i=1; i<=n; i++) geti(b[i]);
	b[0] = 1;
	if (b[n]!=2)
	{
		puts("-1");
		return 0;
	}
	a[n+1] = MP(1, 1);
	for (int i=n; i>=1; i--)
	{
		a[i] = solve(b[i-1], b[i], a[i+1]);
		if (a[i].FF>a[i].SS)
		{
			puts("-1");
			return 0;
		}
	}
	cout<<a[1].FF<<" "<<a[1].SS<<endl;
	return 0;
}


Measured memory_bytes: 2688
while str = STDIN.gets
  n = str.split(" ")
  W = n[0].to_i
  H = n[1].to_i
  x = n[2].to_i
  y = n[3].to_i
  r = n[4].to_i

  if x - r < 0
    puts "No"
    elsif y - r < 0
      puts "No"
    elsif x + r > W
      puts "No"
    elsif y + r > H
         puts "No"
    else
        puts "Yes"
    end
end

Measured memory_bytes: 8656
#include <bits/stdc++.h>
#define MAXN 100000
int v[MAXN*3+1];
int main(){
   int i,n,b,e;
   scanf("%d" ,&n);
   for(i=1;i<=3*n;i++)
      scanf("%d" ,&v[i]);
   std::sort(v+1,v+3*n+1);
   b=1;
   e=3*n;
   long long ans=0;
   while(b<e){
       ans+=v[e-1];
       e-=2;
       b++;
   }
   printf("%lld" ,ans);
   return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef long long LL;

inline bool tri(LL a, LL b, LL c){
    return a < b + c;
}

int main(){
    int n;
    cin >> n;
    vector<LL> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<LL>());

    LL ans = 0;

    vector<LL> length;
    REP(i, n - 2) {
        if(tri(a[i], a[i + 1], a[i + 2])){
            length.push_back(a[i] + a[i + 1] + a[i + 2]);
            i += 2;
        }
        if(length.size() == 2) {
            ans = max(ans, accumulate(length.begin(), length.end(), 0LL));
            break;
        }
    }

    vector<int> perm = {0, 0, 0, 1, 1, 1};
    do{
        for(int i = 0; i + 6 <= n; i++){
            vector<LL> b[2];
            for(int j = 0; j < 6; j++){
                b[ perm[j] ].push_back(a[i + j]);
            }
            if(tri(b[0][0], b[0][1], b[0][2]) && tri(b[1][0], b[1][1], b[1][2])){
                ans = max(ans, accumulate(b[0].begin(), b[0].end(), 0LL)
                        + accumulate(b[1].begin(), b[1].end(), 0LL));
            }
        }
    }while(next_permutation(perm.begin(), perm.end()));

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

int n;
string s;
int dp[100000][13];

signed main(){
    FASTER;
    cin>>s;
    n=s.size();
    
    if(s[0]!='?')dp[0][s[0]-'0']=1;
    else for(int k=0;k<10;k++)dp[0][k]=1;
    
    for(int i=0;i<n-1;i++){
        for(int j=0;j<13;j++){
            if(s[i+1]!='?'){
                dp[i+1][(j*10+s[i+1]-'0')%13]=dp[i][j];
            }else{
                for(int k=0;k<10;k++){
                    dp[i+1][(j*10+k)%13]+=dp[i][j];
                    dp[i+1][(j*10+k)%13]%=MOD;
                }
            }
        }
    }
    
    cout<<dp[n-1][5];
}



Measured memory_bytes: 13936
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort(reverse=True)
    return divisors

d = make_divisors(n)
ans = 0
for a in d:
    if a == 1:
        continue
    else:
        q = n//a
        m = a-1
        if 0 <= q <= m-1:
            ans += m
print(ans)


Measured memory_bytes: 3268
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 100000000;
int Amin(int *p,int size){
   int _min = inf;
   for(int i = 0;i < size;i++)
      if(p[i] < _min)_min = p[i];
   return _min;
}
int main(){
   int n,x;scanf("%d %d",&n,&x);
   int m[100];for(int i = 0;i < n;i++)scanf("%d",&m[i]);
   for(int i = 0;i < n;i++){
      x-=m[i];
   }
   printf("%d",n+x/Amin(m,n));
}

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

int main(void)
{
	ios_base::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; i++)
                cin >> a[i];
        int ans = 0;
        for(int i = 1; i <= k; i++) {
                int st = i - 1, en = n;
                while(st >= -1) {
                        int lsum = 0;
                        vector<int> z;
                        z.clear();
                        for(int j = 0; j < n; j++) {
                                if(j <= st || j >= en) {
                                        lsum = lsum + a[j];
                                        z.push_back(a[j]);
                                }
                        }
                        ans = max(ans, lsum);
                        sort(z.begin(), z.end());
                        for(int j = 0; j < min(i, k - i); j++) {
                                lsum = lsum - z[j];
                                ans = max(ans, lsum);
                        }
                        st--;
                        en--;
                }
        }
        cout << ans;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

N,M = inpl()
prefe = defaultdict(list)
for i in range(M):
    p,m = inpl()
    prefe[p].append((m,i+1))

anls = [[] for _ in range(M)]
for a,item in prefe.items():
    item.sort()
    jyun = []
    for b in item:
        ind = bisect.bisect_left(item,b) + 1
        jyun.append([ind,b[1]])
    for item2 in jyun:
        anls[item2[1]-1].append((a,item2[0]))

for item3 in anls:
    print(str(item3[0][0]).zfill(6) + str(item3[0][1]).zfill(6))


Measured memory_bytes: 58400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

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

  ll num = 0;
  int d = n.length();
  rep(i, d) num += n[i] - '0';
  if (num % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

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

#define _USE_MATH_DEFINES
#include <math.h>

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

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

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

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

using namespace std;
using namespace std::chrono;

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

const long double eps = 1e-8;

const i64 MAXN = 100'000 + 6;

i64 T;
i64 n, a, b, c, d;

map<i64, i64> q;

i64 solve(i64 x);

i64 solve(i64 x, i64 k, i64 m) {
    i64 x1 = (x / k) * k;
    i64 t1 = (x - x1) * d + m + solve(x1 / k);

    i64 R = t1;

    i64 x2 = (x / k + (x % k ? 1 : 0)) * k;
    if (x2 / k < x) {
        i64 t2 = (x2 - x) * d + m + solve(x2 / k);
        R = min(R, t2);
    }
 
    return R;
}

i64 solve(i64 x) {
    if (!x) {
        return 0;
    }

    if (q.count(x)) {
        return q[x];
    }

    i64 t2 = solve(x, 2, a);
    i64 t3 = solve(x, 3, b);
    i64 t5 = solve(x, 5, c);

    i64 R = min(t2, min(t3, t5));

    if (R / d >= x && R > x * d) {
        R = x * d;
    }

    q[x] = R;
    return q[x];
}


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

    cin >> T;
    for (i64 tt = 1; tt <= T; tt++) {
        cin >> n >> a >> b >> c >> d;
        q.clear();

        i64 R = solve(n);
        cout << R << endl;
    }


    return 0;
}

Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; } 
int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i, 0, n)cin >> a[i];
    ll ans = gcd(a[0], a[1]);
    rep(i, 2, n){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
	char i,a[3];
	for (i=0;i<3;i++)
	{
		scanf("%c",&a[i]);
	}
	if (a[0]==a[1]&&a[1]==a[2])
	{
		printf("No");
		return 0;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
N = gets.to_i
q = {"M" => 0, "A" => 0, "R" => 0, "C" => 0, "H" => 0}
N.times do |i|
    s = gets.chomp
    q[s[0]] += 1 if q.has_key?(s[0])
end
x = q.values.select{|i| i!= 0}
if x.length < 3 then
    puts '0'
    exit
end
res = 0
x.combination(3).to_a.each_with_index do |z, index|
    res += z.inject(1) { |sum, i| sum * i }
end
puts res

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

int main() {
    int n, y;
    int a = -1, b = -1, c = -1;
    cin >> n >> y;
    y /= 1000;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (i + j <= n) {
                int k = n - i - j;
                if (i * 10 + j * 5 + k == y) {
                    a = i; b = j; c = k;
                    goto END;
                }
            }
        }
    }
END:
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fs first
#define sc second
#define pb push_back
#define mod 998244353
using namespace std;

string baca;
long long kali[20];
vector<pair<long long, long long> > sim1[20], sim2[20];

bool cmp(pair<long long, long long> a, pair<long long, long long> b){
	if(a.fs == b.fs) return a.sc < b.sc;
	return a.fs < b.fs;
}

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

	cin >> baca;

	long long maks = (1 << n);
	kali[0] = 1;
	for(int i = 1; i <= 18; i++){
		kali[i] = kali[i - 1] * 31;
	}

	for(int i = 0; i < maks; i++){
		long long merah = 0;
		long long biru = 0;
		long long pos = 0;
		for(int j = 0; j < n; j++){
			if( ((1 << j) & i) != 0 ){
				merah = merah * 31 + baca[j] - 'a' + 1;
			}else{
				biru = biru + kali[pos] * (baca[j] - 'a' + 1);
				pos++;
			}
		}
	//	if(pos == 11) cout << merah << " " << biru << " ini\n";
	//	cout << merah - biru << " " << i << " " << pos + 1 << " here\n";
		sim1[pos].pb(mp(merah, biru));
	}

	for(int i = 0; i < maks; i++){
		long long merah = 0;
		long long biru = 0;
		long long pos = 0;
		for(int j = 2 * n - 1; j >= n; j--){
			int now = 2 * n - 1 - j;
			if( ((1 << now) & i) != 0 ){
				merah = merah + kali[pos] * (baca[j] - 'a' + 1);
				pos++;
			}else{
				biru = biru * 31 + baca[j] - 'a' + 1;
			}
		}
	//	if(pos == 11) cout << biru << " " << merah << " ini\n";
	//	cout << biru - merah << " " << i << " " << pos + 1 << " ini\n";
		sim2[pos].pb(mp(biru, merah));
	}
	
	for(int i = 0; i <= 18; i++){
		sort(sim1[i].begin(), sim1[i].end());
		sort(sim2[i].begin(), sim2[i].end());
	}

	long long ans = 0;

	for(int idx = 0; idx <= 18; idx++){
		long long nyak = 0;
		for(int i = 0; i < sim1[idx].size(); i++){
			if(i == 0 || (sim1[idx][i].fs == sim1[idx][i - 1].fs && sim1[idx][i].sc == sim1[idx][i - 1].sc)){
				nyak++;
			}else{
				int low = lower_bound(sim2[idx].begin(), sim2[idx].end(), sim1[idx][i - 1]) - sim2[idx].begin();
				int upp = upper_bound(sim2[idx].begin(), sim2[idx].end(), sim1[idx][i - 1]) - sim2[idx].begin();
				ans = ans + nyak * (upp - low);
				nyak = 1;
			}
		}

		int low = lower_bound(sim2[idx].begin(), sim2[idx].end(), sim1[idx][sim1[idx].size() - 1], cmp) - sim2[idx].begin();
		int upp = upper_bound(sim2[idx].begin(), sim2[idx].end(), sim1[idx][sim1[idx].size() - 1], cmp) - sim2[idx].begin();
		ans = ans + nyak * (upp - low);

	//	cout << ans << " " << idx << " halo\n";
	}


	cout << ans << "\n";
}

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

signed main(void)
{
	int n;
	set<string> st;
	cin >> n;
	rep(i, n)
	{
		string s;
		cin >> s;
		st.insert(s);
	}
	int ans = st.size();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 19120
/*input
2002
2017
*/
#include <bits/stdc++.h>
#define getcx getchar_unlocked
#define putcx putchar_unlocked
#define pb(x) push_back(x);
#define in(y) insert(y);
#define tt(t) while(t--)
#define itr ::iterator it;
#define ll long long
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define si set<int>                      
#define msi map<string, int>
#define lines printf("\n")
#define ff(n) for(int i=0;i<n;i++)
#define fors(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(),v.end()
using namespace std;
#define MOD 1000000007

int main()
{
    int a,b;
    cin>>a>>b;
    // a+b/2 = x a+b=2x b=2x-a
    cout<<(2*b) - a;

}

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

int main(){
  int n,t,rate[10]={};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t;
    if(1<=t && t<=399) rate[0]++;
    else if(400<=t && t<=799) rate[1]++;
    else if(800<=t && t<=1199) rate[2]++;
    else if(1200<=t && t<=1599) rate[3]++;
    else if(1600<=t && t<=1999) rate[4]++;
    else if(2000<=t && t<=2399) rate[5]++;
    else if(2400<=t && t<=2799) rate[6]++;
    else if(2800<=t && t<=3199) rate[7]++;
    else rate[8]++;
  }
  int cnt=0;
  for(int i=0;i<8;i++){
    if(0<rate[i]) cnt++;
  }
  if(cnt!=0) cout<<cnt<<" "<<cnt+rate[8];
  else cout<<"1"<<" "<<rate[8];
}


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

int main() {
  string s;
  cin >> s;
  int n = stoi(s.substr(0,4)) * 10000 + 
          stoi(s.substr(5,2)) * 100 +
          stoi(s.substr(9,2));
  if (n > 20190430)
    cout << "TBD" << endl;
  else
    cout << "Heisei" << endl;
}


Measured memory_bytes: 256
using System;

namespace prime
{
    class Program
    {
        static void Main()
        {
            int[] Primes = MakeList();

            while (true)
            {
                int n, ans = 0;

                if (int.TryParse(Console.ReadLine(), out n))
                {
                    /*
                    for (int i = 2; i <= n; ++i)
                    {
                        if (IsPrime(i))
                            ++ans;
                    }
                    */
                    ans = Primes[n];

                    Console.WriteLine(ans);
                }
                else
                    break;
            }
        }

        public static bool IsPrime(int a)
        {
            if (a == 1)
                return false;
            else if (a < 4)
                return true;
            else
            {
                bool prime = true;
                int ma = (int)Math.Sqrt(a + 1);
                int i = 3;
                if (a % 2 == 0)
                    prime = false;
                else
                {
                    for (; i <= ma; i += 2)
                    {
                        if (a % i == 0)
                        {
                            prime = false;
                            break;
                        }
                    }
                }
                return prime;
            }
        }

        public static int[] MakeList() 
        {
            int M = 1000000;
            int rM = 1000;
            bool[] unPrime = new bool[M];
            int[] Primes = new int[M];
            Primes[1] = 0;

            for (int i = 2; i < M; ++i) 
            {
                if (i < rM && !unPrime[i]) 
                {
                    for (int j = i * i; j < M; j += i)
                        unPrime[j] = true; 
                }
                if (!unPrime[i])
                    Primes[i] = Primes[i - 1] + 1;
                else
                    Primes[i] = Primes[i - 1];

            }
            return Primes;
        }
    }
}

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

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, w, h;
    cin >> h >> w >> n;
    if(h < w)
    	swap(h, w);
    cout << n/h + ((n % h) > 0) << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
int main()
{
	long long a = 700, b = 0, rate[100] = {}, last = 0, k = 0, ansa = 0, ansb = 0, x = 0, y = 0;
	std::string  c;
	std::cin >> c;
	bool okada = true;
	for (int i = 0; i < 3; i++) {
		if (c[i] == 'o') {
			a+=100;
		}
	}

	std::cout << a << std::endl;
}







Measured memory_bytes: 256
A, B, C, D = gets.chomp.split.map(&:to_i)

def lcm(a, b)
  a * b / gcd(a, b)
end
def gcd(a, b)
  a, b = b, a if a < b
  return a if b == 0
  _mod = a.modulo(b)
  if _mod == 0
    b
  else
    gcd(b, _mod)
  end
end

lcm_memo = lcm(C, D)

count_to_b = (B/C) + (B/D) - (B/lcm_memo)
count_to_a = ((A-1)/C) + ((A-1)/D) - ((A-1)/lcm_memo)
puts (B - A + 1)-(count_to_b - count_to_a)

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

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

    bool result = false;
    int d_i = 0, c_i = 0;
    while (7 * d_i <= N) {
        if ((N - 7*d_i) % 4 == 0) {
            result = true;
            break;
        }
        else
        {
            d_i++;
        }
    }
    if (result) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        string temp = ReadLine();
        int a = 0;
        for(int i=1;i<999;i++){
            int x1 = (i*(i+1))/2-n;
            int x2 = ((i+1)*(i+2))/2-m;
            if(x1 == x2){
                WriteLine(x1);
            }
        }
    }
}

Measured memory_bytes: 13140