akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

int H, W;
int MOD = 1e9 + 7;
vector<vector<int>> MAP;   //0->通行か
vector<vector<long long>> DP;

int main() {
	cin >> H >> W;
	MAP.resize(W+1, vector<int>(H+1, 0));
	DP.resize(W+1, vector<long long>(H+1, 0));
	for (int y = 1; y <= H; y++) {
		string S;
		cin >> S;
		for (int x = 1; x <= W; x++) {
			if (S[x-1] == '#')MAP[x][y] = 1;
		}
	}
	DP[1][1] = 1;
	for (int y = 1; y <= H; y++) {
		for (int x = 1; x <= W; x++) {
			if (x == 1 && y == 1)continue;
			if (MAP[x - 1][y] == 0)DP[x][y] += DP[x - 1][y];
			if (MAP[x][y - 1] == 0)DP[x][y] += DP[x][y - 1];
			DP[x][y] %= MOD;
		}
	}
	cout << DP[W][H] << endl;
	return 0;
}

Measured memory_bytes: 12032
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n, N) for(ll i=(n);i<(N);i++)
#define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int N;
double T, A, H[10010];
int main() {

    cin>>N>>T>>A;
    double ans = 999999999.990;
    int ai = -1;
    REP(i,0,N){
        cin>>H[i];
        if(ans > fabs(T-H[i]*0.006-A)){
            ans = fabs(T-H[i]*0.006-A);
            ai = i+1;
        }
    }

    cout<<ai<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    vector<int>x, y, z;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        if (d <= a)x.push_back(d);
        else if (d > b)z.push_back(d);
        else y.push_back(d);

    }

    cout << min(x.size(), min(y.size(), z.size()));


    return 0;

}

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

int main() {
    long long int N;
    cin>>N;
    
    vector<long long int> A(N);
    for(int i=0;i<N;++i)cin>>A[i];
    
    map<long long int,long long int> cnt;
    for(auto x:A){
        if(!cnt.count(x)){
            cnt[x]=1;
        }else{
            ++cnt[x];
        }
    }
    
    long long int comb_total=0;
    for(auto x:cnt){
        comb_total+=(x.second*(x.second-1))/2;
    }
    
    for(long long int k=0;k<N;++k){
        if(!cnt.count(A[k])){
            cout<<0<<endl;
            continue;
        }
        
        cout<<(comb_total-cnt[A[k]]+1)<<endl;
        
    }
}


Measured memory_bytes: 11776
"""
Atcoder_Beginner_Contest_148
C

"""
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000)

A, B = map(int, input().split())
tmp_a, tmp_b = A, B
while tmp_a % tmp_b != 0:
    tmp_a, tmp_b = tmp_b, tmp_a % tmp_b

print(int(A * B / tmp_b))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define inf 9999999999999999
#define F first
#define S second
#define eb emplace_back
#define mpp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 100009
#define mod 10000007
using namespace std;
ll dp[109][mx];

int main(){//read(x);
//fast;
ll r,g,h,i,j,t,e,a,b,c,d,n,l,k,z=0;
cin>>n>>k;
ll w[n],p[n];l=0;
for(i=0;i<n;i++){cin>>w[i]>>p[i];l+=p[i];}
dp[n][0]=0;
for(i=1;i<=l;i++)dp[n][i]=inf;
for(i=n-1;i>=0;i--){
    for(j=0;j<=l;j++){
        dp[i][j]=min(dp[i+1][j],(j-p[i]>=0)?w[i]+dp[i+1][j-p[i]]:inf);
        //printf("%2lld ",dp[i][j]);
    }//cout<<endl;
}
a=0;
    for(j=0;j<=l;j++){
        if(dp[0][j]<=k){
            a=max(a,j);
//          cout<<j<<' '<<dp[0][j]<<endl;
        }
    }//cout<<endl;
    cout<<a<<endl;
}




Measured memory_bytes: 82424
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
struct BipartiteMatching {
	vector<vector<int>> E; int n, m; vector<int> match, dist;
	void init(int _n, int _m) { n = _n, m = _m; E.resize(n + m + 2); match.resize(n + m + 2); dist.resize(n + m + 2); }
	bool bfs() {
		queue<int> que;
		rep(i, 1, n + 1) {
			if (!match[i]) dist[i] = 0, que.push(i);
			else dist[i] = INF;
		}
		dist[0] = INF;
		while (!que.empty()) {
			int u = que.front(); que.pop();
			if (u) for(auto v : E[u]) if (dist[match[v]] == INF) {
				dist[match[v]] = dist[u] + 1;
				que.push(match[v]);
			}
		}
		return (dist[0] != INF);
	}
	bool dfs(int u) {
		if (u) {
			for(auto v:  E[u]) if (dist[match[v]] == dist[u] + 1) if (dfs(match[v])) {
				match[v] = u; match[u] = v;
				return true;
			}
			dist[u] = INF;
			return false;
		}
		return true;
	}
	void add(int a, int b) { b += n; E[a + 1].push_back(b + 1); E[b + 1].push_back(a + 1); }
	int whois(int x) { return match[x + 1] - 1; }
	int solve() {
		rep(i, 0, n + m + 1) match[i] = 0;
		int res = 0;
		while (bfs()) rep(i, 1, n + 1) if (!match[i] && dfs(i)) res++;
		return res;
	}
};
int main()
{
	int n, x, y;
	cin >> n;
	vector<int> A(n), B(n), C(n), D(n);
	rep(i, 0, n) {
		cin >> A[i] >> B[i];
	}
	rep(i, 0, n) {
		cin >> C[i] >> D[i];
	}
	BipartiteMatching bm;
	bm.init(n, n);
	rep(i, 0, n) rep(j, 0, n) {
		if (A[i] < C[j] && B[i] < D[j]) bm.add(i, j);
	}
	printf("%d\n", bm.solve());
	return 0;
}


Measured memory_bytes: 3780
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

class edge {
public:
    int from, to;
    ll cost;

    edge(int t, ll c) : from(-1), to(t), cost(c) {}

    edge(int f, int t, ll c) : from(f), to(t), cost(c) {}

    bool operator<(const edge &e) const {
        return cost < e.cost;
    }

    bool operator>(const edge &e) const {
        return cost > e.cost;
    }
};

class unionfind {
    int num;
    vector<int> par;
public:
    explicit unionfind(int n) : num(n), par(n, -1) {}

    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        num--;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size() { return num; }

    int size(int x) { return -par[find(x)]; }
};

vector<edge> v;

ll n, m;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    unionfind uf(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        v.emplace_back(a, b, 1);
    }
    reverse(v.begin(), v.end());
    ll ans = n * (n - 1) / 2;
    vector<ll> res;
    for (auto &e : v) {
        res.emplace_back(ans);
        if (!uf.same(e.to, e.from)){
            ans -= 1LL * uf.size(e.to) * uf.size(e.from);
        }
        uf.unite(e.to, e.from);
    }
    reverse(res.begin(), res.end());
    for (auto &i : res) cout << i << endl;
}


Measured memory_bytes: 5104
#include<stdio.h>

int main(void){
  int a,b,i,j=0,n=0,s=0;
  int m=0;
  int c[100000];

  scanf("%d %d",&a,&b);

  for(i=0;i<b;i++){
    scanf("%d",&c[i]);
    if(m<c[i]){
      j=i; m=c[i];
    }
  }

  if(b==1)
    printf("%d\n",c[0]-1);
  else{
    for(i=0;i<b;i++){
      if(i!=j) s+=c[i];
    }
    if(m<=s)
      printf("%d\n",0);
    else
      printf("%d\n",m-s-1);
  }


      return 0;
}





Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n, m; cin >> n >> m;
    vector<tuple<ll, int>> v;
    REP(i, n) {
        ll a; int b; cin >> a >> b;
        v.push_back(make_tuple(a, b));
    }
    sort(ALL(v));
    ll cost = 0;
    REP(i, n) {
        cost += get<0>(v[i]) * min(get<1>(v[i]), m);
        m -= min(get<1>(v[i]), m);
        if (m == 0) {
            break;
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main(){
    int x;
    int y;
    while (1){
        cin>>x >>y;
        if (x==0 && y==0) break;
        if (x<=y){
            cout<<x<<" "<<y<<endl;
        }else if (x>y){
            cout<<y<<" "<<x<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3048
n=gets.to_i
sps=[]
n.times do |i|
  sp=gets.split
  sp[1]=sp[1].to_i
  sps<<[sp[0],sp[1],i+1]
end
sps.sort!{|a, b| (a[0] == b[0]) ? b[1] <=> a[1] : a[0] <=> b[0]}
n.times{|i| puts sps[i][2]}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int n;
  cin >> n;
  int a[n + 1] = { };
  for (int x = 1; pow(x, 2) + 2 + x * 2 + 1 <= n; x++) {
    int px = pow(x, 2);
    for (int y = 1; px + pow(y, 2) + 1 + x * y + y + x <= n; y++) {
      int py = pow(y, 2);
      for (int z = 1; px + py + pow(z, 2) + x * y + y * z + x * z <= n; z++) {
        a[(int) (px + py + pow(z, 2) + x * y + y * z + x * z)]++;
      }
    }
  }
  rep(i,n)
    cout << a[i + 1] << endl;
  return 0;
}


Measured memory_bytes: 3680
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
	  //カードの枚数
      int n = sc.nextInt();
      //カードの点数
      Integer a[] = new Integer[n];
      for(int i = 0; i < n; i++){
        a[i] = sc.nextInt();
      }
      Arrays.sort(a,Collections.reverseOrder());
      //Aliceの得点
      int alice = 0;
      //ボブの得点
      int bob = 0;
      for(int i = 0;i < n; i++){
      	if(i % 2 == 0){
          alice += a[i];
        }else{
          bob += a[i];
        }
      }
      System.out.println(alice - bob);
    }
}

Measured memory_bytes: 23764
S = list(input())

i = 0
RUD_NO = 0
while i < len(S):

    if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
        i = i + 2
    else:
        RUD_NO = 1
        break

LUD_NO = 0
i = 1
while i < len(S):

    if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
        i = i + 2
    else:
        LUD_NO = 1
        break

if LUD_NO == 0 and RUD_NO == 0:
    print('Yes')
    exit(0)

print('No')


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

ll exp (ll a,ll x){
    if(x == 0) return 1;
    if(x == 1) return a;
    else return a*exp(a ,x-1);
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll q = n / k;
    if(k%2 == 1) {
        cout << exp(q ,3) << endl;
        return 0;
    }

    if(n%k >= k/2){
        cout << exp(q ,3) + exp(q+1 ,3) << endl;
        return 0;
    }
    cout << 2*exp(q ,3) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int b,r,g,c,s,t,m;
  while(1){
    scanf("%d %d %d %d %d %d",&b,&r,&g,&c,&s,&t);
    if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0)break;
    m=100;
    m+=b*5*16;
    m+=b*15;
    m+=r*3*16;
    m+=r*15;
    //g-=b+r;
    m+=g*7;
    m+=c*2;
    t-=s;
    m-=3*t;
    printf("%d\n",m);
  }
  return 0;
}

Measured memory_bytes: 600
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    cout << n * n * n << endl;

    return 0;
}


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

int N, M, X, Y;
int x[110], y[110];

int main()
{
	cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; ++i)
		cin >> x[i];
	for (int i = 0; i < M; ++i)
		cin >> y[i];
	x[N] = X;
	y[M] = Y;
	int max_x = *max_element(begin(x), begin(x) + N + 1);
	int min_y = *min_element(begin(y), begin(y) + M + 1);
	if (max_x < min_y) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
S = list(input())
answer = 0
for i in range(len(S)):
    if i == 0:
        continue
    elif S[i] == S[i-1]:
        if S[i] == '1':
            S[i] = '0'
        else:
            S[i] = '1'
        answer += 1

print(answer)

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

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

Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<s.length();i++){
    int c=(int)(s[i]-'A');
    c+=n;
    c%=26;
    s[i]=(char)('A'+c);
  }
  cout<<s<<endl;
}


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

using namespace std;

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

  string s;
  cin >> s;
  for (size_t i = 0; i < s.size() - 2; ++i) {
    if (s[i] == s[i + 2]) {
      cout << i + 1 << " " << i + 3 << "\n";
      return 0;
    } else if (s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << "\n";
      return 0;
    }
  }
  if (s[s.size() - 2] == s[s.size() - 1]) {
    cout << s.size() - 1 << " " << s.size() << "\n";
    return 0;
  }
  cout << "-1 -1" << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
inline double add(double a, double b){
	return abs(a + b) <= 1e-8 ? 0 : a + b;
}
int n;
double a[101],b[101];
double dist1(){
	double sum = 0;
	for (int i = 0; i < n; ++i){
		sum = add(sum,abs(a[i] - b[i]));
	}
	return sum;
}
double dist2(){
	double sum = 0;
	for (int i = 0; i < n; ++i){
		sum = add(sum, add(a[i], -b[i])*add(a[i], -b[i]));
	}
	return sqrt(sum);
}
double dist3(){
	double sum = 0;
	for (int i = 0; i < n; ++i){
		double tmp = abs(add(a[i], -b[i]));
		sum = add(sum, pow(tmp,3));
	}
	return cbrt(sum);
}
double dist4(){
	double MAX = abs(a[0] - b[0]);
	for (int i = 1; i < n; ++i){
		if (MAX < abs(a[i] - b[i])) MAX = abs(a[i]-b[i]);
	}
	return MAX;
}
int main(){
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	cout << fixed << setprecision(6);
	cout << dist1() << '\n';
	cout << dist2() << '\n';
	cout << dist3() << '\n';
	cout << dist4() << '\n';
}

Measured memory_bytes: 1308
#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()) //ソートのマクロ
int main(){
    int n,x;
    cin>>n>>x;
    vector<int64_t> a(n);
    rep(i,n){
        cin>>a[i];
    }
    all(a);
    int64_t sum=0;
    int ans=0;
    rep(i,n){
        sum += a[i];
        if(sum<x){
            ans++;
        }
        else if(sum==x){
            ans++;
        }
    }
    if(x>sum){
        ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
s=input()
mx=0
for i in range(len(s)):
  a=s[:len(s)-i]
  for j in range(len(s)-i):
    b=a[j:]
    if b.count('A')+b.count('C')+b.count('G')+b.count('T')==len(b):
      mx=max(mx,len(b))
print(mx)

Measured memory_bytes: 38384
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


n = int(input())
a_list = list(map(int,input().split()))
ans = len(a_list)
ini = 1
for l in a_list:
    if l == ini:
        ans -= 1
        ini += 1

if ans < len(a_list):
    print(ans)
else:
    print(-1)


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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    int n,y;
    cin >> n >> y;
    int ai = -1;
  	int jay = -1;
  	int kay = -1;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n-i ; j++){
            if(10000*i + 5000*j + 1000*(n-i-j) == y){
                ai = i;
                jay = j;
                kay = n-i-j;
                break;
            }
        }
    }

    cout << ai <<" "<< jay <<" "<< kay << endl;

    

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		ReaderWriter r = new ReaderWriter(); 	// Class to read/write input.
		String ans = "";			// Final answer to be printed.

		int a = r.rInt();
		int b = r.rInt();	
		int temp = 0;

		if(a <= b) {
			temp = a;
			a = b;
			b = temp;
		}

		// When this loop finishes, we have b == 1 or b == 0.
		while( b > 0 ) {
			temp = a;
			a = b;
			b = temp % b;
		}

		ans = Integer.toString(a);

		// Outputs final answer.
		r.pAns(ans);
		r.out.close();
	}


}

class ReaderWriter {
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	public ReaderWriter() {
		// br = new BufferedReader(new FileReader("in.txt"));
		// out = new PrintWriter(new FileWriter("out.txt"));
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));
	}

	String next() throws IOException  {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	long rLong() throws IOException  {
		return Long.parseLong(next());
	}

	int rInt() throws IOException  {
		return Integer.parseInt(next());
	}

	int[] rIntArray(int n) throws IOException  {
		int[] ret = new int[n];
		for(int i = 0; i < n; i++) {
			ret[i] = rInt();
		}
		return ret;
	}

	double rDouble() throws IOException  {
		return Double.parseDouble(next());
	}

	char rChar() throws IOException  {
		return next().charAt(0);
	}

	String rLine() throws IOException  {
		return br.readLine().trim();
	}

	String wArray(int[] a) throws IOException {
		if(a == null || a.length == 0) {
			return "";
		}
		String ret = "" + a[0];
		for(int i = 1; i < a.length; i++) {
			ret = ret + " " + a[i];
		}
		ret = ret + "\n";
		return ret;
	}

	void pAns(String ans) {
		if(ans.charAt(ans.length()-1) != '\n')
			ans = ans + "\n";
		System.out.print(ans);
	}
}




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

int main() {
  int N,Q;
  long long K;
  cin >> N >> K >> Q;
  
  vector<long long> A(N,0);
  
  int B;
  for (int i = 0; i < Q; i++) {
    cin >> B;
    A.at(B-1)++;
  }
  
  for (int i = 0; i < N; i++) {
    if (Q - A.at(i) < K){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}
    




Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll e=c*d/__gcd(c,d);
    ll cnt1=b/c,cnt2=b/d,cnt3=b/e;
    if(a%c==0)
        cnt1-=(a/c-1);
    else
        cnt1-=a/c;
    if(a%d==0)
        cnt2-=(a/d-1);
    else
        cnt2-=(a/d);
    if(a%e==0)
         cnt3-=(a/e-1);
    else
        cnt3-=a/e;
    cout<<(b-a+1)-(cnt1+cnt2-cnt3);
    return 0;

}

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

void solve() {
    std::string s;
    std::cin >> s;

    for (auto c : s) {
        if ((c -= 3) < 'A') c += 26;
        std::cout << c;
    }
    std::cout << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3228
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Sugar Water
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_F = 3000;

/* typedef */

/* global variables */

bool dp0[MAX_F / 100 + 1], dp1[MAX_F + 1];

/* subroutines */

/* main */

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  int g = f / 100;
  for (int i = 0; i <= g; i += a)
    for (int j = i; j <= g; j += b) dp0[j] = true;

  for (int i = 0; i <= f; i += c)
    for (int j = i; j <= f; j += d) dp1[j] = true;

  double maxr = -1.0;
  int maxi = -1, maxj = -1;
  for (int i = 1; i <= g; i++)
    if (dp0[i]) {
      int x = 100 * i;
      for (int j = 0; x + j <= f && j <= i * e; j++)
	if (dp1[j]) {
	  double r = (double)j / i;
	  if (maxr < r) maxr = r, maxi = i, maxj = j;
	}
    }

  printf("%d %d\n", maxi * 100 + maxj, maxj);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S;
int main()
{
    int count1=0,count2=0;
    cin>>S;
      for(int i=0;i<3;i++)
      {
          if(S[i]=='B')
            count1++;
            else if(S[i]=='A')
                count2++;
      }
      if(count1==3||count2==3)
      {
          cout<<"No"<<endl;
      }
      else
        cout<<"Yes"<<endl;
    return 0;
}


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

int a[100001],b[100001];

int main()
{
	int n,m;
	cin>>n>>m;
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=0;
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		b[x]=max(b[x],a[y]);
		b[y]=max(b[y],a[x]);
	}
	
	int ans=0;
	for(int i=1;i<=n;i++)
		if(a[i]>b[i])
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4384
#include <iostream>
#include <algorithm>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

int N;
char S1[60];
char S2[60];

int mod = 1000000007;

signed main()
{
    cin >> N;
    REP(i,N) cin >> S1[i];
    REP(i,N) cin >> S2[i];

    int ans = 0;
    REP(i,N)
    {
        if (S1[i] == S2[i])
        {
            // たて
            if (i == 0)
            {
                ans = 3;
            }
            else
            {
                ans = S1[i-1] == S2[i-1] ? ans*2 % mod : ans;
            }
        }
        else
        {
            // よこ
            if (i == 0)
            {
                ans = 6;
            }
            else
            {
                ans = S1[i-1] == S2[i-1] ? ans*2 % mod : ans*3 % mod;
            }
            ++i;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
$c = ('a'..'z').to_a
def c2n(char)
  return $c.index(char)
end

def n2c(i)
  return $c[i]
end

def dec(c, ai, b)
  return n2c((ai*(c2n(c)-b)) % 26)
end

p1 = c2n("t")
p2 = c2n("h")

a  = [1,3, 5, 7,9,11,15,17,19,21,23,25] # candidate of alpha
ai = [1,9,21,15,3,19, 7,23,11, 5,17,25] # inverse of the alpha in mod 26

n = gets.to_i
n.times{
  line = gets.chomp
  words = line.split
  ainv = 1
  b = 0
  words.each{|w|
    if w.size == 4
      #candidate of that or this
      c1 = c2n(w[0])
      c2 = c2n(w[1])
      i = 0
      while i < ai.size && (p1-p2) % 26 != (ai[i] * (c1-c2)) % 26
        i += 1
      end
      next if i == ai.size
      ainv = ai[i]
      b = (c1 - a[i] * p1) % 26
      # confirm
      break if dec(w[2], ainv, b) == "a" && w[0] == w[3] 
      break if dec(w[2], ainv, b) == "i" && dec(w[3], ainv, b) == "s"
    end
  }
  line.split("").each{|c|
    if c == " "
      print c
    else
      print dec(c, ainv, b)
    end
  }
  puts
}

Measured memory_bytes: 8716
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   long n,m,i,flg=0;
   cin>>n>>m;
   long a[n];
   double sum=0,res;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       sum+=(double)a[i];
   }
   sort(a,a+n,greater<ll>());
   res=(sum/(double)(4*m));
   for(i=0;i<m;i++)
   {
        if(a[i]<res)
        flg=1;
   }
   if(flg==0)
   cout<<"Yes";
   else
   cout<<"No";
   
}




Measured memory_bytes: 3604
n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 16
a_1 = 0
a_2 = sum(a)
for i in range(n - 1):
    a_1 += a[i]
    a_2 -= a[i]
    ans = min(ans, abs(a_1 - a_2))
print(ans)

Measured memory_bytes: 31552
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, a, b, c = sc.nextInt
    val ls = new Array[Int](n)
    for (i <- 0 until n) {
      ls(i) = sc.nextInt
    }

    var minMP = Int.MaxValue

    def dfs(depth: Int, candidate: Array[Int]): Unit = {
      if (depth == n) {
        val countA = candidate.count(_ == 0)
        val countB = candidate.count(_ == 1)
        val countC = candidate.count(_ == 2)

        if (countA == 0 || countB == 0 || countC == 0) {
          return
        }

        var tmpMP = (countA + countB + countC - 3) * 10 // 合成分の消費MP
        var lengthA = 0
        var lengthB = 0
        var lengthC = 0
        for (i <- 0 until n) {
          candidate(i) match {
            case 0 => lengthA += ls(i)
            case 1 => lengthB += ls(i)
            case 2 => lengthC += ls(i)
            case _ => ()
          }
        }
        // 延長/短縮分の消費MP
        tmpMP += math.abs(a - lengthA) + math.abs(b - lengthB) + math.abs(c - lengthC)

        minMP = math.min(minMP, tmpMP)
        return
      }

      for (i <- 0 until 4) {
        candidate(depth) = i
        dfs(depth + 1, candidate)
      }
    }

    dfs(0, new Array[Int](n))
    println(minMP)
  }
}


Measured memory_bytes: 38648
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  int a, b, t;
  cin >> a >> b >> t;
  int sum = 0;
  for (int i = 1; i  * a <= t; i++) {
    sum += b;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const int maxn = 55;
ll v[maxn];
ll C[maxn][maxn];
void init(){
    memset(C,0,sizeof(C));
    C[0][0]=1;
    for(int i=1;i<=50;i++){
        C[i][0]=1;
        for(int j=1;j<=i;j++)
            C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
}

int main(){
    int n,a,b;
    init();
    scanf("%d%d%d",&n,&a,&b);
    double ave=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&v[i]);
    }
    sort(v,v+n);
    reverse(v,v+n);
    for(int i=0;i<a;i++){
        ave+=v[i];
    }
    ave/=a;
    printf("%.6f\n",ave);
    int num=0,k=0;
    for(int i=0;i<n;i++){
        if(v[i]==v[a-1]){
            num++;
            if(i<a)
                k++;
        }
    }
    ll ans=0;
    if(k==a){
        for(int i=a;i<=b;i++){
            ans+=C[num][i];
        }
    }
    else 
        ans+=C[num][k];
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

string to_binString(int val)
{
    if( !val )
        return std::string("0");
    string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  // val は偶数か？
            str.insert(str.begin(), '0');  //  偶数の場合
        else
            str.insert(str.begin(), '1');  //  奇数の場合
        val >>= 1;
    }
    return str;
}

map<ll,int> prime_factor(ll n){
    map<ll, int> ret;
    REP(i,2,sqrt(n) + 1){
        while(n%i == 0){
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1)ret[n] = 1;  
    return(ret);
}
int main()
{
    ll n;
    cin >> n;
    vll a(n),b(n),c(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n)cin >> c[i];
    sort(all(a));sort(all(b));sort(all(c));

    ll ans = 0;
    rep(i,n)
        ans += (lower_bound(all(a), b[i]) - a.begin()) * (c.end() - upper_bound(all(c), b[i]));

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

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

int main() {
    int min = 99999;
    int N,A;
    cin >> N;
    int count;
    for(int i = 0; i < N; i++){
       count = 0;
        cin >> A;
        for(;;){
          if(A%2 == 0){
              A/=2;
              count++;
          }else{
              break;
          }
        }
        if(count <= min){
         min = count;   
        }
    }
    
    cout << min << endl;
} 

Measured memory_bytes: 256
# B - YYM or MMYY
S = input()
s_for, s_back = int(S[:2]), int(S[2:])

if s_for >=1and s_for <= 12:
    if s_back >= 1 and s_back <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if s_back >= 1 and s_back <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n);
	ll ans=0;
	rep(i,n){
		cin>>a[i];
		ans+=a[i]-1;
	}
	cout<<ans<<endl;
}

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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1)
  {
    cout << "No" << endl;
  }
  else
  {
    int count = 0;
    for (int i = 0; i < n / 2; i++)
    {
      if (s[i] == s[i + (n / 2)])
      {
        count++;
      }
    }
    if (count == n / 2)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, x, N) for (int i = x; i < (N); i++)
using namespace std;
int main()
{
    int x, y, z;
    cin >> x;
    if (x < 100)
    {
        cout << 0 << endl;
    }
    else
    {
        z = x % 100;
        y = x / 100;
        if (z < 5)
        {
            cout << 1 << endl;
        }
        else
        {
            if (z % 5 == 0 && z / 5 <= y)
            {
                cout << 1 << endl;
            }
            else if (z / 5 + 1 <= y)
            {
                cout << 1 << endl;
            }
            else
            {
                cout << 0 << endl;
            }
        }
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static long mod = (int)Math.pow(10,9)+7;
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int m = sc.nextInt();
		long total = 0;
		long digit = 0;
		long ans = 0;
		for(int i = 0; i < m; i ++){
		    long d = sc.nextLong();
		    long a = sc.nextLong();
		    digit += a;
		    total += d*a;
		    ans += total/9;
		    total %= 9;
		}
		if(total == 0) ans--;
		pw.println(ans+digit-1);
		pw.close();
	}
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}



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

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

int main() {
    int l,r,d;cin>>l>>r>>d;
    int ans = 0;
    for(int i=l;i<=r;++i){
        if(i%d==0)++ans;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	ll dx[] = {-1,0,1,0};
	ll dy[] = {0,-1,0,1};
	while(cin>>N){
		if(N==0)break;
		vector<P> v(N);
		v[0] = {0,0};
		ll max_x = 0,min_x=0,max_y=0,min_y=0;
		FOR(i,1,N){
			ll n,d;
			cin >> n >> d;
			v[i] = {v[n].first+dx[d],v[n].second+dy[d]};
			max_x = max(max_x,v[i].first);
			min_x = min(min_x,v[i].first);
			max_y = max(max_y,v[i].second);
			min_y = min(min_y,v[i].second);
		}
		cout << (max_x-min_x+1) << " " << (max_y-min_y+1) << endl;
	}
}


Measured memory_bytes: 3200
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt();
    int B = in.nextInt();
    int C = in.nextInt();

    if (A == B)
        System.out.println(C);
    else if (B == C)
        System.out.println(A);
    else
        System.out.println(B);
    }
}

Measured memory_bytes: 23764
import math

s = input()
s = s.split()
count = 0

for i in range(int(s[0])):
    a = input()
    a = a.split()
    result = math.sqrt(int(a[0])*int(a[0])+int(a[1])*int(a[1]))
    if result<=int(s[1]):
        count += 1

print(count)

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

int main(){
  int N;
  cin>>N;
  long long length=0;
  long long in,inw;
  long long sum=0;
  for(int i=0;i<N;i++){
    cin>>in>>inw;
    length+=inw;
    sum+=in*inw;
  }
  cout<<(sum-1)/9+length-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=210000;
int A[N];
long long ans=0;
int n,y[N];
long long x[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&A[i]);
	for (int i=1;i<=n;i++){
		x[i]=x[i-1]+A[i]; y[i]=y[i-1]^A[i];
	}
	int r=1;
	for (int i=1;i<=n;i++){
		while (r<=n&&x[r]-x[i-1]==(y[r]^y[i-1])) r++;
		ans+=r-i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
bool compare(int a,int b)
{
      return a>b;
}
int main()
{

      int a,b,c,d[100],j=0;
      cin>>a>>b>>c;
      for(int i=1;i<=min(a,b);i++)
      {
              if(a%i==0&&b%i==0)
              {
                     d[j]=i;
                     j++;
              }
      }
      sort(d,d+j,compare);
      cout<<d[c-1]<<endl;
        return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n;cin >> n;
    string s; cin >> s;
    deque<char> c;
    ll r = 0,l = 0;
    ll r_must = 0,l_must = 0;
    rep(i,n) c.push_back(s[i]);
    rep(i,n){
        if(s[i] == '(') l++;
        else{
            if(l==0)l_must++;
            else l--;
        }
    }
    r_must = l;
    rep(i,l_must)c.push_front('(');
    rep(i,r_must)c.push_back(')');
    while(!c.empty()){
        cout<<c.front();
        c.pop_front();
    }
    cout << endl;
}


Measured memory_bytes: 256
def insertionSort(a,n):
    for i in range(n):
        print(a[i],end="")
        if(i!=n-1):
            print(" ",end="")
    print("")    
    for i in range(1,n):
        v=a[i]
        j=i-1
        while(j>=0 and a[j]>v):
            a[j+1] = a[j]
            j-=1
        a[j+1] = v
        for i in range(n):
            print(a[i],end="")
            if(i!=n-1):
                print(" ",end="")
        print("")

a=[]
n=int(input())
s=input()
a=list(map(int,s.split()))
insertionSort(a,n)

Measured memory_bytes: 8432
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  cout << (double) (N - N / 2) / N << endl;
  return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, a[110];
signed main() {
    cin >> N;
    int ans = 0;
    reps(i, N) {
        cin >> a[i];
        if ((i & 1) && (a[i] & 1)) { ans++; }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
n, m, c = map(int, input().split())
b_l = list(map(int, input().split()))
ans = []
for i in range(n):
    a_l = list(map(int, input().split()))
    if sum(a*b for a, b in zip(a_l, b_l)) + c > 0:
        ans.append(i)
print(len(ans))


Measured memory_bytes: 2940
input1 = input()
N = int(input1)
input2 = input()
S = list(input2)
 
R = 0
B = 0
h = 'No'
 
for i in range(N):
  if S[i] == 'R':
    R += 1
  else:
    B += 1
  
if R > B:
  h = 'Yes'

print(h)


Measured memory_bytes: 2940