akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b;
    cin >> a >> b;
    if (a >= 13) cout << b << endl;
    else if (a >= 6) cout << (b/2) << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3624
import math

a,b,h,m = map(int,input().split())

d = 60 * h + m #d分後

sh_d = 360/720*d #d分後の短針の角度。短針の速度は360度/720分。
lh_d = 360/60*d #d分後の長針の角度。長針の速度は360度/60分。

#短針の座標
sh_x = a*math.cos(math.radians(sh_d))
sh_y = a*math.sin(math.radians(sh_d))

#長針の座標
lh_x = b*math.cos(math.radians(lh_d))
lh_y = b*math.sin(math.radians(lh_d))

l = math.sqrt((sh_x-lh_x)**2+(sh_y-lh_y)**2)

print(l)

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

int main() {
	int n;
	std::cin >> n;
	std::vector<int> p = std::vector<int>(n);
	for (int i = 0; i < n; i++) { std::cin >> p[i]; }

	int count = 0;
	for (int i = 0; i < n - 2; i++)
	{
		if ((p[i] <= p[i + 1] && p[i + 1] <= p[i + 2]) ||
			(p[i] >= p[i + 1] && p[i + 1] >= p[i + 2])) {
			count++;
		}
	}

	std::cout << count << '\n';
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
x2 = Base_10_to_n(N, K)
print(len(x2))

Measured memory_bytes: 2940
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def _Ss(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Ss(): return _Ss(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_ = I()
xs = Is()
 
sss = 0
count = D(int)
for x in xs:
  sss += x
  count[x] += 1
  
q = I()
for _ in range(q):
  b, c = I()
  sss += (c - b) * count[b]
  print(sss)
  count[c] += count[b]
  count[b] = 0

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

int N;
int A;
int B;

void input() {
    cin >> N;
    cin >> A;
    cin >> B;
}

int sum(string str){
    int n = 0;
    for (char ch : str) {
        n += atoi(string(1,ch).c_str());
    }
    return n;
}

int main() {
    input();
    int num = 0;
    for(int i = A; i <= N; i++){
        if(sum(to_string(i)) <= B && sum(to_string(i)) >= A){
            // cout << i << endl;
            num += i;
        }
    }
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;




int main(void) {
  ll N, M;
  cin >> N >> M;
  ll i, j;
  ll x[MAX];
  vector<ll> v[MAX];
  for(i=0; i<N; i++) {
    cin >> x[i];
    v[x[i]%M].push_back(x[i]);
  }
  
  for(i=0; i<M; i++) {
    v[i].push_back(INF);
    sort(v[i].begin(), v[i].end());
  }
  
  vector<ll> cnt[MAX];
  for(i=0; i<M; i++) {
    for(j=0; j<v[i].size(); j++) {
      ll t=1;
      while(v[i][j]==v[i][j+1]) {
        t++;
        j++;
      }
      cnt[i].push_back(t);
    }
    sort(cnt[i].begin(), cnt[i].end());
  }
  
  for(i=0; i<M; i++) cnt[i].erase(cnt[i].begin());
  
  ll s[MAX]={};
  ll odd[MAX]={};
  for(i=0; i<M; i++) {
    ll t=0;
    for(j=0; j<cnt[i].size(); j++) {
      t+=cnt[i][j];
      if(cnt[i][j]&1) odd[i]++;
    }
    s[i]=t;
  }
  
  ll ans=s[0]/2;
  if(M%2==0) ans+=s[M/2]/2;
  
  for(i=1; i<=M/2-(M&1 ? 0:1); i++) {
    ll a=i;
    ll b=M-i;
    
    if(s[a]>s[b]) swap(a, b);
    
    if(s[a]>=odd[b]) {
      ans+=s[a]+(s[b]-s[a])/2;
    }else {
      ans+=s[a]+(s[b]-odd[b])/2;
    }
    
  }
  
  pt(ans);
}








Measured memory_bytes: 14720
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <sstream>
#include <bitset>
using namespace std;
#define MP(a, b) make_pair(a, b)
#define VT vector
#define FI first
#define SE second
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 1; i <= n; ++i)
typedef long long ll;
typedef unsigned long long ull;

const char *P;
const ll mod = 1000000007;
ll expr();
ll term();

ll term() {
    ll x = 0;
    if (P[0] == 'S') {
        P += 2;
        x = expr();
        x = x * x % mod;
        P++;
    }
    else {
        char *endp;
        x = strtoll(P, &endp, 10);
        P = endp;
    }
    return x;
}

ll expr() {
    ll x = term();
    ll b;
    while (P[0] == '>' && P[1] == '>' && (P[2] == 'S' || isdigit(P[2]))) {
        P += 2;
        x >>= min(term(), 63LL);
    }
    return x;
}

int main() {
    string s;
    while (1) {
        getline(cin, s);
        if (s[0] == '#') break;
        s.erase(remove(s.begin(), s.end(), ' '), s.end());
        P = s.c_str();
        // cout << s << endl;
        cout << expr() << endl;
    }
    return 0;
}

Measured memory_bytes: 3400
N = int(input())
X = input()
X_i = int(X, 2)
X_b = bin(X_i)
sum_X = X_b.count("1")
Xp = X_i % (sum_X + 1)
Xm = X_i % (sum_X - 1) if sum_X - 1 > 0 else -1


def f(n, p):
    count = 1
    n %= p
    while n != 0:
        p = bin(n).count("1")
        n %= p
        count += 1
    return count


for i in range(1, N + 1):
    if X[i - 1] == "1":
        if sum_X - 1 <= 0:
            print(0)
            continue
        nm = pow(2, N - i, sum_X - 1)
        print(f(Xm - nm, sum_X - 1))
    else:
        np = pow(2, N - i, sum_X + 1)
        print(f(Xp + np, sum_X + 1))

Measured memory_bytes: 9608
import math

def check_dist(pt0, pt1):

	d = 0.0
	for k in range(len(pt0)):
		d += (pt0[k] - pt1[k]) ** 2
	d = math.sqrt(d)

	return d.is_integer()

N, D = map(lambda x: int(x), input().split(" "))

pts = []

for i in range(N):
	pt = list(map(lambda x: int(x), input().split(" ")))
	pts.append(pt)

count = 0

for i in range(0, N-1):
	for j in range(i+1, N):
		if check_dist(pts[i], pts[j]):
			count += 1

print(count)



Measured memory_bytes: 3064
//Name: Stopping Problem
//Level: 2
//Category: シミュレーション,幅優先探索,BFS
//Note:

/**
 * 状態は「どのマスにいるか」、「どの方向に進んでいるか」、「メモリの値がいくつか」の3つ。
 * 同じ状態からは同じ遷移しか発生しないので、一度通った状態は2回目以降は無視して良い。
 *
 * オーダーは O(RCDM)。
 * ただしDは進行方向の種類数、Mはメモリのとり得る値の種類数で、D=4, M=16。
 */
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_set>
#include <queue>
#include <tuple>

using namespace std;

const int DR[] = {0, -1, 0, 1};
const int DC[] = {1, 0, -1, 0};

int hashf(int r, int c, int d, int m) {
    return ((((r) * 20 + c) * 20 + d) * 20 + m);
}

bool solve() {
    int R, C;
    if(!(cin >> R >> C)) return false;

    vector<string> prog(R);
    for(int r = 0; r < R; ++r) {
        cin >> prog[r];
    }

    unordered_set<int> memo;
    queue<tuple<int,int,int,int>> q;
    q.push(make_tuple(0, 0, 0, 0));
    memo.insert(0);
    bool ans = false;
    while(!q.empty()) {
        int r, c, d, m;
        tie(r, c, d, m) = q.front();
        q.pop();

        switch(prog[r][c]) {
        case '<':
            d = 2;
            break;
        case '>':
            d = 0;
            break;
        case '^':
            d = 1;
            break;
        case 'v':
            d = 3;
            break;
        case '_':
            d = (m ? 2 : 0);
            break;
        case '|':
            d = (m ? 1 : 3);
            break;
        case '@':
            ans = true;
            goto end;
        case '+':
            m = (m + 1) % 16;
            break;
        case '-':
            m = (m + 15) % 16;
            break;
        default:
            if(isdigit(prog[r][c])) {
                m = prog[r][c] - '0';
            }
        }
        if(prog[r][c] == '?') {
            for(d = 0; d < 4; ++d) {
                const int nr = (r + DR[d] + R) % R;
                const int nc = (c + DC[d] + C) % C;
                const int h = hashf(nr, nc, d, m);
                if(!memo.count(h)) {
                    memo.insert(h);
                    q.push(make_tuple(nr, nc, d, m));
                }
            }
        } else {
            const int nr = (r + DR[d] + R) % R;
            const int nc = (c + DC[d] + C) % C;
            const int h = hashf(nr, nc, d, m);
            if(!memo.count(h)) {
                memo.insert(h);
                q.push(make_tuple(nr, nc, d, m));
            }
        }
    }
end:
    cout << (ans ? "YES" : "NO") << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

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

int main() {
    int n;cin>>n;
    ll sum=0;
    int a[n];
    for (int i=0;i<n;i++) {
        cin>>a[i];
        sum+=a[i];
    }
    for (int i=1;i<n;i+=2)
        sum-=2*a[i];
    int x=sum;
    cout<<x<<' ';
    for (int i=0;i<n-1;i++) {
        x=2*a[i]-x;
        cout<<x<<' ';
    }
    return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
int gcd(int x, int y){
    int r;
    while(y>0){
        r = x%y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin>>a>>b>>k;
    int n = gcd(a,b);
    vector<int> l(100);
    REP(i,100) l[i] = -inf;
    int j = 0;
	for(int i=1; i<=sqrt(n);i++){
        if(n%i == 0){
			l[j] = i;
            j++;
            if(i!=sqrt(n)){
                l[j] = n/i;
                j++;
            }
		}
	}
   
    sort(all(l), greater<int>()); 
    print(l[k-1]);
    return 0;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	string s;
	cin >> s;
	int n = s.size();
	string ans = "";
	rep(i, n) {
		if (i % 2 == 0)ans += s[i];
	}
	print(ans);
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char s[3252], t[3252];
int n,m;
int dp[3252][3252];

int main(){
  scanf("%s%s",s,t);
  n = strlen(s);
  m = strlen(t);
  REP(i,n+1)REP(j,m+1){
    if(i<n && j<m && s[i]==t[j])CHMAX(dp[i+1][j+1], dp[i][j]+1);
    if(i<n)CHMAX(dp[i+1][j], dp[i][j]);
    if(j<m)CHMAX(dp[i][j+1], dp[i][j]);
  }
  int ci = n, cj = m;
  vector<char> v;
  while(ci>0 && cj>0){
    if(s[ci-1]==t[cj-1] && dp[ci-1][cj-1]+1 == dp[ci][cj]){
      v.push_back(s[ci-1]);
      ci--; cj--;
    }else if(dp[ci-1][cj] == dp[ci][cj]){
      ci--;
    }else{
      cj--;
    }
  }
  FORR(i,0,v.size())putchar(v[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 39168
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;

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

	int ret = 0,current = 0;
	for (int i = 0; i < S.size(); ++i)
	{
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
		{
			++current;
		}
		else
		{
			ret = max(ret, current);
			current = 0;
		}
	}
	ret = max(ret, current);

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

point = 0

for i in li:
    lin = prime_factorize(i)
    point += lin.count(2)

print(point)

Measured memory_bytes: 71256
#include<bits/stdc++.h>
#define ll long long//
#define rp(i,a,b) for(ll i=a;i<b;i++)
#define r(i,n) for(ll i=0;i<n;i++)
#define rt return
#define db double
#define ldb long double
#define vd void
#define p(x) cout<<(x)<<endl;
#define ce continue;
#define bl bool
#define r0 rt 0;
#define r1 rt 1;
#define elif else if
#define bk break;
#define A p("A")
#define B p("B")
#define C p("C")
#define D p("D")
#define E p("E")
#define F p("F")
#define S(a) sort(a.begin(),a.end());
#define R(a) reverse(a.begin(),a.end());
#define cl cout<<endl;
#define pb(x) push_back(x);
#define str string
using namespace std;
void Cond(int g){if(g)p("YES")else p("NO")rt;}
void cond(int g){if(g)p("Yes")else p("No")rt;}
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)rt b;gcd(b,a%b);}
str su="0123456789";
str m1="abcdefghijklmnopqrstuvwxyz";
str m2="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
map<char,ll>m5;
typedef pair<ll,ll> P;
const ll INF=(ll)1e18+10;
ll t1=0,t2=0,t3=0,t4=0,t5=0,t6=0,t7=0,t8=0,g=0,ans=0;
ll n=0,m=0,k=0,mx=-INF,mn=INF,ct=0;
ll tmp=0,tmp1=0,tmp2=0,tmp3=0,tmp4=0;
ll sum=0,mask=0;
set<P> pst;
set<ll>st,st1,st2;
set<char> cst;
ll powmod(ll a,ll b,ll x){//(a^b)modx
    if(!b)r1
    if(!(b%2)){//B
        ll t=powmod(a,b/2,x);
        rt t*t%x;
    }
    rt ((a)*powmod(a,b-1,x))%x;
}
void di(){m5['a']=0;
    m5['b']=1;
    m5['c']=2;
    m5['d']=3;
    m5['e']=4;
    m5['f']=5;
    m5['g']=6;
    m5['h']=7;
    m5['i']=8;
    m5['j']=9;
    m5['k']=10;
    m5['l']=11;
    m5['m']=12;
    m5['n']=13;
    m5['o']=14;
    m5['p']=15;
    m5['q']=16;
    m5['r']=17;
    m5['s']=18;
    m5['t']=19;
    m5['u']=20;
    m5['v']=21;
    m5['w']=22;
    m5['x']=23;
    m5['y']=24;
    m5['z']=25;
}
map<ll,ll>mp,mp1,mp2,mp3;
typedef std::vector<ll> vl;
typedef pair<ll,ll> P;
typedef pair<ll,P>  P2;
typedef struct edge2{P tos;ll cost;}EDGE2;
typedef struct edge1{ll to,cost;}EDGE;
bl used[(ll)1e9];
const ll M=(ll)1e9+7;
ll fac[1000007],finv[1000007],inv[1000007];
void initcmb(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<1000007;i++){
        fac[i]=fac[i-1]*i%M;
        inv[i]=M-inv[M%i]*(M/i)%M;
        finv[i]=finv[i-1]*inv[i]%M;
    }
}
ll cmb(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%M)%M;
}
db pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196;

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; }
const ll MAX=5+(ll)1e5*3;
vl rui(MAX);

   

vector<vector<EDGE>>G(1e6);



int main(){//swap(ary１,ary２)
    //a.erase(a.begin()+5),a.insert(a.begin()+3,tmp)    ios_base::sync_with_stdio(0); cin.tie(0);
clock_t start = clock();//timecalc
di();

ll a[5];
r(i,5){
	cin>>a[i];
	if(a[i]==0){
		t1=i;
	}
}
p(t1+1)




clock_t end = clock();//
const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;//timecalc
//printf("time %lf[ms]\n", time);//
return 0;
}//main


Measured memory_bytes: 28924
#include <stdio.h> 
 
int main() {
 
  int c,a,n,i,j,y,count = 0;
 
  scanf("%d",&y);
 
  for(i=0;i<y;i++) {
 
    scanf("%d %d %d",&c,&a,&n);
    count = 0;
    while(1) {
 
      if(c - 1 >= 0 && n - 1>=0 && a - 1>=0 ) {
    count++;
    c--;
    n--;
    a--;
      } else if(c -2 >= 0 && a-1 >= 0) {
    count++;
    c -= 2;
    a--;
      }else if(c-3 >= 0) {
    count++;
    c -= 3;
      } else break;
 
    }
 
    printf("%d\n",count);
 
  }
  return 0;
 
}

Measured memory_bytes: 600
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int kazu = int.Parse(ReadLine());
        string[] suji = ReadLine().Split(' ');
        int[] suuji = new int[kazu];
        for(int i=0;i<kazu;i++){
            suuji[i] = int.Parse(suji[i]);
        }
        
        for(int i=0;i<30;i++){
            int k =0;
            for(int j=0;j<kazu;j++){
                if(suuji[j]%2==0){
                    suuji[j] /= 2;
                }else{
                    k++;
                    WriteLine(i);
                    break;
                }
            }
            if(k>0){
                break;
            }
        }
    }
}


Measured memory_bytes: 11092
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int ans = 1;
        for (int i = a[1]; i > 1; i--) {
            int cnt = 0;
            boolean ok = false;
            for (int j = 0; j < n; j++) {
                if (a[j] % i != 0) {
                    cnt++;
                }
                if (cnt > 1) {
                    break;
                }
                if (j == n - 1) {
                    ans = i;
                    ok = true;
                }
            }
            if (ok) {
                break;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 50644
def main():
    mod = 10**9+7
    fact = [1, 1]
    for i in range(2, 300):
        fact.append(fact[-1]*i % mod)

    n, x = map(int, input().split())
    s = sorted(list(map(int, input().split())))[::-1]
    next_dict = {x: fact[n-1]}
    for i in range(n):
        memo = dict()
        inv = pow(n-i-1, mod-2, mod)
        ss = s[i]
        for j, a in next_dict.items():
            memo[j % ss] = (memo.get(j % ss, 0)+a) % mod
        for j, a in memo.items():
            next_dict[j] = (next_dict.get(j, 0)+a*inv) % mod
    ans = 0
    for i, j in memo.items():
        ans = (ans+i*j) % mod
    print(ans)


main()

Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL A[123456], kPlus[123456], kTotal[123456];

int main(){
    
    // 1. 入力情報取得.
    int N, K;
    scanf("%d %d", &N, &K);
    LL pTotal = 0;
    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
        if(A[i] > 0) pTotal += A[i];
    }
    
    // 2. K個ずつの和(プラスのみ, 及び, 符号によらない合計)を保存.
    // ex.
    // K = 3 の 場合, 
    // kPlus[4]  は, A[0] ～ A[4] で, プラスのものだけを合計.
    // kTotal[4] は, A[0] ～ A[4] を合計.
    kPlus[0] = (A[0] > 0) ? A[0] : 0;
    kTotal[0] = A[0];
    for(int i = 1; i < N; i++){
        // kPlus更新.
        if(A[i] > 0) kPlus[i] += kPlus[i - 1] + A[i];
        else         kPlus[i] =  kPlus[i - 1];
        // kTotal更新.
        kTotal[i] += kTotal[i - 1] + A[i];
    }
    // for(int i = 0; i < N; i++) printf("%lld ", kPlus[i]);
    // printf("\n");
    // for(int i = 0; i < N; i++) printf("%lld ", kTotal[i]);
    // printf("\n");
    
    // 3. スコアの最大値を計算.
    LL ans = 0;
    for(int i = K - 1; i < N; i++){
        LL kp = (i > K - 1) ? kPlus[i]  - kPlus[i - K]  : kPlus[i];
        LL kt = (i > K - 1) ? kTotal[i] - kTotal[i - K] : kTotal[i];
        // K個連続で, 黒色にする場合.
        ans = max(ans, pTotal - kp + kt);
        // K個連続で, 白色にする場合.
        ans = max(ans, pTotal - kp + 0);
    }
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort (vec.begin(), vec.end());
  int dan = 0;
  
  for (int i = 0; i < vec.size() - 1; i++){
    if (vec.at(i) != vec.at(i + 1)){
      dan++;
    }
  }
  
  cout << dan + 1 << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int d, e, sub, ans, N;
long int L[110];
int main(void) {

	scanf("%d", &N);
	for(int k = 0; k < N; k++){
		scanf("%ld", &L[k]);
	}

	for(int a = 0; a < N; a++){
			for(int b = a +1; b < N; b++){
				if (L[a] > L[b]){
				sub = L[a];
				L[a] = L[b];
				L[b] = sub;
				}
			}
		}

	for(int a = 0; a < N; a++){
		for(int b = a + 1; b < N; b++){
			for(int c = b +1; c < N; c++){
				if( (L[a] != L[b]) && (L[b] != L[c]) && (L[c] != L[a]) ){
					if( ((L[a] + L[b]) > L[c]) && ((L[b] + L[c]) > L[a]) && ((L[c] + L[a]) > L[b])){
						ans++;
					}
				}
			}
		}
	}

	printf("%d", ans);

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  bool flag = true;
  for (int i=0; i<3; i++){
    if (s[i]==s[i+1]){
      flag=false;
      break;
    }
  }
  if (flag) cout << "Good" <<endl;
  else cout << "Bad" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10 ** 7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    l = input()

    bad = False
    if l[0] == l[1]:
        bad = True

    if l[1] == l[2]:
        bad = True
    if l[2] == l[3]:
        bad = True

    if bad:
        print("Bad")
    else:
        print("Good")

solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int K;
  cin >> K;
  cout << (K/2) * ((K+1)/2) << endl;
}

Measured memory_bytes: 256
package main
import "fmt"

func check(num,num2 int)(string){
    if num==num2{
        return "=="
    }else if num<num2{
        return "<"
    }else{
        return ">"
    }
}

func main(){
    var num,num2 int
    fmt.Scan(&num,&num2)
    sign:=check(num,num2)
    
    fmt.Println("a",sign,"b")
}



Measured memory_bytes: 1120
#include<iostream>
#include<stdio.h>
#include<math.h>
#include    <iomanip>
#include    <map>
#include    <set>
using namespace std;

int a[100][100];
int n1,n2,dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
int dfs(int x,int y,int v){
    int vv=v;
    for (int i=0; i<4; i++) {
            if ((x+dx[i]>=0)&&(x+dx[i]<n2)&&(y+dy[i]>=0)&&(y+dy[i]<=n1)&&a[x+dx[i]][y+dy[i]]==1) {
                a[x+dx[i]][y+dy[i]]=0;
                vv=max(vv,dfs(x+dx[i], y+dy[i], v+1));
                a[x+dx[i]][y+dy[i]]=1;
            
        }
    }
    return vv;
}

int main(){
    while(cin>>n1&&n1!=0){
        cin>>n2;
        for (int i=0; i<n2; i++) {
            for (int j=0; j<n1; j++) {
                cin>>a[i][j];
            }
        }
        int m=0;
        for (int i=0; i<n2; i++) {
            for (int j=0; j<n1; j++) {
                if (a[i][j]==1) {
                    a[i][j]=0;
                    m=max(m,dfs(i,j,1));
                    a[i][j]=1;
                }
            }
        }
        cout<<m<<endl;
        
    }
           return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll e = lcm(c,d);
    //  P(e);
    a--;
    ll ans = (b/c - a/c) + (b/d-a/d) - (b/e-a/e);
    //  P(b/d);
    // P(a/d);
    P(b-a -ans);
    return  0;
}


Measured memory_bytes: 256
s = "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"
lst = s.split(", ")
print(lst[int(input()) - 1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

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

    int K;
    vector<vector<int>> tree;
    queue<int> q;
    vector<int> parentCol(N);
    vector<int> deg(N, 1);
    map<pair<int, int>, int> edge;
    vector<pair<int, int>> edge2;

    rep(i, N)
    {
        tree.push_back({});
    }

    rep(i, N - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        deg[a]++;
        tree[a].push_back(b);
        edge2.push_back(make_pair(a, b));
    }

    deg[0]--;

    K = *max_element(deg.begin(), deg.end());

    q.push(0);
    parentCol[0] = -1;

    while (!q.empty())
    {
        int node = q.front();
        q.pop();

        int currentCol = 1;
        for (int child : tree[node])
        {
            q.push(child);
            if (currentCol == parentCol[node])
            {
                currentCol++;
            }
            edge[make_pair(node, child)] = currentCol;
            parentCol[child] = currentCol;
            currentCol++;
        }
    }

    cout << K << endl;
    for (auto p : edge2)
    {
        cout << edge[p] << endl;
    }
}


Measured memory_bytes: 12272
A, B, C = input().split()

ans = []

ans.append(int(A) + int(B+C))
ans.append(int(A) + int(C+B))
ans.append(int(B) + int(A+C))
ans.append(int(B) + int(C+A))
ans.append(int(C) + int(A+B))
ans.append(int(C) + int(B+A))

print(max(ans))

Measured memory_bytes: 9220
using System;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        int[] n = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int min = n[1];
        int max = n[2];
        int num = 0;
        int ans = 0;
        for(int i = 1;i <= n[0];i++){
            num = (i.ToString().ToCharArray()).Select(b => int.Parse(b.ToString())).Sum();
            if(min <= num && num <= max)ans += i;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
package main

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

var sc = bufio.NewScanner(os.Stdin)

// utils
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

// func max(a, b int) int {
// 	return int(math.Max(float64(a), float64(b)))
// }

// func min(a, b int) int {
// 	return int(math.Min(float64(a), float64(b)))
// }

// func abs(a, b int) int {
// 	return int(math.Abs(float64(a) - float64(b)))
// }

// //data types

// type pair struct {
// 	first  int
// 	second int
// }

func main() {
	sc.Split(bufio.ScanWords)
	m := make(map[string]int)

	for i := 0; i < 3; i++ {
		v := next()
		if _, ok := m[v]; ok {
			m[v]++
		} else {
			m[v] = 1
		}
	}
	for _, v := range m {
		if v == 2 {
			fmt.Print("Yes")
			return
		}
	}
	fmt.Print("No")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int n;
cin >> n;
vector<string> S(n);
set <char> st;
rep(i,n) {
    cin >> S[i];
    int len = S[i].size();
    rep(j,len) {
        st.insert(S[i][j]);
    }
}

vector<char> ans;

for(auto c : st) {
    int cnt = INF;
    rep(i,n) {
        int cur = 0;
        rep(j,S[i].size()) {
            if(S[i][j] == c) cur++;
        }
        cnt = min(cnt,cur);
    }
    rep(i,cnt) ans.push_back(c);
}

sort(all(ans));
rep(i,ans.size()) {
    cout << ans[i];
}

cout << "\n";

return 0;
}

Measured memory_bytes: 256
s = input()

n = len(s)

ans = 0
for i in range(2**n):
	l = []
	for j in range(n):
		if i & (1 << j):
			l.append(j)
	#print(l)
	string = s
	if len(l) == 0:
		continue
	for k in range(len(l)):
		if l[k] == 0:
			string = '+' + string
		else:
			string = string[:l[k]+k] + '+' + string[l[k]+k:]

	ans += eval(string)

print((ans + int(s))//2)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int  m,f,r;
    char grade='F';

    cin >> m >> f >> r;

    while((m!=-1)||(f!=-1)||(r!=-1)) {
        if ((m==-1)||(f==-1)){
            grade = 'F';
        }
        else if(m+f>=80){
            grade = 'A';
        }
        else if((m+f<80)&&(m+f>=65)){
            grade = 'B';
        }
        else if((m+f<65)&&(m+f>=50)){
            grade = 'C';
        }
        else if((m+f<50)&&(m+f>=30)){
            if(r>=50){
                grade = 'C';
            }
            else{
                grade = 'D';
            }
        }
        else if(m+f<30){
            grade = 'F';
        }

        cout << grade << endl;
        cin >> m >> f >> r;
    }




    return 0;
}



Measured memory_bytes: 3096
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
num = len(a)
alice = []
bob = []
coun = 1
for i in a:
    if coun % 2 == 1:
        alice.append(i)
    else:
        bob.append(i)
    coun += 1
ans = abs(sum(alice) - sum(bob))
print(ans)

Measured memory_bytes: 9104
a = [map(int, raw_input().split()) for _ in xrange(3)]
h0 = sum(a[0])
h1 = sum(a[1])
h2 = sum(a[2])
w0 = sum([a[i][0] for i in xrange(3)])
w1 = sum([a[i][1] for i in xrange(3)])
w2 = sum([a[i][2] for i in xrange(3)])

if (h0-h1)%3 or (h1-h2)%3 or (h2-h0)%3 or (w0-w1)%3 or (w1-w2)%3 or (w2-w0)%3:
    print "No"
else:
    print "Yes"


Measured memory_bytes: 2568
N = int(input())
count = 0
end = 0
start = 0
double = 0
for i in range(N):
    line = input()
    if "AB" in line:
        count += line.count("AB")
    if line[0] == "B":
        if line[-1] == "A":
            double +=1
        else:
            start += 1
    elif line[-1] == "A":
            end += 1
if double == 0:
    count += min(start, end)
elif start + end > 0:
    count += double + min(start, end)
elif start + end == 0:
    count += double - 1
print(count)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
ids = [list(map(int, input().split())) for _ in range(m)]
l = []
r = []
for id in ids:
        l.append(id[0])
        r.append(id[1])
if max(l) <= min(r):
        print(min(r) - max(l) + 1)
else:
        print(0)


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> city(n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        city[a - 1]++;
        city[b - 1]++;
    }
    for (int i = 0; i < n; i++) {
        cout << city[i] << endl;
    }
    return 0;
}

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

#define REP(i,n) for(i=0;i<n;i++)

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int dfs(int v, int n, int *visited, int table[n][n]);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);

//main function
int main() {
    int n = iin();
    iout(180*(n - 2));
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
    int all_visited = 1, i;

    REP(i,n) {
        if (!visited[i]) {
            all_visited = 0;
            break;
        }
    }

    if (all_visited) {
        return 1;
    }

    int count = 0;

    REP(i,n) {
        if (!table[v][i]) continue;
        if (visited[i]) continue;

        visited[i] = 1;
        count += dfs(i, n, visited, table);
        visited[i] = 0;
    }

    return count;
}

int gcd(int a, int b) {
    int r;

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

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

long long llgcd(long long a, long long b) {
    long long r;

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

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
typedef long long ll;

void insert(unordered_map<int, int> &mp, int a){
  if (mp.find(a) == mp.end())
    mp[a] = 1;
  else
    mp[a]++;
}

int main(int argc, const char * argv[]) {

  int n; cin >> n;
  unordered_map<int, int> mpa, mpb;
  int a,b;
  for (int i=0; i<n/2; i++) {
    cin >> a >> b;
    insert(mpa, a);
    insert(mpb, b);
  }
  
  pair<int, int> max4a, secondmax4a, max4b, secondmax4b;
  max4a = make_pair(0, 0);
  secondmax4a = make_pair(0, 0);
  for (auto it = mpa.begin(); it != mpa.end(); ++it){
    if(it->second > max4a.second){
      secondmax4a = max4a;
      max4a = make_pair(it->first, it->second);
    }else if(it->second > secondmax4a.second)
      secondmax4a = make_pair(it->first, it->second);
  }
  max4b = make_pair(0, 0);
  secondmax4b = make_pair(0, 0);
  for (auto it = mpb.begin(); it != mpb.end(); ++it){
    if(it->second > max4b.second){
      secondmax4b = max4b;
      max4b = make_pair(it->first, it->second);
    }else if(it->second > secondmax4b.second)
      secondmax4b = make_pair(it->first, it->second);
  }
  
  int ans = n - max4a.second - max4b.second;
  if(max4a.first != max4b.first){
    cout << ans << endl;
  }else{
    ans += min(max4a.second - secondmax4a.second, max4b.second - secondmax4b.second);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
const int maxn=100005;
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    string s;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='1') s[i]='9';
        else if(s[i]=='9') s[i]='1';
    }
    cout<<s<<endl;
}


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

using namespace std;

int n, q, x, y, i, j;
string s, t;

vector<int> pos[256];

void solve() {
  cin >> s >> t;
  for (i = 0; i < s.size(); i++) {
    pos[s[i]].push_back(i);
  }
  long long res = 0;
  int cur = -1;

  for (auto& ch : t) {
    const auto& inds = pos[ch];
    if (inds.empty()) {
      cout << -1 << endl;
      return;
    }

    auto iter = upper_bound(inds.begin(), inds.end(), cur);

    if (iter == inds.end()) iter = inds.begin();

    int nxt = *iter;

    res += (nxt > cur ? nxt - cur : nxt - cur + s.size());
    cur = nxt;
  }

  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}


Measured memory_bytes: 1228
n = int(input())
flag= False
count = 0
for i in range(n):
  a,b = list(map(int, input().split()))
  if a==b:
    count += 1
  else:
    count= 0
  if count==3:
    flag = True
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9044
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;
 
int main(){
    ll n, m;

    cin >> n >> m;

    vector<char> ans(n);
    rep(i, n)ans[i] = '?';

    rep(i, m){
        ll s;
        char c;
        cin >> s >> c;
        s--;
        if(ans[s] == '?')ans[s] = c;
        else if(ans[s] != c){
            cout << -1 << endl;
            return 0;
        }
    }

    if(ans[0] == '0' && n != 1){
        cout << -1 << endl;
        return 0;
    }



    if(ans[0] == '?'){
        if(n == 1){
            cout << 0 << endl;
            return 0;
        }
        ans[0] = '1';
    }

    rep(i, n)if(ans[i] == '?')ans[i] = '0';


    rep(i, n)cout << ans[i];
}

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

int main(){
    int n, i;
    double amount=0;
    cin >> n;
    double v;
    for (i=0; i<n; i++) {
        cin >> v;
        amount += 1/v;
    }
    
    cout << 1/amount << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,d = list(map(int, list(input())))
for op1 in range(2):
    for op2 in range(2):
        for op3 in range(2):
            if a + b * [1,-1][op1] + c * [1,-1][op2] + d * [1,-1][op3] == 7:
                print("%d%s%d%s%d%s%d=7" % (a, ["+", "-"][op1], b, ["+", "-"][op2], c, ["+", "-"][op3], d))
                exit()

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

using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cout.tie(NULL);


int main()
{
	FAST_IO;

	int n;
	cin >> n;
	if (n%2 == 0) cout << n << endl;
	else cout << 2*n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace  std;
signed main(){
    int N; cin>>N;
    vector<int> S(N);
    for(int i=0; i<N; i++){
        cin>>S[i];
    } 
    int q; cin >> q;
    int res = 0;
    for(int i=0; i<q; i++){
        int x; cin>>x;
        for(int i=0; i<N; i++){
            if(S[i]==x){
                res++;
                break;
            }
        }
    } 
    cout << res << endl;
    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B;
  cin >> A >> B;
  rep(i, 1, 4) {
    if (i != A && i != B) {
      cout << i << endl;
    }
  }

  return 0;
};


Measured memory_bytes: 256
from math import factorial
n, m = map(int, input().split())
x = 0
y = 0
if n >= 2:
    x = factorial(n) / factorial(2) / factorial(n - 2)

if m >= 2:
    y = factorial(m) / factorial(2) / factorial(m - 2)

print(int(x+y))



Measured memory_bytes: 3060
#include <stdio.h>

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int H;
    int max_H = 0;
    int counter = 0;
    rep(i, N){
        cin >> H;
        if (H>=max_H){
            counter++;
            max_H = H;
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 256