akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (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)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    int flag = 0;
    double ans = 0;
    ans = (double)w * h / 2.0;
    if (x * 2 == w && y * 2 == h) {
        flag = 1;
    }
    if (y * w == h * x || y * w == h * (w - x)) {
        ans = (double)w * h / 2.0;
        cout << fixed << setprecision(10) << ans << " " << flag << endl;
        return 0;
    }
    if (x == w || y == h || x == 0 || y == 0) {
        cout << fixed << setprecision(10) << ans << " " << flag << endl;
        return 0;
    }
    cout << fixed << setprecision(10) << ans << " " << flag << endl;
    return 0;
}

Measured memory_bytes: 256
//
// Created by kichi on 2018/03/05.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>

using namespace std;


int main() {
    int n;
    cin >> n;
    long m=0;
    long a=0;
    long r=0;
    long c=0;
    long h=0;

    string str;
    for(int i=0;i<n;i++){
        cin>>str;
        if(str[0]=='M'){
            m++;
        }
        if(str[0]=='A'){
            a++;
        }
        if(str[0]=='R'){
            r++;
        }
        if(str[0]=='C'){
            c++;
        }
        if(str[0]=='H'){
            h++;
        }
    }

    unsigned long long sum = 0;

    sum += m * a * r;
    sum += m * a * c;
    sum += m * a * h;
    sum += m * r * c;
    sum += m * r * h;
    sum += m * c * h;
    sum += a * r * c;
    sum += a * r * h;
    sum += a * c * h;
    sum += r * c * h;

    printf("%llu\n", sum);
}

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

struct Card {
  char suit;
  char value;
};

void bubble(struct Card *C, int n) {
  int i, j;
  char temp;

  for(i = 0; i < n; i++) {
    for(j = n-1; j > i; j--) {
      if(C[j-1].value > C[j].value) {
	temp = C[j].value;
	C[j].value = C[j-1].value;
	C[j-1].value = temp;
	temp = C[j].suit;
	C[j].suit = C[j-1].suit;
	C[j-1].suit = temp;
      }
    }
  }
}

void selection(struct Card *C, int n) {
  int i, j, min;
  char temp;

  for(i = 0; i < n; i++) {
    min = i;
    for(j = i; j < n; j++) {
      if(C[j].value < C[min].value) {
	min = j;
      }
    }
    if(min != i) {
	temp = C[i].value;
	C[i].value = C[min].value;
	C[min].value = temp;
	temp = C[i].suit;
	C[i].suit = C[min].suit;
	C[min].suit = temp;
    }
  }
}

int main() {
  struct Card *C1, *C2;
  int n, i;
  char ch;
  int stab = 1;

  scanf("%d%c", &n, &ch);
  C1 = malloc(n*sizeof(struct Card));
  C2 = malloc(n*sizeof(struct Card));
  for(i = 0; i < n; i++) {
    scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
  }
  for(i = 0; i < n; i++) {
    C2[i].suit = C1[i].suit;
    C2[i].value = C1[i].value;
  }

  bubble(C1, n);
  selection(C2, n);

  for(i = 0; i < n; i++) {
    printf("%c%c", C1[i].suit, C1[i].value);
    if(i != n-1) {
      printf(" ");
    }
  }
  printf("\n");

  printf("Stable\n");

  for(i = 0; i < n; i++) {
    printf("%c%c", C2[i].suit, C2[i].value);
    if(i != n-1) {
      printf(" ");
    }
  }
  printf("\n");

  for(i = 0; i < n; i++) {
    if(C1[i].suit != C2[i].suit) {
      stab = 0;
    }
  }
  if(stab > 0) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}

Measured memory_bytes: 612
<?php
While ($line = fgets(STDIN) ) {
    $stdin[] = trim($line);
}
$v = explode(" ", $stdin[0]);
fscanf(STDIN,"%d %d", $n, $d);
$ans=0;
for($i=0; $i<$v[0]; $i++){
  $a = explode(" ", $stdin[$i+1]);
  for($j=$i+1; $j<$v[0]; $j++){
    $b = explode(" ", $stdin[$j+1]);
    $r=0;
    for($k=0; $k<$v[1]; $k++){
      $r+=pow(($a[$k]-$b[$k]),2);
    }
    if(preg_match('/^[0-9]+$/', sqrt($r))){
      $ans++;
    }
  }
}
echo $ans;

Measured memory_bytes: 3700
N = int(input())
A_list = []
B_list = []
for i in range(N):
    A, B = map(int, input().split())
    A_list.append(A)
    B_list.append(B)
sort_A = sorted(A_list)
sort_B = sorted(B_list)

if N % 2 == 0:
    center_A = (sort_A[N//2] + sort_A[N//2-1])/2
    center_B = (sort_B[N//2] + sort_B[N//2-1])/2
    print(int((center_B-center_A)*2)+1)
else:
    center_A = sort_A[N//2]
    center_B = sort_B[N//2]
    print(center_B-center_A+1)

Measured memory_bytes: 102184
K = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[K - 1])

Measured memory_bytes: 9176
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  if (s.at(0) != 'A')
  {
    cout << "WA" << endl;
    return 0;
  }
  int cnt = 0;
  for (int i = 2; i <= n - 2; i++)
  {
    if (s.at(i) == 'C')
      cnt++;
  }
  if (cnt != 1)
  {
    cout << "WA" << endl;
    return 0;
  }
  for (int i = 1; i < n; i++)
  {
    if (s.at(i) != 'C' && s.at(i) <= 'Z')
    {
      cout << "WA" << endl;
      return 0;
    }
  }
  cout << "AC" << endl;
  return 0;
}


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

int main(){
    int N,K;
    vector<int > gain(3,0);
    string T;
    long long ans=0;

    cin >> N >> K;
    vector<int> kutai(N,0);
    vector<bool> win(N,false);
    for(int i=0;i<3;i++) cin >> gain[(i+1)%3];
    cin >> T;

    for(int i=0;i<N;i++){
        if(T[i]=='r') kutai[i]=0;
        if(T[i]=='s') kutai[i]=1;
        if(T[i]=='p') kutai[i]=2;
    }

    for (int i=0;i<N;i++){
        if(i>=K && T[i-K]==T[i] && win[i-K]){//K回前の相手の手が、今と同じで、その時に買っていると、その手が出せないのでskip
            continue;
        }
        else{
            win[i]=true;
            ans+=gain[kutai[i]];
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
  int main(){
    int s,m,m_other,h,h_other,input;

    scanf("%d",&input);

    h = input / 3600;
    h_other = input % 3600;
    m = h_other / 60;
    m_other = h_other % 60;
    s = m_other;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
  }



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
#define chkmin(a,b) (a) = min((a), (b))
#define chkmax(a,b) (a) = max((a), (b))
using namespace std;
int inf = 1e9, mod = 1e9;
vi ps;
inline int sum(int l, int r)
{
    return ps[r + 1] - ps[l];
}

inline int diff(int l, int mid, int r)
{
    return abs(sum(mid, r) - sum(l, mid - 1));
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n; cin >> n;
    ps.resize(n + 1);
    ps[0] = 0;
    vi arr(n);
    for (int i=0;i<n;i++) cin >> arr[i], ps[i + 1] = ps[i] + arr[i];
    vi l(n, -1),r(n, -1);
    l[1] = 1;
    r[n - 2] = n - 1;
    for(int i = 2,ind = 1, s; i < n;i++)
    {
        s = diff(0, ind, i);
        while(ind <= i && s > diff(0, ind + 1, i)) s = diff(0, ++ind, i);
        l[i] = ind;
    }

    for(int i = n - 3,ind = n - 1, s; i >= 0;i--)
    {
        s = diff(i, ind, n - 1);
        while(ind > i && s > diff(i, ind - 1, n - 1)) s = diff(i, --ind, n - 1);
        r[i] = ind;
    }
    int mini = 2e18;
    for(int i = 2; i < n - 1;i++)
    {
        vi vals(4);
        vals[0] = sum(0, l[i - 1] - 1);
        vals[1] = sum(l[i - 1], i - 1);
        vals[2] = sum(i, r[i] - 1);
        vals[3] = sum(r[i], n - 1);
        mini = min(mini, *max_element(all(vals)) - *min_element(all(vals)));
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 9552
#include <bits/stdc++.h>
#include<iostream>
#include <math.h>//pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init,i,n) for (int i=init; i <(n);i++)
#define ll long long
#define rev(s) reverse(s.begin(),s.end())
#define sor(v) sort(v.begin(),v.end())
#define PI 3.14159265358979323846264338327950L
//コード自動整形 Shift + Option + F @vscode
using namespace std;

ll facctorialMethod(ll k);//階乗を出力する
/////main/////
int main() {
string S;
cin>>S;
ll Ssize = S.size();
if(S.at(Ssize-1)=='s'){
    cout<<S+"es"<<endl;
}else{
    cout<<S+"s"<<endl;
}

}
/////main/////

/////function/////
ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(){
  int a, b;

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

  if(a > b) printf("a > b\n");
  if(a < b) printf("a < b\n");
  if(a == b) printf("a == b\n");

  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int N,M;
int A[222222];

const int INF=1001001001;
//p<=X[i]       Z[i]<=q<=y[i]
int X[222222],Y[222222],Z[222222];
int accX[222222],accY[222222],accZ[222222];
bool check(int x){

    rep(i,2*N){
        int k=lower_bound(A,A+2*N,x+1-A[i])-A-1;
        X[i]=(i+k+1)/2;
    }


    rep(i,2*N){
        int k=lower_bound(A,A+2*N,M+x+1-A[i])-A-1;
        Y[i]=(i+k+1)/2;

        k=lower_bound(A,A+2*N,M-A[i])-A;
        Z[i]=(i+k+1 +1)/2;
    }


    accX[0]=INF;
    rep(i,2*N)accX[i+1]=min(accX[i],X[i]);
    accY[2*N]=INF;
    accZ[2*N]=-INF;
    for(int i=2*N-1;i>=0;i--){
        accY[i]=min(accY[i+1],Y[i]);
        accZ[i]=max(accZ[i+1],Z[i]);
    }

    for(int i=0;i<=2*N;i+=2){
        int p=i/2;
        int q=(2*N+i)/2;
        if(p>accX[i])continue;
        if(q>accY[i])continue;
        if(q<accZ[i])continue;
        return true;
    }
    return false;
}

signed main(){
    cin>>N>>M;
    rep(i,2*N)cin>>A[i];
    sort(A,A+2*N);



    int lb=-1,ub=M-1;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(check(mid))ub=mid;
        else lb=mid;
    }

    cout<<ub<<endl;
    return 0;
}

Measured memory_bytes: 11904
using System;

namespace AtCoder20190622
{
	class ProgramA
	{
		static void Main(string[] args)
		{
			var S = Console.ReadLine().Trim();
			A(S);
		}
		static void A(string S)
		{
			for(int i = 1; i < S.Length; i++)
			{
				if(S[i] == S[i - 1]) { Console.WriteLine("Bad"); return; }
			}
			Console.WriteLine("Good");
		}
	}
}


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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define si(d)  scanf("%d",&d)
#define sll(d) scanf("%lld",&d)
#define pin(d) printf("%d\n",d)
#define pln(d) printf("%lld\n",d)
#define nl 	   printf("\n")

#define ll long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi vector<int>
#define pii pair<int,int> 
#define piii pair<pair<int,int>,int> 
#define all(v) v.begin(), v.end()

#define chalne_de continue
int mod=1000000007;
const int N = 1000005;

ll gcd(ll a , ll b)
{
    if ( b == 0)
    return a;
    return gcd( b, a % b);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int a[n+1];
	map<int,bool> m;
	int cnt =0;
	rep(i,0,n)
	{
		cin >> a[i];
		if ( a[i] >= 1 and a[i] <= 399)
			m[1] = true;
		else if ( a[i] > 399 and a[i] <= 799 )
			m[2] = true;
		else if ( a[i] > 799 and a[i] <= 1199)
			m[3] = true;
		else if ( a[i] > 1199 and a[i] <= 1599)
			m[4] = true;
		else if ( a[i] > 1599 and a[i] <= 1999)
			m[5] = true;
		else if ( a[i] > 1999 and a[i] <= 2399)
			m[6] = true;
		else if ( a[i] > 2399 and a[i] <= 2799)
			m[7] = true;
		else if ( a[i] > 2799 and a[i] <= 3199)
			m[8] = true;
		else
			cnt ++;
	}
	int mn = m.size();
	int mx = mn;
	mx = mx + cnt;
	cout << (mn == 0 ? 1 : mn) << " " << mx ;
	return 0;
}


Measured memory_bytes: 256
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

template<class Ab>
struct fenwick_tree {
private:
 
    int size;
    std::vector<Ab> node;
 
public:
 
    fenwick_tree() { }
    fenwick_tree(const int& size_) { init(size_); }
 
    void init(const int& size_) {
        size = size_;
        node.resize(size);
    }
 
    void modify(int idx, const Ab& value) {
        while (idx < size) {
            node[idx] += value;
            idx |= (idx + 1);
        }
    }
 
    Ab get(int idx) const {
        Ab result{};
        while (idx >= 0) {
            result += node[idx];
            idx = (idx & (idx + 1)) - 1;
        }
        return result;
    }

};

int main() {

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i] -= K;

    vector<long long> sum(N + 1);
    rep(i, N) {
        sum[i + 1] += A[i];
        sum[i + 1] += sum[i];
    }

    map<long long, int> mp;
    rep(i, N + 1) mp[sum[i]] = 0;

    int cnt = 0;
    for(auto& x : mp) x.second = cnt++;

    fenwick_tree<long long> fen(mp.size());
    long long ans = 0;
    rep(i, N + 1) {
        ans += fen.get(mp[sum[i]]);
        fen.modify(mp[sum[i]], 1);
    }
    cout << ans << '\n';
    return 0;

}




Measured memory_bytes: 11028
N,M = map(int,input().split())
P = list(map(int,input().split()))
XY = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

uf = UnionFind(N)
for x,y in XY:
    x,y = x-1,y-1
    if uf.is_same(x,y): continue
    uf.unite(x,y)
for i in range(N):
    uf.root(i)

from collections import defaultdict
ps = defaultdict(lambda: set())
ids = defaultdict(lambda: set())
rs = set()
for i,p in enumerate(P):
    r = uf.root(i)
    ps[r].add(p-1)
    ids[r].add(i)
    rs.add(r)

ans = 0
for r in rs:
    ans += len(ps[r] & ids[r])
print(ans)

Measured memory_bytes: 92600
#include <stdio.h>

int main()
{
	long a, b, c, d;
	long ac, ad, bc, bd;
	long max;

	scanf("%ld%ld%ld%ld", &a, &b, &c, &d);//提出時は scanf_s→scanf
	
	ac = a * c;
	ad = a * d;
	bc = b * c;
	bd = b * d;
	max = ac;

	if (max < ad) {
		max = ad;
	}
	if (max < bc) {
		max = bc;
	}
	if (max < bd) {
		max = bd;
	}

	printf("%ld",max);

	return 0;
}

Measured memory_bytes: 1708
N,K=map(int,input().split())
A=list(map(int,input().split()))
done=[-1 for _ in range(N)]
done[0]=0
n=0
now=0
init=0
loop=N
log=[0]

while n<N:
    log.append(A[log[-1]]-1)
    n+=1
    if done[log[-1]]>-1:
        init=done[log[-1]]
        loop=n-done[log[-1]]
        break
    done[log[-1]]=n

if K<init:
    print(log[K]+1)
else:
    num=init+(K-init)%loop
    print(log[num]+1)

Measured memory_bytes: 32436
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int N,M,X;



int main(int argc, char const *argv[])
{
    cin>>N>>M>>X;
    vector<int> A(M);
for(int i=0;i<A.size();i++){
    cin>>A[i];
}
int cost_zero=0;
int cost_N=0;
for(int place=X;place>0;--place){
    auto itr = std::find(A.begin(), A.end(), place);    //  最初の要素5へのイテレータを返す
    if( itr != A.end() ) {     // 発見した場合
        cost_zero++;
    }
}
    for(int place=X;place<N;++place){
    auto itr = std::find(A.begin(), A.end(), place);    //  最初の要素5へのイテレータを返す
    if( itr != A.end() ) {     // 発見した場合
        cost_N++;
    }

}

cout<<min(cost_zero,cost_N)<<endl;
return 0;
}


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

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

  int cnt1 = 0;
  int cnt2 = 0;
  int a;
  for(int i = 0; i < m; i++){
    cin >> a;
    if(a < x) cnt1++;
    if(a > x) cnt2++;
  }

  cout << min(cnt1, cnt2) << endl;

  return 0;

}


Measured memory_bytes: 256
//Coprime 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

unordered_set<int>a;

bool f(int n){
    for(int i=2;i*i<=n;i++){
        bool flag = false;
        while(n%i==0){
            flag = true;
            n/=i;
        }
        bool t = true;
        if(flag)t=a.insert(i).second;
        if(!t)return false;
    }
    if(n!=1)if(!a.insert(n).second)return false;
    return true;
}

signed main (){
    nvarep(n,a);
    int g=a[0];
    bool flag = true;
    rep(i,0,n){
        g=__gcd(a[i],g);
        if(flag)flag = f(a[i]);
    }
    if(flag)cout<<"pairwise coprime"<<nnn;
    else if(g==1)cout<<"setwise coprime"<<nnn;
    else cout<<"not coprime"<<nnn;
    return 0;
}

Measured memory_bytes: 11152
N,Y = map(int,input().split())
count=0
for x in range(N+1):
    for y in range(N+1):
        if x+y >N:
            break
        else:
            money = 10000*x + 5000*y + 1000*(N-x-y)
            if money == Y:
                count=1
                print('{} {} {}'.format(x,y,N-x-y))
                break
    if count == 1:
        break
if count == 0:
    print('-1 -1 -1')

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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

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

    switch (d) {
        case 22:
            cout << "Christmas Eve Eve Eve";
            break;
        case 23:
            cout << "Christmas Eve Eve";
            break;
        case 24:
            cout << "Christmas Eve";
            break;
        case 25:
            cout << "Christmas";
            break;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll m=n;
	for(ll i=2;i*i<=m;i++){
		bool ok=false;
		while(m%i==0){
			ok=true;
			m/=i;
		}
		if(ok){
			n*=(i-1);
			n/=i;
		}
	}
	if(m!=1){
		n*=(m-1);
		n/=m;
	}
	cout<<n<<endl;
}




Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; ++i)
	{
		cin >> i;
		if(i%k == 0)
		{
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
}

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

int main()
{
    long N;
    cin >> N;
    vector<int> a(N);
    rep(i, N)
    {
        cin >> a[i];
    }
    bool is_ok = true;
    vector<int> b(N, 0);

    for (int i = N; i >= 1; i--)
    {
        int ball_count = 0;
        for (int j = i; j < N + 1; j += i)
        {
            ball_count += b[j - 1];
        }

        if (ball_count % 2 != a[i - 1])
            b[i - 1]++;
    }

    if (is_ok)
    {
        vector<int> ans;
        rep(i, N)
        {
            if (b[i] == 1)
                ans.push_back(i + 1);
        }

        int M = ans.size();
        cout << M << endl;
        if(M != 0)
        {
            rep(i, M)
            {
                cout << ans[i] << " ";
            }
            cout << endl;
        }
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx=1000;
const int px=2000;
const ll INF=1LL << 50;
int main()
{
   int n,m;
   cin>>n>>m;
   int a[px],b[px];
   ll c[px];
   for(int i=0;i<m;i++)
   {
       cin>>a[i]>>b[i]>>c[i];
       c[i]=-c[i];
   }
   ll d[mx];
   for(int i=0;i<n;i++)
   {
       d[i]=INF;
   }
   d[0]=0;
   for(int l=0;l<n-1;l++)
   {
       for(int i=0;i<m;i++)
       {
           if(d[a[i]-1]==INF) continue;
           if(d[b[i]-1]>d[a[i]-1]+c[i])
           {
               d[b[i]-1]=d[a[i]-1]+c[i];
           }
       }
   }
   ll ans=d[n-1];
   bool ma[mx];
   for(int i=0;i<n;i++)
   {
       ma[i]=false;
   }
   for(int l=0;l<n;l++)
   {
       for(int i=0;i<m;i++)
       {
           if(d[a[i]-1]==INF) continue;
           if(d[b[i]-1]>d[a[i]-1]+c[i])
           {
               d[b[i]-1]=d[a[i]-1]+c[i];
               ma[b[i]-1]=true;
           }
           if(ma[a[i]-1]==true)
           {
               ma[b[i]-1]=true;
           }
       }
   }
   if(ma[n-1])
    cout<<"inf"<<endl;
   else
    cout<<-ans<<endl;
}


Measured memory_bytes: 3644
K=int(input())
import math
X=[]
for a in range(1,K+1):
    _=[math.gcd(a,b) for b in range(1,K+1)]
    X.append(_)
ans=0
for c in range(1,K+1):
    #print(c,ans)
    for a in range(1,K+1):
        for _ in X[a-1]:
            ans+=math.gcd(_,c)
    #ans-=math.gcd(X[c-1][0],c)*2
print(ans)

Measured memory_bytes: 9476
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
//-------------------------------
//min_cost_flow1
struct edge { int to, cap, cost, rev; };
int V;
const int MAX_V = 5000;

vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, int cost){
  G[from].push_back((edge){to, cap, cost, G[to].size()});
  G[to].push_back((edge){from, 0, -cost, G[from].size()-1});
}
void clear(){
  REP(i, MAX_V){
    G[i].clear();
  }
}
int min_cost_flow(int s, int t, int f){
  int res = 0;
  while(f > 0){
    fill(dist, dist + V, INF);
    dist[s] = 0;
    bool update = true;
    while(update){
      update = false;
      //debug(dist, dist + 6);
      for(int v = 0; v < V; v++){
        if(dist[v] == INF) continue;
        for(int i = 0; i < G[v].size(); i++){
          edge &e = G[v][i];
          if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
            dist[e.to] = dist[v] + e.cost;
            prevv[e.to] = v;
            preve[e.to] = i;
            update = true;
          }
        }
      }
    }
    if(dist[t] == INF) return -1;

    int d = f;
    for(int v = t; v != s; v = prevv[v]){
      //cout<<v<<endl;
      d = min(d, G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d * dist[t];
    //cout<<res<<endl;
    for(int v = t; v != s; v = prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}
//--------------------

int main(){
  int N;
  while(cin>>N && N){
    clear();
    map<int, int> ids;
    int a[1000];
    int b[1000];
    int M = 0;
    REP(i, N){
      cin>>a[i]>>b[i];
      if(!ids.count(a[i]))ids[a[i]] = M++;
      if(!ids.count(b[i]))ids[b[i]] = M++;
    }
    const int S = N + M;
    const int G = S + 1;
    const int L = G + 1;
    V = L + 1;
    REP(i, N) add_edge(S, i, 1, 0);
    REP(i, M) add_edge(N + i, G, 1, 0);
    REP(i, N){
      add_edge(i, N + ids[a[i]], 1, 1000000-b[i]);
      add_edge(i, N + ids[b[i]], 1, 1000000-a[i]);
      add_edge(i, L, 1, 1000000);
    }
    add_edge(L, G, 1000000, 0);
    cout<<N * 1000000 - min_cost_flow(S, G, N)<<endl;
  }
  return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  bool ret = false;
  for(int i = 0; i <= x; i++) {
    int t = x - i;
    int total = 2*i + 4*t;
    if(total == y) ret = true;
  }
  if(ret) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

long long func(long long b, long long n){
  long long s = 0;
  while(n){
    s += n % b;
    n /= b;
  }
  return s;
}


int main(){
  long long n,s;
  cin >> n >> s;
  // for(int i = 2; i < 100; i++){
    // cout << "i: " << i << " f: " << func(i,n) << endl;
  // }
  if(n == s){
    cout << n+1 << endl;
    return 0;
  }

  for(long long i = 2; i < (long long)sqrt(n); i++){
    if(func(i, n) == s){
      cout << i << endl;
      return 0;
    }
  }
  long long b;
  for(long long p = (long long)sqrt(n); p > 0; p--){
    b = (n-s) / p + 1;
    if (b < 2) continue;
    if(func(b, n) == s){
      cout << b << endl;
      return 0;
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int n;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n)cin >> a[i];
    ll res = 0;
    rep(i,n-1){
        if(a[i] == 0)continue;
        if(a[i] == a[i+1]){
            a[i+1] = 0;
            res++;
            continue;
        }
    }
    cout << res << endl;
    return 0;
}

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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  ll res1, res2;
  if (n%a == 0) {
    res1 = (n/a)*b;
  } else {
    res1 = (n/a)*b + b;
  }
  if (n%c == 0) {
    res2 = (n/c)*d;
  } else {
    res2 = (n/c)*d + d;
  }
  cout << min(res1, res2) << endl;
}


Measured memory_bytes: 3104
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n, ma = 0, x = -1, two = 0;
	cin >> n;
	int a[200005];
	rep(i, n) {
		cin >> a[i];
		if (a[i] > ma) {
			x = i;
			ma = a[i];
		}
	}
	rep(i, n) {
		if (i != x) {
			two = max(two, a[i]);
		}
	}
	rep(i, n) {
		if (i == x) {
			cout << two << endl;
		}
		else {
			cout << ma << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
int main() {
    int A, B, C, X;
    int a, b, c;
    scanf("%d%d%d%d", &A, &B, &C, &X);
    if (X%50 != 0) return !printf("0\n");
    int res = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (i*500+j*100+k*50 == X) res++;
            }
        }
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 256
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var n, m int
	fmt.Sscan(getNextLine(scanner), &n, &m)

	pp := getIntList(scanner)
	uf := make([]int, n+1)
	for i := 1; i <= n; i++ {
		uf[i] = i
	}

	for i := 0; i < m; i++ {
		xy := getIntList(scanner)
		xr := root(xy[0], uf)
		yr := root(xy[1], uf)
		if xr <= yr {
			uf[yr] = xr
			continue
		}
		uf[xr] = yr
	}
	ans := 0
	for i := 1; i <= n; i++ {
		if root(i, uf) == root(pp[i-1], uf) {
			ans++
		}
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func root(i int, uf []int) int {
	if i == uf[i] {
		return i
	}
	r := root(uf[i], uf)
	uf[i] = r
	return r
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int v, e, r; cin >> v >> e >> r;
    vector<pii> g[100010];
    rep(i,e){
        int s, t, d;
        cin >> s >> t >> d;
        g[s].push_back(pii(t,d));
    }

    vi dist(v,INF);
    auto dijk = [&](int s){
        priority_queue<int> pq;
        pq.push(s);
        dist[s] = 0;
        while(!pq.empty()){
            int v = pq.top(); pq.pop();
            rep(i,g[v].size()){
                int u = g[v][i].fi;
                int d = g[v][i].se;
                if(dist[u] > dist[v] + d){
                    dist[u] = dist[v] + d;
                    pq.push(u);
                }
            }
        }
    };
    dijk(r);
    rep(i,v){
        if(dist[i] == INF) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 16160
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    ab = [LI() for _ in range(N)]
    cd = [LI() for _ in range(N)]
    ab.sort()
    ab_used = collections.OrderedDict()
    for i in ab:
        ab_used[tuple(i)] = False
    cd.sort()

    # x座標でソート 青点基準で考える
    # 青点は、自分よりx座標が小さい赤点の中でy座標が最大のものをとればよい
    ans = 0
    for c, d in cd:
        m = -1
        m_ab = (-1, -1)
        for a, b in ab:
            if a > c:
                break
            if not ab_used[(a, b)] and d > b > m:
                m = b
                m_ab = (a, b)
        if m_ab != (-1, -1):
            ab_used[m_ab] = True
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;

/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll a,b,c;
	cin>>a>>b>>c;
	ll k =0;
	for(i=a;i<=b;i++)
	{
		if(i%c==0)
			k++;
	}
	cout<<k<<endl;

	


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a[110];  cin >> n;
    REP(i,n){
        cin >> a[i];
    }

    int tot=1E9;

    FOR(i,-100,101){
        int tt=0;
        REP(j,n){
            tt+=(a[j]-i)*(a[j]-i);
        }
        if(tt<tot){

            tot=tt;
        }
        //OUT(tt)
    }
    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9+10)
#define ll_MIN (ll)(-1e9*1e9-10)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
//using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX
 


void solve()
{
  int n,m,k;
  cin >> n >> m >> k;
  multiset<int> q;
  map<int, vi> r;
  map<int, set<int>> c;

  rep(i,0,k-1)
  {
    int l,r1;
    cin >> l >> r1;
    r[l].pb(r1);
    c[r1].insert(l);
  }


  for(int i=1; i<=m; i++)
  {
    q.insert(c[i].size());
  }

  int ans = 0;




  for(auto it: r)
  {
    vi& xx = it.sc;
    for(auto it: xx)
    {
      int x = c[it].size();
      q.erase(q.find(x));
      q.insert(x-1);
    }



    ans = max((int)xx.size() +  *q.rbegin(), ans);

    for(auto it: xx)
    {
      int x = c[it].size();
      q.erase(q.find(x-1));
      q.insert(x);
    }
  }

  cout << ans << endl;

}


 
signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 92688
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,y; cin>>n>>y;
    int a=0, b=0, c=0;
    bool ok=false;
    rep(i,n+1){
        if(i*10000>y) break;
        int now=y-i*10000;

        int cntb=now-1000*(n-i), cntc=5000*(n-i)-now;
        if(cntb%4000==0 && cntc%4000==0 && cntb>=0 && cntc>=0){
            ok=true;
            a=i;
            b=cntb/4000;
            c=cntc/4000;
        }
        if(ok) break;
    }
    if(ok){
        cout<<a<<" "<<b<<" "<<c<<endl;
    }else{
        rep(i,3){
            cout<<-1<<" ";
        }
    }
}

Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;


#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}



int main() {
	IOS;
	ll n, m;
	cin >> n >> m;
	vector<ll> p(n + 1);
	FOR(i, 1, n + 1)cin >> p[i];
	UnionFind u(n + 1);
	REP(i, m) {
		int x, y;
		cin >> x >> y;
		u.unionSet(x, y);
	}
	ll ans = 0;
	FOR(i, 1, n + 1) {
		if (i == p[i] || u.findSet(i, p[i])) {
			ans++;
		}
	}
	dump(ans);
}




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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 1000000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    map<int, int> m;
    rep(i, 0, n)
    {
        int x;
        cin >> x;
        m[x]++;
    }
    if (n == 2)
    {
        if (sz(m) == 1 && m.begin()->fi == 1)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    else if (sz(m) > 2)
    {
        cout << "No\n";
    }
    else if (sz(m) == 1)
    {
        int v = m.begin()->fi;
        if (v == n - 1 || v * 2 <= n)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    else if ((++m.begin())->fi != m.begin()->fi + 1)
    {
        cout << "No\n";
    }
    else
    {
        n -= m.begin()->se;
        int v = (++m.begin())->fi - m.begin()->se;
        if (v < 0 || !(v == n - 1 || v * 2 <= n))
        {
            cout << "No\n";
            return 0;
        }
        vector<int> aaa;
        if (v == n - 1)
            aaa.push_back(n);
        if (v != 0 && v * 2 <= n)
            aaa.push_back(v);
        for (int x : aaa)
            if (x + m.begin()->se - 1 == m.begin()->fi)
            {
                cout << "Yes\n";
                return 0;
            }
        cout << "No\n";
    }
    return 0;
}

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

int main()
{
    int N, M; cin>>N>>M;
    int res=1;
    for(int i=1; i*i<=M; ++i) if (M%i==0) {
        int x=M/i;
        if (x>=N && res<i) res=i;
        if (i>=N && res<x) res=x;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import math

p = [2]
    
def isprime(x):
    if x == 2:
        return True
    if x == 3:
        return True
    if max(p) < x**0.5:
        for j in range(max(p), math.floor(x**0.5) + 1):
            if all([j % k != 0 for k in p]):
                p.append(j)
    i = 0
    while i <= len(p)-1:
        if x%p[i] == 0:
            return False
        if p[i] > x**0.5:
            break;
        i += 1
    return True


n = int(input())
res = 0
for i in range(n):
    k = int(input())
    if isprime(k):
        res += 1
print(res)

Measured memory_bytes: 7852