akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  double T,X;
  cin >> T >> X;
  print(T/X);
  

  return 0;
}


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

int main(){
  string S;
  cin >> S;
  if(S[0]!=S[1] && S[0]!=S[2] && S[1]!=S[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  int temp=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a==temp+1) temp=a;
  }
  if(temp==0) cout<<-1<<endl;
  else cout<<n-temp<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>





using namespace std;





int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
}









Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int a, b;
    cin >> a >> b;
    int ans = -1;
    if (IN(0, 10, a) && IN(0, 10, b))
    {
        ans = a * b;
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  vector<char> s(3);
  in3(s[0], s[1], s[2]);
  sort(all(s));
  string g, t;
  g = s[1];
  t = s[0];
  t = t + g;
  g = s[2];
  t = t + g;
  if(t == "abc")
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

class vertex {
 public:
  double x;
  double y;
  double r;
};

int main() {
  unsigned N;
  double x0, y0, x1, y1;
  std::cin >> x0 >> y0 >> x1 >> y1;
  std::cin >> N;
  std::vector<vertex> v(N + 2);
  v[0].x = x0;
  v[0].y = y0;
  v[0].r = 0.0;
  v[1].x = x1;
  v[1].y = y1;
  v[1].r = 0.0;
  for (unsigned i = 2; i < N + 2; ++i) {
    std::cin >> v[i].x >> v[i].y >> v[i].r;
  }
  std::vector<std::vector<double>> cost(N + 2, std::vector<double>(N + 2));
  for (unsigned i = 0; i < N + 2; ++i) {
    cost[i][i] = 0.0;
  }
  for (unsigned i = 0; i < N + 2; ++i) {
    for (unsigned j = 0; j < i; ++j) {
      double tmp = std::max(0.0, std::sqrt(std::pow(v[i].x - v[j].x, 2) + std::pow(v[i].y - v[j].y, 2)) - (v[i].r + v[j].r));
      cost[i][j] = tmp;
      cost[j][i] = tmp;
    }
  }
  for (unsigned k = 0; k < N + 2; ++k) {
    for (unsigned i = 0; i < N + 2; ++i) {
      for (unsigned j = 0; j < N + 2; ++j) {
        cost[i][j] = std::min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  std::cout << std::setprecision(16) << cost[0][1];
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int mul = a;
    set<int> rem;
    bool t = true;
    while (t)
    {
        if(mul%b == c){
            cout << "YES";
            break;
        }
        else
        {
            if(rem.find(mul%b) == rem.end()){
                rem.insert(mul%b);
                mul += a;
            }
            else
            {
                cout << "NO";
                break;
            }
            
        }
        
    }
    
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int W = 0, H = 0, 
	    x = 0, y = 0, r = 0;
	
	cin >> W;
	cin >> H;
	cin >> x;
	cin >> y;
	cin >> r;

	if( (0 > x - r) || (W < x + r) )
	{
		cout << "No" << endl;
		return 0;
	}
	
	if( (0 > y - r) || (H < y + r) )
	{
		cout << "No" << endl;
		return 0;
	}
	
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 3092
#include <iostream>

using namespace std;
typedef long long ll;
const ll INF = (1LL << 58);
ll G[101][101];

int main(void) {
    int V, E;
    cin >> V >> E;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            if (i == j) continue;
            G[i][j] = INF;
        }
    }

    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s][t] = d;
    }

    for (int k = 0; k < V; k++)
        for (int i = 0; i < V; i++)
            for (int j = 0; j < V; j++)
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);

    for (int i = 0; i < V; i++) {
        if (G[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            if (G[i][j] < (1LL << 40)) cout << G[i][j];
            else cout << "INF";
            if (j < V - 1) cout << " ";
            else cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1236
import sys

N = int(input())
D = [list(map(int, input().split())) for D in range(N)]
count = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
        if count == 3:
            print('Yes')
            sys.exit()
    else:
        count = 0

print('No')

Measured memory_bytes: 9184
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;

ll N;
ll a[2][101];
ll ans = 0;
bool flag = true;
int main(void)
{
	cin >> N;
	FOR(i, 0, N)cin >> a[0][i];
	FOR(i, 0, N)cin >> a[1][i];
	FOR(i, 0, N) {
		ll cur = 0;
		FOR(k, 0, i+1)cur += a[0][k];
		FOR(k, i, N)cur += a[1][k];
		ans = max(ans, cur);
	}
	ct(ans);
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
students=[tuple(map(int,input().split())) for i in range(N)]
point=[tuple(map(int,input().split())) for i in range(M)]
inf=float('inf')
for n in students:
    ans=0
    Min=inf
    for j in range(M):
        if abs(n[0]-point[j][0])+abs(n[1]-point[j][1])<Min:
            ans=j+1
            Min=abs(n[0]-point[j][0])+abs(n[1]-point[j][1])
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

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

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0,k,x,r;
    set<string> s;
    string temp ;
    cin >> n ;
    rep(i,n) 
    {
        cin >> temp ;
        s.insert(temp);
    }
    cout << s.size() ;
    
    return 0;
}

Measured memory_bytes: 19184
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int sum = 0;
  int sum2 = 0;
  for(int i=0; i<N; i++){
    int tmp;
    cin >> tmp;
    sum += tmp;
    sum2 += tmp*tmp;
  }
  int ans = 1e9;
  // X = sum/N or (sum+N-1)/Nのときmin
  ans = N*(sum/N)*(sum/N) - 2*sum*(sum/N) + sum2;
  ans = min(ans, N*((sum+N-1)/N)*((sum+N-1)/N) - 2*sum*((sum+N-1)/N) + sum2);
  cout << ans << endl;
  return 0;
            
            
  
}

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

int main() {
        ll a,b,c,d;
        ll i;
        cin>>a>>b>>c>>d;
        int n=4;
        ll x[n];
        
        x[0]=a*c;
        x[1]=a*d;
        x[2]=b*c;
        x[3]=b*d;
        
        sort(x,x+n);
        cout<<x[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 3596
/*
4
10 80 90 30
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    long long arr[n+1]={0},dp[n+1][n+1]={0,0};
    for(int i=1;i<=n;i++)
    	cin>>arr[i];



    for(int i=n;i>=1;i--)
    {
    	for(int j=i;j<=n;j++)
    	{
    		if(i==j)
    			dp[i][j] = arr[j];
    		else{
    			dp[i][j] = max(arr[i]-dp[i+1][j],arr[j]-dp[i][j-1]);
    		}
    	}
    }

    cout<<dp[1][n];
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;

long sum(vector <long> v) {
	long s=0;
	long n = v.size();
	for (long i = 0; i < n; i++) {
		s = s + v[i];
	}
	return s;
}

int main()
{
	string str;
	getline(cin, str);
	int N = stoi(str);

	vector <long> A;

	for (long i = 0; i < N; i++) {
		getline(cin, str);
		A.push_back(stoi(str));
	}
	long ans=0;
	sort(A.begin(), A.end());
	if (N % 2 == 0) {
		vector <long> U, L;
		for (int i = 0; i < N; i++) {
			if (i < N / 2) {
				L.push_back(A[i]);
			}
			else {
				U.push_back(A[i]);
			}
		}
		ans = (sum(U) * 2 - U[0]) - (sum(L) * 2 - L[N/2-1]);
	}
	else if (N == 3) {
		long ans1, ans2;
		ans1 = A[2]  + A[1] - A[0] * 2;
		ans2 = A[2] * 2 - A[1] - A[0];
		ans = ans1 > ans2 ? ans1 : ans2;
	}
	else{
		vector <long> U1, L1, U2, L2;
		long ans1, ans2;
		for (int i = 0; i < N; i++) {
			if (i < (N-1) / 2) {
				L1.push_back(A[i]);
			}
			else {
				U1.push_back(A[i]);
			}
		}
		for (int i = 0; i < N; i++) {
			if (i < (N - 1) / 2 + 1) {
				L2.push_back(A[i]);
			}
			else {
				U2.push_back(A[i]);
			}
		}
		ans1 = (sum(U1) * 2 - U1[0] - U1[1]) - (sum(L1) * 2);
		ans2 = (sum(U2) * 2) - (sum(L2) * 2 - L2[(N-1)/2] - L2[(N - 1) / 2 -1]);
		ans = ans1 > ans2 ? ans1 : ans2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int n, k;
Int h[108000];
Int dp[108000];
int main(){
  cin >> n >> k;
  for(int i = 1;i <= n;i++)cin >> h[i];
  fill(dp, dp + 108000, INF);
  dp[1] = 0;
  for(int i = 2;i <= n;i++){
    for(int j = 1;j <= k && i - j >= 1;j++){
      dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
    //    cout << dp[i] << endl;			    
  }
  cout << dp[n] << endl;
  return 0;
}

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

int n,k;
///store position of outdeg0
int ansp[500005];
int fenwick[500005];
int ans[500005];

int arr[500005];

void update(int pos,int val){
    while (pos<n+2){
        fenwick[pos]+=val;
        pos += pos&(-pos);
    }
}

int query(int pos){
    int ans = 0;
    while (pos>0){
        ans += fenwick[pos];
        pos-= pos&(-pos);
    }
    return ans;
}

struct node{
int s,e;
int v=0,lazy=0,vp;
node *l,*r;
node(int _s, int _e){
    s = _s;
    e = _e;
    vp = e;
    if (s!=e){
        l = new node(s,(s+e)/2);
        r = new node((s+e)/2+1,e);
    }
}
void proc(){
    if (lazy==0) return;
    v += lazy;
    if (s!=e){
        l->lazy+=lazy;
        r->lazy+=lazy;
    }
    lazy = 0;
}
void update(int a, int b, int val){
    proc();
    if (a<=s&&b>=e){
        lazy += val;
        proc();
        return;
    }
    if (b<=(s+e)/2){
        l->update(a,b,val);
    }
    else if (a>(s+e)/2){
        r->update(a,b,val);
    }
    else{
        l->update(a,b,val);
        r->update(a,b,val);
    }
    proc();
    l->proc();
    r->proc();
    if (l->v<r->v){
        v = l->v;
        vp = l->vp;
    }
    else {
        v = r->v;
        vp = r->vp;
    }
}
pair<int,int> query(int a, int b){
    proc();
    //printf("node %d %d, v %d\n",s,e,v);
    if (a<=s&&b>=e){
        return {v,vp};
    }
    if (b<=(s+e)/2){
        return l->query(a,b);
    }
    if (a>(s+e)/2){
        return r->query(a,b);
    }
    else{
        pair<int,int> t1 = l->query(a,b);
        pair<int,int> t2 = r->query(a,b);
        if (t1.first<t2.first) return t1;
        return t2;
    }
}


}*root;


int main(){
    scanf("%d%d",&n,&k);
    root = new node(1,n);
    for (int x = 0; x<n; x++){
        scanf("%d",&arr[x+1]);
    }
    for (int x = 1; x<=k; x++){
        update(arr[x],1);
    }
    int sz = k;
    for (int x = 1; x<=n; x++){
        //printf("num %d\n",sz-query(arr[x]));
        root->update(x,x,sz-query(arr[x]));
        int t = x-k+1;
        if (t>=1&&t<=n){
            update(arr[t],-1);
            sz--;
        }
        t = x+k;
        if (t>=1&&t<=n){
            update(arr[t],1);
            sz++;
        }
    }
    for (int x = n; x>=1; x--){
        auto res = root->query(1,n);
        assert(res.first==0);
        ansp[x] = res.second;
        ans[res.second] = x;
        root->update(res.second,res.second,1000000);
        root->update(max(1,res.second-k+1),min(n,res.second+k-1),-1);
    }

    for (int x = 1; x<=n; x++){
        printf("%d\n",ans[x]);
    }

}


Measured memory_bytes: 58240
import bisect
N,M,K = map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

A_acc=[0]
B_acc=[0]

for a in A:
    A_acc.append(a+A_acc[-1])
for b in B:
    B_acc.append(b+B_acc[-1])

ans=0
for i in range(len(A_acc)):
    a_time = A_acc[i]
    remain = K-a_time
    if remain>=0:
        idx = bisect.bisect_right(B_acc,remain)
        if idx==0:
            continue
        ans=max(ans,i+idx-1)
print(ans)




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


int main(){
    int n[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    
    cout << n[K-1] << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        double kaku = 0;
        for(int i = 1; i <= a; i++)
        {
            int n = i;
            int sum = 0;
            while(n < b)
            {
                n *= 2;
                sum++;
            }
            kaku += Math.Pow(0.5, sum) / a;
        }
        Console.WriteLine(kaku);
    }
}

Measured memory_bytes: 11092
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断

    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N, M = map(int, input().split())
uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split())
    uf.Unite(a-1, b-1)

ans = -1
for i in range(N):
    ans = max(ans, uf.Count(i))
print(ans)


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


from sys import stdin
import math



############################################

# read data for n sequences.
input=[]
for _ in range(6):
    input.append(int(stdin.readline().split()[0]))
N=input[0]
train=input[1:6]

mintrain=min(train)
ans=math.ceil(N/mintrain)+4
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>

using namespace std;

const int N = 1000;

const int INF = 1e9;

int u[1000000], cl[1000000], n, d1, d2, cnt[4];

vector < vector <int> > g (1000000), f (1000000);

int dist (pair <int, int> a, pair <int, int> b)
{
    return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}

void dfs_bw (int x, int c)
{
    u[x] = 1;
    cl[x] += 2 * c;
    
    for (int to : g[x])
	if (!u[to])
	    dfs_bw (to, !c);
}

void dfs_rb (int x, int c)
{
    u[x] = 1;
    cl[x] += c;
    
    for (int to : f[x])
	if (!u[to])
	    dfs_rb (to, !c);
}

void build (int d, vector < vector <int> >& g)
{
    vector < pair <int, int> > ab;
    
    for (int i = -n; i < n; i++)
	for (int j = -n; j < n; j++)
	    if (i * i + j * j == d)
	    ab.push_back ({i, j});
    
    for (int i = 0; i < n; i++)
	for (int j = 0; j < n; j++)
	    for (auto a : ab)
	    {
		if (i + a.first < n && i + a.first >= 0
		    && j + a.second < n && j + a.second >= 0)
		g[n * i + j].push_back (n * (i + a.first) + j + a.second);
	    }
}

int main () 
{
    cin >> n >> d1 >> d2;
    
    n *= 2;
    
    build (d1, g);
    build (d2, f);
    
    for (int i = 0; i < n * n; i++)
	if (!u[i]) dfs_bw (i, 0);
    
    memset (u, 0, sizeof (u));
    
    for (int i = 0; i < n * n; i++)
	if (!u[i]) dfs_rb (i, 0);
    
    for (int i = 0; i < n * n; i++)
	cnt[cl[i]]++;
    
    int ind = 0, ptr = 0;
    
    for (int i = 0; i < 4; i++)
	if (cnt[i] > cnt[ind]) ind = i;
    
    for (int i = 0; i < n; i++)
	for (int j = 0; j < n; j++)
	    if (cl[n * i + j] == ind)
	    {
		printf ("%d %d\n", i, j);
		ptr++;
		
		if (4 * ptr == n * n) return 0;
	    }
	
		
	
}

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

int main() {
  int n, k; cin >> n >> k;
  vec s(n,0);

  rep(i,k) {
    int d;
    cin >> d;
    rep(j,d) {
      int a;
      cin >> a;
      s[a-1]++;
    }
  }
  int c = 0;
  rep(i,n) {
    if (s[i] == 0) {
      c++;
    }
  }

  cout << c << endl;
}


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

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main(){
    int n;
    const int TIME = 86400;
     
    while( scanf("%d",&n) , n ){
        int timeTable[TIME] = {};
        for(int i=0 ; i<n ; ++i ){
            int h1,m1,s1,h2,m2,s2,start,end;
            scanf("%d:%d:%d %d:%d:%d", &h1 , &m1 , &s1 , &h2 , &m2 , &s2 );
            start = s1 + m1*60 + h1*60*60;
            end   = s2 + m2*60 + h2*60*60 -1;
            for(int j = start ; j <= end ; ++j ){
                timeTable[j]++;
            }
        }
        int ans = 0;
        for(int i=0 ; i<TIME ; ++i ){
            ans = max( ans , timeTable[i] );
        }
        printf("%d\n", ans );
         
    }
}

Measured memory_bytes: 1224
import sys

S=input()
N=len(S)
if S!=S[::-1]:
  print("No")
  sys.exit(0)
check=S[0:int((N-1)/2)]
#print(check)
if check!=check[::-1]:
  print("No")
  sys.exit(0)
check=S[int((N+3)/2)-1:N]
#print(check)
if check!=check[::-1]:
  print("No")
  sys.exit(0)
print("Yes")

Measured memory_bytes: 9068
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
using namespace std;
const double PI = 3.14159265358979323846;
 
int main() {
	float R;
	cin >> R;
 
	cout << 2.0 * PI * R << endl;
	return 0;
}

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

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

  bool can = false;
  for(int i=1; i<=9; ++i)
  {
    for(int j=1; j<=9; ++j)
    {   
      int pro = i * j;  
      if( pro == n ) 
        can = true;
    }   
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll a,b,c;

void input(void){
cin>>a>>b>>c;
}
void solve(void){
    cout<<max(b+c-a,ll(0))<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;

int main ()
{
    int num , len , cnt = 0;
    st chs ;

    cin >> num ;
    cin >> chs ;

    len = chs . size() ;

    for (int i = 0 ; i < len ; i ++)
    {
        if (chs [i] == 'A')
        {
            st ser = chs . substr (i , 3) ;
            if (ser == "ABC")
                cnt ++ ;
        }
    }
    cout << cnt << endl ;

    return 0 ;
}


Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        ArrayList<Pair> pairs = new ArrayList<>();
        for(int i = 0;i < n;i++){
            pairs.add(new Pair(sc.nextInt(),sc.nextInt()));
        }
        Collections.sort(pairs);
        Iterator<Pair> it = pairs.iterator();
        while(it.hasNext()){
            Pair a = it.next();
            a.print();
        }
    }

    static class Pair implements Comparable<Pair>{
        int x,y;
        Pair(int x,int y){
            this.x = x;
            this.y = y;
        }

        public int compareTo(Pair p){
            if(x < p.x) return -1;
            else if(x == p.x){
                if(y < p.y) return -1;
                else return 1;
            }
            else    return 1;
        }

        public void print(){
            System.out.println(x+" "+y);
        }
        
    }
}


Measured memory_bytes: 110468
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int X,Y,Z;
	cin >> X >> Y >> Z;
	cout << (X-Z)/(Y+Z);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

const int dev = 1e9+7;
typedef unsigned long long ull;

int main(){
    string S;
    cin >> S;
    int n = S.size();
    bool b1 = n%2;
    bool b2 = (S[0]==S[n-1]);
    if(b1^b2){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

class dep_union_find{
    int n_; 
    vector<int> par, rank, dep;

public:
    dep_union_find(int n): n_{n}, par(n), rank(n, 1), dep(n, 0){
        iota(par.begin(), par.end(), 0);
    } 

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

    // dep[y] = dep[x] + d
    bool unite(int x, int y, int d) {
        int rx = find(x), ry = find(y);
        if (rx == ry) {
            return false;
        }

        d = d + dep[x] - dep[y];

        if (rank[rx] < rank[ry]) {
            swap(rx, ry);
            d = -d;
        }

        if (rank[rx] == rank[ry]) ++rank[rx];

        par[ry] = rx;
        
        dep[ry] = d;

        return true;
    }

    int find(int x) {
        if(par[x] == x) {
            return x;
        } else {
            int r = find(par[x]);
            dep[x] += dep[par[x]];
            return par[x] = r;
        }
    }

    // dep[x] - dep[y]
    int diff(int x, int y) {
        if (find(x) != find(y)) {
            return -1;
        } else {
            return dep[x] - dep[y];
        }
    }

    void debug() const {
        for (int d : dep) cout << d << " ";
        cout << endl;
    }
};

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

    dep_union_find uf(n);

    REP(_, m) {
        int l, r, d; cin >> l >> r >> d;
        --l; --r;

        if (!uf.same(l, r)) {
            uf.unite(l, r, d); // dep[r] = dep[l] + d
        } else {
            if (uf.diff(r, l) != d) { // dep[r] - dep[l] != d
                cout << "No" << endl;
                return 0;
            }
        }
    }

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


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

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





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
const ll inf = 2e18;


int n;
ll a[maxn];
ll racc[maxn];

ll mul(ll x, ll y) {
    if (x>inf/y) {
	return inf;
    }
    return x*y;
}


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

    cin>>n;

    if (n==0) {
	int x; cin>>x;
	if (x != 1) out(-1);
	out(1);
    }
    
    n++;
    
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }


    for (int i=n-1; i>=0; i--) {
	racc[i]=a[i]+racc[i+1];
    }

    if (a[0]>0) {
	out(-1);
    }

    ll res = 1;
    ll par = 1;
    
    for (int i=1; i<n; i++) {
	ll maxp = mul(par, 2);
	if (a[i]>maxp) {
	    out(-1);
	}
	maxp -= a[i]; // make leaves
	res += a[i];
	maxp = min(maxp, racc[i+1]);
	res += maxp;
	par = maxp;

	//cout<<i<<": "<<res<<endl;
    }


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


Measured memory_bytes: 5236
import sys

for line in sys.stdin.readlines():
    data = line.rstrip('\n').split()
    height = data[0]
    width = data[1]
    #print(height,width)
    if height=='0' and width=='0':
        break
    for h in range(int(height)):
        for w in range(int(width)):
            print('#',end='')
        print('')
    print('')



Measured memory_bytes: 7020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if((b-a)==(c-b)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int max = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+max+1; j < n; j++) {
                if(0 < s.indexOf(s.substring(i, j), j)){
                    max = j - i;
                }else{
                    break;
                }
            }
        }
        System.out.println(max);
        sc.close();

    }

}


Measured memory_bytes: 40020
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			rec(n, n, "");
		}
		System.out.flush();
	}

	void rec(int max, int n, String s){
		if(n==0){
			println(s.substring(0, s.length()-1));
			return;
		}
		for(int i=min(max, n); i>=1; i--){
			if(n-i>=0){
				rec(min(max, i), n-i, s+i+" ");
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
class Array
    def sum
        self.reduce(0){|i1,i2| i1+i2}
    end
end

N, K = gets.split.map(&:to_i)
Vs = gets.split.map(&:to_i)
puts (0..([N,K].min)).map{|l|
    (0..([N-l, K-l].min)).map{|r|
        ts = (Vs[0...l] + Vs.reverse[0...r]).sort
        f = [K - l - r, l+r].min # number of item can be dropped 
        ts[0...f].select{|n| n>0}.sum + ts[f...(l+r)].sum
    }.max
}.max

Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cassert>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;



int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int A,B;
  cin >> A >> B;
  cout << (A + B) % 24 << endl;
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = long.Parse(Console.ReadLine());
            Console.WriteLine((N * (N - 1)) / 2);
        }
    }
}


Measured memory_bytes: 13140
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	hs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&hs[i])
	}

	if n <= k {
		fmt.Print(0)
		return
	}

	sort.Sort(sort.Reverse(sort.IntSlice(hs)))

	var hs2 []int
	if k == 0 {
		hs2 = hs
	} else {
		hs2 = hs[k:]
	}

	cal := 0
	for _, h := range hs2 {
		cal = cal + h
	}

	fmt.Print(cal)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        if (x[i] > y[i]) {
            swap(x[i], y[i]);
        }
    }
    ll xa = *max_element(x.begin(), x.end());
    ll xb = *min_element(x.begin(), x.end());
    ll ya = *max_element(y.begin(), y.end());
    ll yb = *min_element(y.begin(), y.end());
    ll ans = (yb - ya) * (xb - xa);
    if (xa < yb || xa == ya || xb == yb) {
        cout << ans << '\n';
        return 0;
    }
    ll mx = xa, mn = yb;
    for (int i = 0; i < n; i++) {
        if (x[i] == xb && y[i] == ya) {
            cout << ans << '\n';
            return 0;
        }
        if (x[i] == xb) {
            mx = max(mx, y[i]);
        }
        if (y[i] == ya) {
            mn = min(mn, x[i]);
        }
    }
    vector<pair<ll, ll>> p;
    for (int i = 0; i < n; i++) {
        if (x[i] < mn && mx < y[i]) {
            p.emplace_back(mn - x[i], y[i] - mx);
        }
    }
    ll dif = 0;
    if (!p.empty()) {
        sort(p.begin(), p.end());
        for (int i = p.size() - 1; i > 0; i--) {
            p[i - 1].second = max(p[i - 1].second, p[i].second);
        }
        dif = min(p.back().first, p[0].second);
        for (int i = 0; i < p.size() - 1; i++) {
            dif = min(dif, p[i].first + p[i + 1].second);
        }
    }
    ans = min(ans, (ya - xb) * (mx - mn + dif));
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>
int main(void)
{
    int n,temp;
    double total,t;
    while(1)
{
        scanf("%d",&n);
        if(n==0)return 0;
        total=t=0;
        for(int i=0;i<n;i++)
{
            scanf("%d",&temp);
            total+=temp*temp;
            t+=temp;
        }
        printf("%lf\n",sqrt((total-t*t/n)/n));
    }
}


Measured memory_bytes: 2040
n = int(input())
ai = list(map(int, input().split()))
min = 1000000
max = -1000000
sum = 0
for i in range(n):
    if ai[i] >= max:
        max = ai[i]
    if min >= ai[i]:
        min = ai[i]
    sum += ai[i]
print("%d %d %d" % (min, max, sum))


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

vector<int> sw[15];
int P[15];

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  int n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    int k;cin>>k;
    for(int j=0;j<k;j++){
      int s;cin>>s;s--;
      sw[i].push_back(s);
    }
  }
  int ans=0;
  for(int i=0;i<m;i++)cin>>P[i];
  for(int i=0;i<(1<<n);i++){
    bool ok=true;
    // cout<<i<<':'<<endl;
    for(int j=0;j<m;j++){
      int cnt=0;
      for(auto t : sw[j]){
        if((1<<t) & i)cnt++;
      }
      // cout<<cnt<<endl;
      if( (cnt%2) != P[j])ok=false;
    }
    if(ok){ans++;}
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	long long int x,y,ans;
	cin >> x >> y;
	for(int i = 2;i < 10000; i++)
	{
		if((i * x) % y != 0)
		{
			cout << i * x << endl;
				return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int64> A(N);
  cin >> A;
  sort(A.begin(), A.end());
  int ans = 1;
  for (int i = 0; i < N - 1; i++) {
    if (A[i + 1] > A[i] * 2) {
      ans = 1;
    } else {
      ans++;
    }
    A[i + 1] += A[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
H = list(map(int, input().split()))
ans = [1]*N
for _ in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        ans[b-1] = 0
    elif H[a-1] < H[b-1]:
        ans[a-1] = 0
    else:
        ans[a-1] = 0
        ans[b-1] = 0

print(sum(ans))


Measured memory_bytes: 20132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int M, ans = 0;
    cin >> M;
    rep(i, M) {
        int x;
        cin >> x;

        auto itr = lower_bound(A.begin(), A.end(), x);
        if (itr != A.end() && *itr == x)
            ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    sort(all(a));

    vector<ll> b(n,0);
    rep(i,n){
        if(i==0) b[i]=a[i];
        else b[i]=b[i-1]+a[i];
    }
    int ans=1;

    for(int i=n-2;i>=0;i--){
        if(b[i]*2>=a[i+1]) ans++;
        else break;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include <queue>
#include <stdint.h>
#include <vector>
#include <utility>
#include <array>
using namespace std;
typedef void (*single_source_shortest_path_callback_t)(int32_t index, int32_t weight);

#define GRAPH_MAX_SIZE 10000
enum color_t { WHITE, GRAY, BLACK };

static int32_t weights[GRAPH_MAX_SIZE];
static color_t colors[GRAPH_MAX_SIZE];

bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
{
  if ((graph == nullptr) || (size == 0)) return false;

  int32_t i;
  for (i = 0; i < GRAPH_MAX_SIZE; i++) {
    weights[i] = INT32_MAX;
    colors[i] = WHITE;
  }

  weights[0] = 0;
  priority_queue<pair<int32_t, int32_t>> que;
  que.push(make_pair(-1 * weights[0], 0));

  while (!que.empty()) {
    pair<int, int> top = que.top();
    que.pop();
    int32_t top_index = top.second;
    int32_t top_weights = (-1) * top.first;
    if (top_weights > weights[top_index]) continue;

    callback(top_index, top_weights);
    colors[top_index] = BLACK;

    vector<pair<int32_t, int32_t>> vertex = graph[top_index];
    for (auto connect_to = vertex.begin(); connect_to != vertex.end(); connect_to++) {
      int32_t index = (*connect_to).first;
      if (colors[index] != BLACK) {
        int32_t new_weight = weights[top_index] + (*connect_to).second;

        if (new_weight < weights[index]) {
          weights[index] = new_weight;
          colors[index] = GRAY;
          que.push(make_pair(-1 * weights[index], index));
        }
      }
    }
  }
  return true;
}

#if !defined(TEST)
static vector<pair<int32_t, int32_t>> graph[GRAPH_MAX_SIZE];
static int32_t routes[GRAPH_MAX_SIZE];

void callback(int32_t index, int32_t weight)
{
  routes[index] = weight;
}

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);

  uint32_t i;
  for (i = 0; i < num; i++) {
    int32_t index, len;
    scanf("%d", &index);
    scanf("%d", &len);
    uint32_t j;
    for (j = 0; j < len; j++) {
      int32_t k, v;
      scanf("%d %d", &k, &v);
      graph[i].push_back(make_pair(k, v));
    }
  }
  single_source_shortest_path(graph, num, callback);

  for (i = 0; i < num; i++) {
    printf("%d %d\n", i, routes[i]);
  }

  return 0;
}
#endif

Measured memory_bytes: 7700