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

using namespace std;


void solve() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

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

    int ans;

    if (N % 2 == 0) {
        int ma = B[N/2-1] + B[N/2];
        int mi = A[N/2-1] + A[N/2];
        ans = ma - mi + 1;
    }
    else {
        int ma = B[(N+1)/2-1];
        int mi = A[(N+1)/2-1];
        ans = ma - mi + 1;
    }

    cout << ans << endl;
}


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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  vector<vector<long double>> P(n,vector<long double>(2));
  rep(i,n)rep(j,2) cin>>P.at(i).at(j);
  long double sum=0;
  rep(i,n)rep(j,n){
    long double x=P.at(i).at(0)-P.at(j).at(0);
    long double y=P.at(i).at(1)-P.at(j).at(1);
    sum+=sqrt(x*x+y*y);
  }
  cout<<fixed<<setprecision(7);
  cout<<sum/n<<endl;
}

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

int main() {
  int n, cnt = 0;
  cin >> n;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if(a == b) cnt++;
    else cnt = 0;
    if(cnt == 3) break;
  }
  string ans;
  if(cnt == 3) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
}

Measured memory_bytes: 3632
/*input
6 6 8
..##..
.#..#.
#....#
######
#....#
#....#
*/

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    rep(i, H) cin >> c[i];
    int n = 1<<H, m = 1<<W, ans = 0;
    rep(i, n) {
        rep(j, m) {
            int cnt = 0;
            rep(h, H) {
                rep(w, W) {
                    if (c[h][w] == '#' && ((i>>h&1) == 0) && ((j>>w&1) == 0)) cnt++;
                    // cout << c[h][w] << ' ' << (i>>h&1) << ' '<< (j>>w&1) << ' '<< cnt << endl;
                }
            }
            if (cnt == K) ans++;
        }
    }
    cout << ans << endl;
    // printf("%d %d %d\n", n, m, K);
}

Measured memory_bytes: 3532
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long[] L) {
    auto l = L.sort!"a < b".assumeSorted!"a < b";
    long ans;

    foreach (i; 0 .. N) foreach (j; i + 1 .. N) {
        auto a = l[i];
        auto b = l[j];

        ans += l
            .drop(j + 1)
            .lowerBound(a + b)
            .upperBound(abs(a - b))
            .length;
    }

    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] L = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        L[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, L);
    else
        solve(N, L).writeln;
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;


map<pair<int,int>, int> mp;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
   // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        ll n;
        cin >> n;
        ll tmp = n;
        int ans = 0;
        while(tmp){
            tmp /= 10;
            ans++;
        }
        //cerr << ans << endl;

        for(ll x = 1; x * x <= n; x++){
            if(n % x == 0){
                ll p = x;
                ll q = n/x;
                int cnt1 = 0, cnt2 = 0;
                while(p){
                    p /= 10;
                    cnt1++;
                }
                while(q){
                    q /= 10;
                    cnt2++;
                }
                ans = min(ans, max(cnt1,cnt2));
            }
        }
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
pair<int,int> dat[10];char p[10][21];
int main(){
	int a;bool saisho=1;
	while(scanf("%d",&a),a){
		if(!saisho)printf("\n");
		saisho=0;
		for(int i=0;i<a;i++){
			int b,c,d;
			scanf("%s%d%d%d",p[i],&b,&c,&d);
			dat[i]=make_pair(-(b*3+d),i);
		}
		std::sort(dat,dat+a);
		for(int i=0;i<a;i++){
			printf("%s,%d\n",p[dat[i].second],-dat[i].first);
		}
	}
}


Measured memory_bytes: 2732
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n: usize,
        d: usize,
    }

    let mut ans = 0;

    for _ in 0..n {
        input! {
            x: isize,
            y: isize,
        }

        if (x*x + y*y) <= (d*d) as isize {
            ans += 1;
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 4896
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;



int main(void){
    string s,t;
    cin >> s >> t;
    int cnt=0;
    REP(i,(int)s.size()){
        if(s[i]!=t[i])
            cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

# 文字列の入力
s = raw_input()
t = raw_input()

isOk=False
for i in range(len(s)):
	c=''.join(list(s)[i:]+list(s)[:i])
	if t == c:
		print 'Yes'
		isOk=True
		break

if not isOk:
	print 'No'

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

lli n;
lli w;
lli h;
vll a;
mat m;
lli d[4][2] = {{0,1},{1,0},{0,-1},{-1,0}};
lli dir = 0;
lli x,y;

int main(){
	cin >> h >> w >> n;
	a = vll(n);
	for(lli i = 0;i < n;i++){
		cin >> a[i];
	}
	m = mat(w,vll(h));
	for(lli i = 0;i < n;i++){
		for(lli j = 0;j < a[i];j++){
			m[x][y] = i+1;
			if(x+d[dir][0] < 0 || x+d[dir][0] >= w || y+d[dir][1] < 0 || y+d[dir][1] >= h || m[x+d[dir][0]][y+d[dir][1]] != 0){
				dir = (dir+1)%4;
			}
			x+=d[dir][0];
			y+=d[dir][1];
		}
	}
	for(lli i = 0;i < h;i++){
		for(lli j = 0;j < w;j++){
			cout << m[j][i];
			if(j+1 < w) cout << " "; 
		}
		cout << endl;
	}
	return 0;
}

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

int solve() {

}

int main() {
	int n, cnt=0,a[100];
	cin >> n;
	for (int i = 1; i <= n ; i++) cin >> a[i];
	for (int i = 1; i <= n ; i++) {
		if(i%2 && a[i]%2) cnt++;
	}
	cout << cnt << endl;
}




Measured memory_bytes: 3620
n = int(input())
MOD = 10**9 + 7
if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    ans = pow(10, n, MOD) + pow(8, n, MOD) - 2 * pow(9, n, MOD)
    print(ans % MOD)

Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <numeric>
 
using namespace std;

int main(void) {
    int a,b,c,d,e,k;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;
    if(e-a>k){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }
    return 0;
}

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

int main() {
	string s;

	cin >> s;

	string ans = "CODEFESTIVAL2016";

	int count = 0;

	for (int i = 0; i < 16; i++) {
		if (s[i] != ans[i]) count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()
counter = 0
RL = 0
RL_L = 0
RL_R = 0

if S[0] == 'L':
    RL_L += 1

if S[N-1] == 'R':
    RL_R += 1

for i in range(N-1):
    if S[i:i+2] == 'RL':
        counter += 1

if (counter - K) >= 0:
    counter -= K
    K = 0
else:
    K -= counter
    counter = 0
    RL = 0

if RL_L == 1 and K > 0:
    RL_L -= 1
    K -= 1

if RL_R == 1 and K > 0:
    RL_R -= 1
    K -= 1

ans = N - (counter*2 + RL_L + RL_R)

print(min(ans, N-1))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    vector<int> dp(10);
    for (int i = 1; i <= 3; ++i) {
        if (s[i - 1] == 'R') {
            dp[i] = dp[i - 1] + 1;
        } else {
            dp[i] = 0;
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};


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

    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h,vector<char> (w,'1'));
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for(int i = 0;i < (1<<h); ++i){
        for(int j = 0; j < (1<<w); ++j){
            auto tmp = c;
            int sumi = 0;
            for(int kk = 0;kk < h;++kk){
                if(i & (1<<kk)){
                    for(int ci = 0;ci < w;++ci){
                        tmp[kk][ci] = 'r';
                    }
                }
            }
            for(int kk = 0;kk < w;++kk){
                if(j & (1<<kk)){
                    for(int cj = 0;cj < h;++cj){
                        tmp[cj][kk] = 'r';
                    }
                }
            }
            rep(ii,h){
                rep(jj,w){
                    if(tmp[ii][jj] == '#') sumi++;
                }
            }
            if(sumi == k){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
  int n;
  string s;
  cin>>n>>s;
  
  int counter=0;
  for(int i=0;i<n-2;i++)
  {
    if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C')
      counter++;
  }
  cout<<counter<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   String line = br.readLine();
   String[] token = line.split("");


   for (int i = 0; i < token.length; i++){
	   if( Character.isUpperCase(line.charAt(i) )){
		   token[i] = token[i].toLowerCase();
	   }else if( Character.isLowerCase(line.charAt(i)) ){
		   token[i] = token[i].toUpperCase();
	   }
	   System.out.print(token[i]);
   }

   System.out.println();

  }
}

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

string check(int num);

int main(){
	string s;
	int n,h;
	while(cin >> s){
		if(s == "-")break;
		cin >> n;
		for(int i = 0;i < n;i++){
			cin >> h;
			s = s.substr(h) + s.substr(0,h);
		}
		cout << s << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define us unordered_set
#define f first
#define s second
#define pb push_back
#define MOD 1000000007
#define MOD2 1000000009
#define BASE 29
#define BASE2 31
#define eps 1e-9
#define INF 1000000002

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
typedef pair<pii,pii> piiii;
const int N = 200002;
const int BIT = 30;
int m;
bool removed[N];
set<int> vs;
set<int> vis;
vector<pii> edges;
map<int, vi> adjList;
map<int,int> outDeg;
map<int,int> cmp;

int main() {
	int n;
  cin>>n;
  for(int i= 1;i<=9;i++) {
    for(int j = 1;j<=9;j++) {
      if(i*j == n) {
        return cout<<"Yes", 0;
      }
    }
  }
  cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())
sl = []

dic = {'M':0,'A':0,'R':0,'C':0,'H':0}
for i in range(n):
    name = input()
    if name[0] in dic:
        dic[name[0]] += 1

lst = []
for com in itertools.combinations(dic.keys(),3):
    lst.append(com)

ans = 0
for v in lst:
    ans += dic[v[0]] * dic[v[1]] * dic[v[2]]
print(ans)

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

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  if(A > B) swap(A,B);
  if(A%2 == B%2){
    cout << (B-A)/2 << endl;
  }else{
    // A -> 1
    long long A_ = 1, B_ = B-A;
    long long ans = (B_-A_)/2 + A;
    if(B_%2 != A_%2) ++ans;
    // B -> 1
    A_ = A+(N-B), B_ = N;
    long long ans2 = (B_-A_)/2+(N-B);
    if(B_%2 != A_%2) ++ans2;
    ans = min(ans,ans2);
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = s.length();
        int charge = 0;
        int ans = 0;
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            if (charge > 0) {
                if (c == 'g') {
                    ans++;
                    charge--;

                } else {
                    charge--;

                }
            } else {
                if (c == 'g') {
                    charge++;

                } else {
                    charge++;
                    ans--;

                }
            }
        }
        System.out.println(ans);
        sc.close();
    }

}


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

ll x[1010],y[1010],z[1010];

int main(){
  int N,M; cin>>N>>M;
  rep(i,N) cin>>x[i]>>y[i]>>z[i];
  ll ans=0;
  rep(i,8){
    int sig[3];
    rep(j,3){
      if((i>>j)&1) sig[j]=1;
      else sig[j]=-1;
    }
    vector<ll> V;
    rep(j,N) V.push_back(x[j]*sig[0]+y[j]*sig[1]+z[j]*sig[2]);
    sort(V.rbegin(),V.rend());
    ll tmp=0;
    rep(j,M) tmp+=V[j];
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;

int main(){
  int n,m;
  cin >> n >> m;
  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){int x,n;cin>>x>>n;vector<int>a(n);
           for(int i=0;i<n;i++)cin>>a.at(i);
           sort(a.begin(),a.end());int p=0;
           for(int i=0;i<n;i++)if(a.at(i)<x)p++;else{break;}
           int s=0,t=x;if(n)t--;for(int i=p-1;i>=0;i--)if(t-a.at(i)>0){break;}else{t=a.at(i)-1;}
           s=x-t;int q=0,r=x;for(int i=p;i<n;i++)if(a.at(i)-r>0){break;}else{r=a.at(i)+1;}
           q=r-x;if(q<s)cout<<r<<endl;else{cout<<t<<endl;}}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void)
{
  int n,s=0,temp;
  scanf("%d",&n);
  temp = n;
  while(n != 0)
    {
      s += n%10;
      n /= 10;
    }
  if(temp%s==0)
    {
      printf("Yes\n");
    }
  else
    {
      printf("No\n");
    }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[500][500];//動的計画法
int tmp[500][500];
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int n,m,Q;
  int ans;
  int l,r;
  int p,q;
  cin>>n>>m>>Q;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      dp[i][j]=0;
    }
  }
  for(int i=1;i<=m;i++){
      cin>>l>>r;
      dp[l][r]++;
  }
  for(int i=2;i<=n;i++){
      for(int j=i+1;j>=1;j--){
          dp[j][i]+=dp[j+1][i];
      }
      for(int j=i+1;j>=1;j--){
          dp[j][i]+=dp[j][i-1];
      }
  }
  //cout<<dp[1][7]<<endl;
  for(int i=0;i<Q;i++){
      ans=0;
      cin>>p>>q;
      cout<<dp[p][q]<<endl;
  }
    return 0;
}

Measured memory_bytes: 6016
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
        if(N % 1.08 == 0){
            System.out.println((int)(N / 1.08));
            return;
        }
        for(int i =(int) (N / 1.08); i <= N; i++){
            if((int) (i * 1.08) == N){
                System.out.println((int) i);
                return;
            }
        }
        System.out.println(":(");
    }
}


Measured memory_bytes: 35720
#include<iostream>
#include<cmath>
using namespace std;
bool isprime(int n) {
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
	return true;
}
int main() {
	int n;
	while (cin >> n){
		for (int i = n - 1; ; i--){
			if (isprime(i)) {
				cout << i << ' ';
				break;
			}
		}
		for (int i = n + 1;; i++) {
			if (isprime(i)) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  map<string, int> mp;
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  return 0;
}


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

int main()
{
  int N, P = 0, W = 0, Y = 0, G = 0;
  string color;
  //cout << "N>";
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    cin >> color;
    if (color == "P" && P == 0)
      P = 1;
    if (color == "W" && W == 0)
      W = 1;
    if (color == "Y" && Y == 0)
      Y = 1;
    if (color == "G" && G == 0)
      G = 1;
  }
  if (P + W + Y + G == 4 || Y == 1)
  {
    cout << "Four" << endl;
  }
  else
  {
    cout << "Three" << endl;
  }
}

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

int a[1000010];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1; i<=m; ++i) scanf("%d", &a[i]);
    for(int i=2; i<=m; ++i) a[i] += a[i-1];
    if(n-a[m] < 0){ printf("-1\n"); return 0;}
    else printf("%d\n", n-a[m]);
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p= 998244353;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j,y,k,z,w,g,m,t,n,a,b;
	ll t2,t3,t4,t1;
	    string s;
	    char x;
	    cin>>x;
	    if(x<='Z')
	    cout<<'A';
	    else
	    cout<<'a';
	     
	 return 0;
	 
           
}

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

N = int(input())

ans ='No'
for x in range(1, 10, 1):
    if (N % x) == 0:
        for y in range(x, 10, 1):
            if x * y == N:
                ans = 'Yes'
                break
    
    if ans == 'Yes':
        break

print(ans)

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


typedef long long ll;


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

	vector<ll> L(N);
	for (int i = 0; i < N; ++i) cin >> L[i];

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			for (int k = j + 1; k < N; ++k) {
				ll a = L[i], b = L[j], c = L[k];
				if (a == b || b == c || c == a) continue;
				if ((a + b > c) && (b + c > a) && (a + c > b)) {
					++cnt;
				}
			}
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3196
#include <stdio.h>

int compare(char *s1, char *s2){
  while(*s1 == *s2){
    if(*s1 == '\0'){
      return 0;
    }
    s1++;
    s2++;
  }
  return(*s1 - *s2);
}

int main(){
  int n,judge;
  int taro_score = 0;
  int hanako_score = 0;
  char taro_card[1001];
  char hanako_card[1001];

  scanf("%d", &n);

  for(int i = 0; i < n; i++){
    scanf("%s %s", taro_card, hanako_card);
    judge = compare(taro_card, hanako_card);
    if(judge > 0){
      taro_score += 3;
    }else if(judge < 0){
      hanako_score += 3;
    }else{
      taro_score++;
      hanako_score++;
    }

  }

  printf("%d %d\n", taro_score, hanako_score);

  return 0;
}



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

using namespace std;

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

  string S;
  cin >> S;
  const char* s = S.c_str();

  size_t sum = 1;
  char l = s[0];
  for (size_t i = 1; i < N; i++) {
    if (l != s[i]) {
      l = s[i];
      sum++;
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int n;
    int a[110];
    cin >> n;
    int sum = 0;
    REP(i,n) cin >> a[i];
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += a[i] * a[j];
        }
    }
    cout << sum << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#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=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007; 
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int dp[110000];
int h[110000];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	 rep(i, n)cin >> h[i];
	rep(i, n)dp[i] = INF;
	dp[0] = 0;
	rep(i, n) {
		FOR(j,1,k+1) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int A,B;
void solve(){
  if(A==B){
    prin("Draw");
  }
  else if(A==1){
    prin("Alice");
  }
  else if(B==1){
    prin("Bob");
  }
  else if(A>B){
    prin("Alice");
  }
  else if(A<B){
    prin("Bob");
  }
}
int main(){
  cin>>A>>B;
  solve();
  return 0;
}




Measured memory_bytes: 256
N = int(raw_input())
B = raw_input().split()

# initial term                                                                                                                                          
sum = int(B[0])

# intermediate                                                                                                                                          
for i in range(1,N-1):
    ai = min(int(B[i-1]), int(B[i]))
    sum = sum + ai

# last term                                                                                                                                             
sum = sum + int(B[N-2])


print sum


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int K;
    cin >> K;
    ll A[K];
    rep(i,K){
        cin >> A[i];
    }
    ll L,R;
    L=2;
    R=2;
    bool ans=true;
    for(int i=K-1;i>=0;i--){
        ll X=((L-1)/A[i]+1)*A[i];
        ll Y=R/A[i]*A[i];
        if(X>R || Y<L){
            ans=false;
            break;
        }
        else{
            L=X;
            R=Y+A[i]-1;
        }
    }
    if(ans){
        cout << L << ' ' << R;
    }
    else cout << -1;
    


}

/*



 */



Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    s = input()
    d = [float("inf")]*(n+1)
    d[n] = 0
    i = n
    k = 1
    mi = n
    while i >= 0:
        pre = i
        i = mi
        i -= m
        for j in range(m):
            x = i+j
            if x >= 0:
                if s[x] == "0":
                    d[x] = k
                    if x < mi:
                        mi = x
        if pre == i:
            print(-1)
            return
        k += 1
    q = []
    for i in range(n+1):
        heappush(q,(-d[i],i))
    ans = [0]
    x = 0
    dx = d[0]
    while q:
        di,i = heappop(q)
        if i <= x:
            continue
        di *= -1
        if dx-1 == di:
            dx = di
            x = i
            ans.append(i)
    a = [ans[i+1]-ans[i] for i in range(len(ans)-1)]
    print(*a)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 70680
#define mod 1000000007
char buf[30];sz;
char out[10];osz=10;
int N,K;
long I[2<<17]={1,1};
main()
{
	read(0,buf,30);
	for(;;)
	{
		char c=buf[sz++];
		if(c<'0')break;
		N=N*10+c-'0';
	}
	for(;;)
	{
		char c=buf[sz++];
		if(c<'0')break;
		K=K*10+c-'0';
	}
	for(int i=2;i<2<<17;i++)I[i]=(mod-mod/i)*I[mod%i]%mod;
	long ans=0;
	long x=1,y=1;
	for(long i=0;i<N&&i<=K;i++)
	{
		ans+=x*y%mod;
		x=x*(N-i-1)%mod*I[i+1]%mod;
		y=y*(N-i)%mod*I[i+1]%mod;
	}
	ans%=mod;
	do{
		out[--osz]=ans%10+'0';
	}while(ans/=10);
	write(1,out+osz,10-osz);
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<math.h>
int main(){
int X,t,p;
scanf("%d %d",&X,&t);
if((X>=1 && X<=pow(10,9)) && (t>=1 && t<=pow(10,9)))
{
    p=X-t;
    if(p>=0){
        printf("%d\n",p);
    }
    else{
        printf("0\n");
    }
}

return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, s;
  cin >> k >> s;
  
  int ans = 0;
 
  for (int x = 0; x <= k; x++)
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if(0 <= z && z <= k)
          ans++;
    }
  
  cout << ans << endl;   
}

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  vector<string> a;
  string t;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A') {
      t += 'A';
    } else if (i < s.size() - 1 && s[i] == 'B' && s[i + 1] == 'C') {
      t += 'X';
      ++i;
    } else {
      a.push_back(t);
      t = "";
    }
  }
  a.push_back(t);
  auto proc = [](string t) {
    long long ans = 0;
    int na = 0;
    for (int i = t.size() - 1; i >= 0; --i) {
      if (t[i] == 'A') {
        ++na;
        ans += t.size() - i - na;
      }
    }
    return ans;
  };
  long long ans = 0;
  for (auto t : a) {
    ans += proc(t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5388
/*
ex3_2
tomatokan
*/
#include<stdio.h>

int main(void){
    int n,digit;
    scanf("%d",&n);
    digit=n%10;
    if(digit==3){
        /*n%10=3のとき*/
        printf("bon\n");
    }else if(digit==0||digit==1||digit==6||digit==8){
        /*n%10=0,1,6,8のとき*/
        printf("pon\n");
    }else{
        /*n%10=2,4,5,7,9のとき*/
        printf("hon\n");
    }
    return 0;
    
}

Measured memory_bytes: 1652
{-# LANGUAGE MultiParamTypeClasses, ScopedTypeVariables, ExplicitForAll,InstanceSigs,PackageImports #-}
import qualified Data.ByteString.Char8 as B

import Data.List
import Control.Monad.Primitive 
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV
import Data.Monoid((<>))
import Data.Function hiding ((&))
import Debug.Trace
import qualified Data.Vector.Generic as G
import Unsafe.Coerce
 
(&) :: a -> (a -> b) -> b
(&) a b = b a
 
infixl 1 &

newtype P' = P' { unP' :: P }

instance {-# Overlaps #-} G.Vector V.Vector P where
    {-# INLINE basicUnsafeFreeze #-}
    basicUnsafeFreeze :: forall m. PrimMonad m => MV.MVector (PrimState m) P -> m (V.Vector P)
    basicUnsafeFreeze v = unsafeCoerce (G.basicUnsafeFreeze (unsafeCoerce v :: MV.MVector (PrimState m) P') :: m (V.Vector P'))
    {-# INLINE basicUnsafeThaw #-}
    basicUnsafeThaw v = fmap unsafeCoerce $ G.basicUnsafeThaw (unsafeCoerce v :: V.Vector P') 
    {-# INLINE basicLength #-}
    basicLength v = G.basicLength (unsafeCoerce v :: V.Vector P')
    {-# INLINE basicUnsafeSlice #-}
    basicUnsafeSlice offset len v = unsafeCoerce $ G.basicUnsafeSlice offset len (unsafeCoerce v :: V.Vector P')
    {-# INLINE basicUnsafeIndexM #-}
    basicUnsafeIndexM v i = fmap unsafeCoerce $ G.basicUnsafeIndexM (unsafeCoerce v :: V.Vector P') i
    {-# INLINE basicUnsafeCopy #-}
    basicUnsafeCopy :: forall m. PrimMonad m => MV.MVector (PrimState m) P -> V.Vector P -> m ()
    basicUnsafeCopy dst src = G.basicUnsafeCopy (unsafeCoerce dst :: MV.MVector (PrimState m) P') (unsafeCoerce src :: V.Vector P')
    {-# INLINE elemseq #-}
    elemseq _ (P i x) b = x `seq` b

 
data P = P { p_fst :: {-# UNPACK #-} !Int, 
             p_snd :: (String -> String) }
 
instance Eq P where
    (==) = (==) `on` p_fst
instance Ord P where
    compare = compare `on` p_fst
instance Monoid P where
    mappend (P a b) (P c d) = P (a + c) (b . d)
    mempty = P 0 id 
 
main :: IO ()
main = do
    s <- B.getLine
    t <- B.getLine
    let len_s = B.length s
        result = B.foldl' step s0 t
        v_end = result `seq` traceShow "v_end" (result & V.last & p_snd & ("" &))
        step :: V.Vector P -> Char -> V.Vector P
        step tbl ch = tbl'
            where
            tbl' = G.constructN (len_s + 1) gen 
            gen vec | i == 0 = mempty
                    | ch == ch' = a1 `max` a2 `max` a3
                    | otherwise = a1 `max` a2
                where
                    i = V.length vec
                    ch' = B.index s (i - 1)
                    a1 = V.last vec
                    a2 = tbl V.! i
                    a3 = tbl V.! (i - 1) <> (P 1 (ch:))
        s0 = V.replicate (len_s + 1) mempty
    putStrLn (v_end :: String)


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

int main()
{
	int N;
	cin >> N;
	vector<string> S, S2;
	string s;
	int p;
	vector<int>  P;
	int i;
	
	for (i = 0; i < N; i++) {
		cin >> s >> p;
		S.push_back(s);
		S2.push_back(s);
		P.push_back(p);
	}
	sort(S.begin(), S.end());
	string v = "";
	vector<int> score;
	int max=-1,mx=10000000,t;
	int BC[1000] = { 0 };
	int syutu;
	for (i = 0; i < N; i++) {
		max = -1;
		if (i >= 1) {
			if (S[i - 1] != S[i]) {
				max = -1; mx = 1000000;
			}
		}
		syutu = -1;
		for (t = 0; t < N; t++) {
			if (S2[t] == S[i]) {
				if (P[t] > max&&mx-1 >= P[t]){
					syutu = t;
					max = P[t];
				}
			}
		}
		cout << syutu+1 << endl;
		mx = max;
	}
	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))
using ll = long long;
using P = pair<int, int>;
using namespace std;

int N;
ll a[501];
ll sum[501];

ll dp[501][501];
const ll inf = 1e15;

ll get(int l, int r) {
    ll ret = sum[r];
    if (l) ret -= sum[l-1];
    return ret;
}

ll solve(int l, int r) {
    ll& ret = dp[l][r];
    if (l == r) return ret = 0;
    if (ret != 1e15) return ret;
    for (int i=l; i<r; ++i) ret = min(ret, solve(l, i) + solve(i+1, r) + get(l, r));
    return ret;
}

int main() {
    cin >> N;
    rep(i, N) cin >> a[i];

    rep(i, N) {
        sum[i] = a[i];
        if (i>=1) sum[i] += sum[i-1];
    }

    fill(dp[0], dp[N], inf);
    cout << solve(0, N-1) << endl;
}


Measured memory_bytes: 1792
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
        }
        int ans = A[0];
        for (int i = 1; i < N; i++) {
            ans = gcd(ans, A[i]);
        }
        System.out.println(ans);
    }

    public static int gcd(int x, int y) {
        return y == 0 ? x : gcd(y, x % y);
    }
}

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

int main(){
    int n,count;
    cin >> n;
    rep(i,n/2){
        if(n-i!=i)
        count++;
    }
    cout << count << endl;
}

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


int main(){
    int n;
    cin >> n;
    bool flag = 1;
    rep(i, n){
        int x;
        cin >> x;
        if (x%2 == 0){
            if (x%3 == 0 || x%5 == 0){
                continue;
            }
            else flag = 0;
        }
    }
    if (flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  ll n;
  cin >> n;
  ll l[2000];
  FOR(i,0,n-1) {
    cin >> l[i];
  }

  ll ans = 0;

  sort(l,l+n);

  FOR(i,0,n-3){
    FOR(j,i+1,n-2){
      FOR(k,j+1,n-1){
        if(l[i]+l[j]>l[k]) ++ans;
      }
    }
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d", $k);
fscanf(STDIN, "%d", $x);
fscanf(STDIN, "%d", $y);
if ($n > $k) {
    echo $k * $x + $y * ($n - $k);
} else {;
    echo $n * $x;
}

Measured memory_bytes: 3576
#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 <complex>
#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<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long 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<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e6+3;
const int dx[8]={0,1,0,-1,-1,-1,1,1},dy[8]={1,0,-1,0,-1,1,-1,1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	a.erase(unique(a.begin(),a.end()),a.end());
	cout<<a.size()<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		sc.close();

		boolean check = false;

		if (y % 2 != 0) {
			//false

		} else if (4 * x < y) {
			//false

		} else if (2 * x > y) {
			//false

		} else if (4 * x == y) {
			check = true;

		} else if (2 * x == y) {
			check = true;

		} else {

			int yy = y;
			for (int i = 1; i <= x && yy - 4 >= 2; i++) {
				yy -= 4;
			}
			if (yy == 2 || yy == 4) {
				check = true;

			}
		}

		System.out.println(check ? "Yes" : "No");

	}

}

Measured memory_bytes: 27088
n,m= map(int,input().split())
nd = {i:set() for i in range(1,n+1)}
ns = [0]*n
if m==0:
    if n==1:print(0)
    else:
        ns[0]=1
        print(''.join([str(t) for t in ns]))
else:
    for i in range(m):
        s,c= map(int,input().split())
        nd[s].add(c)
    for i in range(1,n+1):
        if   len(nd[i])==0:ns[i-1] = 1 if i==1 else 0
        elif len(nd[i])==1:ns[i-1] = list(nd[i])[0]
        else:
            print(-1)
            break
    else:
        if ns[0]==0:
            if n==1:print(0)
            else:print(-1)
        else:print(''.join([str(t) for t in ns]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int nya(lint n){
  if(n < 10) return n;
  else{
    v1i m;
    lint t = n;
    while(n > 0){
      m.push_back(n%10);
      n /= 10;
    }
    reverse(m.begin(), m.end());
    v3i dp(m.size(), v2i(2, v1i(10))), z(m.size(), v2i(2, v1i(10)));
    rep(i, m.size()){
      if(i == 0){
        rep(j, 10){
          if(j < m[0]) dp[i][0][j] = 1;
          else if(j == m[0]) dp[i][1][j] = 1;
          else break;
        }
      }
      else{
        rep(j, 10){
          dp[i][0][j] += dp[i-1][0][j];
          if(j > 0) dp[i][0][j] += dp[i-1][0][j-1];
          if(j < 9) dp[i][0][j] += dp[i-1][0][j+1];
        }
        rep(j, 10){
          if(j < m[i]){
            dp[i][0][j] += dp[i-1][1][j];
            if(j > 0) dp[i][0][j] += dp[i-1][1][j-1];
            if(j < 9) dp[i][0][j] += dp[i-1][1][j+1];
          }
          else if(j == m[i]){
            dp[i][1][j] += dp[i-1][1][j];
            if(j > 0) dp[i][1][j] += dp[i-1][1][j-1];
            if(j < 9) dp[i][1][j] += dp[i-1][1][j+1];
          }
          else dp[i][1][j] = 0;
        }
      }
    }
    rep(i, m.size()){
      if(i == 0){
        rep(j, 10){
          if(j == 0) z[i][1][j] = 1;
          else if(j > 1) z[i][0][j] = 1;
        }
      }
      else{
        rep(j, 10){
          z[i][0][j] += z[i-1][0][j];
          if(j > 0) z[i][0][j] += z[i-1][0][j-1];
          if(j < 9) z[i][0][j] += z[i-1][0][j+1];
        }
        rep(j, 10){
          if(j > 1){
            z[i][0][j] += z[i-1][1][j];
            if(j > 0) z[i][0][j] += z[i-1][1][j-1];
            if(j < 9) z[i][0][j] += z[i-1][1][j+1];
          }
          else if(j == 0) z[i][1][j] += z[i-1][1][j];
        }
      }
    }
    int s = -1;
    rep(i, 10) s += dp[m.size()-1][0][i] + dp[m.size()-1][1][i];
    rep(i, m.size()-1) rep(j, 10) s += z[i][0][j];
    return s;
  }
}

int main() {
  lint k, a = pow(2, 40), b = 1e18;
  cin >> k;
  rep(i, 40){
    if(nya(a) < k) a += pow(2, 39-i);
    else if(nya(a) == k){
      b = min(b, a);
      a -= pow(2, 39-i);
    }
    else a -= pow(2, 39-i);
  }
  if(nya(a) == k) b = min(b, a);
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int D[107][7],i,j,N;
int G[55][6]={
    {1,2,3},{1,3,5},{1,5,4},{1,4,2},
    {2,1,4},{2,4,6},{2,6,3},{2,3,1},
    {3,1,2},{3,2,6},{3,6,5},{3,5,1},
    {4,1,5},{4,2,1},{4,6,2},{4,5,6},
    {5,1,3},{5,3,6},{5,4,1},{5,6,4},
    {6,2,4},{6,4,5},{6,5,3},{6,3,2}};
 
int ch(int a,int b)
{
    int i;
    for(i=0;i<24;i++)
    {
        if(D[a][1]==D[b][G[i][0]]&&
           D[a][2]==D[b][G[i][1]]&&
           D[a][3]==D[b][G[i][2]]&&
           D[a][6]==D[b][7-G[i][0]]&&
           D[a][5]==D[b][7-G[i][1]]&&
           D[a][4]==D[b][7-G[i][2]])
        return 1;
    }
    return 0;
}
 
int main()
{
    scanf("%d",&N);
    for(i=0;i<N;i++)
        for(j=1;j<=6;j++)
            scanf("%d",&D[i][j]);
    for(i=0;i<N;i++)
        for(j=i+1;j<N;j++)
        {
            if(ch(i,j))
            {
                puts("No");
                return 0;
            }
        }
    puts("Yes");
    return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

string s;
int n;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>s;
  n = s.length();

  ll res = 0;
  for (int i=0; i<(1<<(n-1)); i++) {
    ll cur = 0;
    ll x = s[0]-'0';
    for (int j=1; j<n; j++) {
      int bit = (i>>(j-1))&1;
      if (bit) {
	cur += x;
	x = s[j]-'0';
      } else {
	x *= 10;
	x += s[j]-'0';
      }
    }
    cur += x;
    //watch(cur);
    res += cur;
  }

  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256