akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int k;
 cin>>k;
 int a,b;
 cin>>a>>b;
 for(int i=a;i<=b;i++)
 {
           if(i%k==0) 
           {
                     cout<<"OK";
                     return 0;
           }
 }
 puts("NG");
 
 
 
 
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3624
let rec read t m =
  if m = 0 then ()
  else
    begin
      let i, j = Scanf.scanf "%d %d\n" (fun x y -> (x, y)) in
      t.(i-1) <- t.(i-1) + 1;
      t.(j-1) <- t.(j-1) + 1;
      read t (m-1)
    end
         
let () =
  let n, m = Scanf.scanf "%d %d\n" (fun x y -> (x, y)) in
  let tbl = Array.make n 0 in
  read tbl m;
  Array.iter (fun v ->
              Printf.printf "%d\n" v
             ) tbl


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

int main() {
  int N,K,A=1;
  cin >> N >> K;
  for (int i = 0; i < N; i++){
    if (A < K)
      A *= 2;
    else
      A += K;
  }
  cout << A << endl;
}


Measured memory_bytes: 256
a=input().split(" ")
A=int(a[0])
B=int(a[1])
p=A+B
q=A-B
r=A*B
if p>=q:
    s=p-r
    if s>=0:
        print(p)
    else:
        print(r)
if q>p:
    s=q-r
    if s>=0:
        print(q)
    else:
        print(r)

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

int main(){
    int H,W;
    
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if((i + j) % 2 == 0)cout << "#";
                else cout <<".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MP make_pair
#define endl '\n'
const int mod = 10007;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;

vector<int> e[MAXN];
int ta[MAXN], tb[MAXN];
int n, s, t;
struct node {
    int t, x;
    node(int a, int b) : t(a), x(b) {}
};

int solve() {
    queue<node> q;
    memset(ta, -1, sizeof(ta));
    memset(tb, -1, sizeof(tb));
    q.push({0, s});
    while (!q.empty()) {
        node u = q.front();
        q.pop();
        if (ta[u.x] != -1) continue;
        ta[u.x] = u.t;
        for (int v : e[u.x]) {
            if (ta[v] == -1) q.push({u.t + 1, v});
        }
    }
    q.push({0, t});
    while (!q.empty()) {
        node u = q.front();
        q.pop();
        if (tb[u.x] != -1) continue;
        tb[u.x] = u.t;
        for (int v : e[u.x]) {
            if (tb[v] == -1) q.push({u.t + 1, v});
        }
    }
    // for (int i = 1; i <= n; i++) {
    //     printf("i:%d ta:%d tb:%d\n", i, ta[i], tb[i]);
    // }
    int maxm = 0;
    for (int i = 1; i <= n; i++) {
        if (ta[i] < tb[i]) maxm = max(maxm, tb[i]);
    }
    return maxm - 1;
}

int main(int argc, char* argv[]) {
#ifdef local
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d %d %d", &n, &s, &t);
    for (int i = 0; i < n; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        e[u].push_back(v);
        e[v].push_back(u);
    }
    printf("%d\n", solve());
    return 0;
}


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

int main(){
	int w,h;
	long long dp[101][101][2][2]={};
	dp[0][0][0][1]=dp[0][0][1][1]=1;
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			dp[i+1][j][0][1] += dp[i][j][1][0]%100000;
			dp[i][j+1][1][1] += dp[i][j][0][0]%100000;
			for(int k=0;k<2;k++){
				dp[i+1][j][0][0] += dp[i][j][0][k]%100000;
				dp[i][j+1][1][0] += dp[i][j][1][k]%100000;
			}
		}
	}
	while(cin>>w>>h,w||h){
		int ans=0;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				ans+=(dp[h-1][w-1][i][j]%100000);
			}
		}
		printf("%d\n",ans%100000);
	}
	return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  bool flag = false;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j][i] == b[0][0]) {
        flag = true;
        for (int x = 0; x < m; x++) {
          for (int y = 0; y < m; y++) {
            if (a[j + y][i + x] != b[y][x]) {
              flag = false;
              break;
            }
          }
          if (!flag) break;
        }
        if (flag == true) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        final String CORRECT = "CODEFESTIVAL2016";
        int result = 0;
        for (int i = 0; i < CORRECT.length(); i++) {
            if (s.charAt(i) != CORRECT.charAt(i)) {
                result++;
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 22868
N=int(input())
room=[[[0]*10 for _ in range(3)] for _ in range(4)]

for _ in range(N):
    b,f,r,v=map(int,input().split())
    room[b-1][f-1][r-1]+=v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' {}'.format(room[i][j][k]),end='')
        print()
    if i!=3:
        print('####################')
    


Measured memory_bytes: 5624
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  std::string S, T;
  std::cin >> S >> T;
  std::size_t min_count = T.size();
  for (std::size_t i = 0; i + T.size() <= S.size(); ++i) {
    std::size_t count = 0;
    for (std::size_t j = 0; j < T.size(); ++j) {
      count += S[i + j] != T[j];
    }
    min_count = std::min(min_count, count);
  }
  std::cout << min_count << std::endl;
  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define beg begin()
#define end end()

void _main(){
    int n,m; cin >> n >> m;
    auto check = [](int x,map<int,int>& digitnums){
        vector<int> digitx;
        if(x==0) digitx.push_back(x);
        while(x){
            digitx.push_back(x%10);
            x /=10;
        };
        reverse(digitx.beg,digitx.end);
        for(auto dnum : digitnums){
            if(digitx[dnum.first-1]!=dnum.second) return false;
        }
        return true;
    };
    auto mainn = [&](){
        map<int,int> digitnums;
        rep(i,m){
            int s,c; cin >> s >> c;
            auto ite = digitnums.find(s);
            if(ite != digitnums.end && digitnums[s] != c) return -1;
            else digitnums.emplace(s,c);
        }
        int mi=0;if(n>1) mi = pow(10,n-1);
        int ma= pow(10,n);
        int x;
        for (x = mi; x < ma; x++)
        {
            if(check(x,digitnums)) return x;
        }
        return -1;
    };
    cout << mainn() << endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>//sort
#include <vector>
#include <string>
#include <map>//pair
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if(A == B && B != C)cout << "Yes" << endl;
  else if(A == C && B != C)cout << "Yes" << endl;
  else if(C == B && A != C)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import product

N, Y = map(int, input().split())

x = y = z = -1

for i, j in product(range(N+1), range(N+1)):
    if i+j > N:
        continue
    else:
        tmp = N - i - j
        if tmp < 0:
            continue
        elif 10000*i+5000*j+1000*tmp == Y:
            x = i
            y = j
            z = tmp
            break

print(x, y, z)

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    string res = "APPROVED";
    rep(i,n){
        if(a.at(i)%2==0){
            if(a.at(i)%3!=0 && a.at(i)%5!=0){
                res = "DENIED";
                break;
            }
        }
    }
    cout << res << endl;
}


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

int main() {    
    string s; cin >> s;
    int t; t = stoi(s);

    if(t/100 <= 12 && t%100 <= 12 && t/100 >= 1 && t%100 >= 1){
        cout << "AMBIGUOUS" << endl;
    }
    else if(t/100 <= 12 && t/100 >= 1){
        cout << "MMYY" << endl;
    }
    else if(t%100 <= 12 && t%100 >= 1){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000000],b[1000000];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int minn=a[1],sum=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>minn) continue;
		else
		{
			sum++;
			minn=a[i];
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))


#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321

int N,M,K,T;

int main(void){
	int a,b; geti(a,b);
	if( a == b ){
		cout << "Draw" << endl;
		return 0;
	}

	if( a == 1 ){
		cout << "Alice" << endl;
		return 0;
	}
	if( b == 1 ){
		cout << "Bob" << endl; return 0;
	}
	if( a > b ){
		cout << "Alice" << endl; return 0;
	}
	if( a < b ){
		cout << "Bob" << endl; return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin >> n;
	int a = 0, b = 0, c = 0, d = 0;
	for(int i = 1;i <= n;i++)
	{
		string s;
		cin >> s;
		if(s == "AC")
			a++;
		else if(s == "WA")
			b++;
		else if(s == "TLE")
			c++;
		else
			d++;
	}
	cout << "AC" << " " << "x" << " " << a << "\n";
	cout << "WA" << " " << "x" << " " << b << "\n";
	cout << "TLE" << " " << "x" << " " << c << "\n";
	cout << "RE" << " " << "x" << " " << d << "\n";
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
long long gcd(long long a, long long b) { /* the greatest common divisor*/
  while (b != 0) {
    long long r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { /*the least common multiple*/
  return (a / gcd(a, b)) * b;
}

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  int g = gcd(A, B);
  int cnt = 0;
  int ans = 0;
  VEC<int>s;
  REP(i, 1, g + 1) {
    if (g % i == 0){
++cnt;
s.push_back(i);
    } 
    
  }
  cout << s[s.size()-K] << endl;
  return 0;
}


Measured memory_bytes: 256
import math

def main():
    r = int(input())
    s = math.pi*r*r
#    print("s:"+str(s))
    base_s = math.pi
#    print("base:"+str(base_s))
    ans = s/base_s
#    print("ans:"+str(round(ans)))
    print(round(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define umap unordered_map
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




//———————UnionFind木   UF uf(n);——————————————————————————

struct UF {
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    UF(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void reset(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

//—————————————————————————————————————————————————



int main() {
  int n,k,l;
  cin >>n>>k>>l;
  
  UF road(n);
  UF rail(n);
    
  rep(i,k){
  ll x,y;
  cin>>x>>y;
    road.unite(x-1,y-1);
  }
  rep(i,l){
  ll x,y;
  cin>>x>>y;
    rail.unite(x-1,y-1);
  }  
  
  map<pair<int,int>,int> p;
  rep(i,n){
  auto x=mp(road.root(i),rail.root(i));
    if(p.count(x)) p.at(x)++;
    else p[x]=1;
  }
  
  rep(i,n){
  auto x=mp(road.root(i),rail.root(i));
  cout << p[x] << " ";
  }
  
  cout << endl;
}


Measured memory_bytes: 18048
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = 0;
    int move = 0;
    int prev = sc.nextInt();
    for (int i = 1; i < N; i++) {
      int H = sc.nextInt();
      if (prev >= H) {
        move++;
        max = Math.max(max, move);
      } else {
        move = 0;
      }
      prev = H;
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 48208
n = int(input())
l = [int(num) for num in input().split()]

count = 0

for i in range(len(l)-2) :
    part = l[i:i+3]
    part.sort(reverse=False)
    if (part.index(l[i+1]) == 1) :
        count += 1

print(count)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(void)
{
  int ary[100001] = {};
  int num;
  cin >> num;
  unsigned long long sum = 0;
  
//  cout << ary[100000];
  
  for(int i = 0; i < num; i++) {
    int tmp;
    cin >> tmp;
	ary[tmp]++;
    sum += tmp;
  }

  /*
  for(int i = 0; i < 10; i++) {
    cout << ary[i] << ' ';
  }
  cout << '\n';

  cout << sum << '\n';
  */
  int CNT;
  cin >> CNT;

  for(int i = 0; i < CNT; i++) {
    int b,c;
    cin >> b >> c;
    sum = sum - ((unsigned long long)b * ary[b]) + ((unsigned long long)c * ary[b]);
    ary[c] = ary[c] + ary[b];
    ary[b] = 0;
    cout << sum <<'\n';
  }


    return 0;
}

Measured memory_bytes: 4020
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] cnt = new int[200001];
      int INF = 10000000;
      int x = 0;
      int ans = 0;
      for(int i = 0;i < 200001;i++)cnt[i]=INF;
      for(int i = 0;i < n;i++){
        int r = sc.nextInt();
        if(cnt[r]==INF)cnt[r]=1;
        else if(cnt[r]!=INF)cnt[r]++;
      }
      Arrays.sort(cnt);
      for(int i = 0;i < 200001;i++){
      	if(cnt[i]==INF){
          x = i;
          break;
        }
      }
      int j = 0;
      while(x>k){
      	ans+=cnt[j];
        x--;
        j++;
      }
      System.out.println(ans);
    }
}

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

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n - 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            cin >> a[i][j];
            a[i][j]--;
        }
    };

    vector<int> c(n);
    vector<int> q;
    for (int i = 0; i < n; i++) {
        int x = a[i][0];
        if (a[x][0] == i) {
            q.push_back(i);
        }
    }
    int res = 0;
    while (!q.empty()) {
        res++;
        vector<int> q2;
        for (int i : q) {
            c[i]++;
            if (c[i] < n - 1) {
                int x = a[i][c[i]];
                if (a[x][c[x]] == i) {
                    q2.push_back(i);
                    q2.push_back(x);
                }
            }
        }
        q = q2;
    }
    for (int i = 0; i < n; i++) {
        if (c[i] < n - 1) {
            cout << -1;
            return 0;
        }
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 4224
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()

    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    from math import gcd

    flag = 0
    if K in A: flag = 1
    elif max(A)<K: flag = 0
    else:
        x = max(A)-K
        g = A.pop(0)
        for a in A:
            g = gcd(g,a)

        if K%g==0:
            flag = 1
        
    print(['IMPOSSIBLE','POSSIBLE'][flag])
    


if __name__=='__main__':
    main()

Measured memory_bytes: 19828
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			
			Map<String, Entry> map = new HashMap<>();
			
			for(int i = 0 ; i < n ; i++ ) {
				String s = sc.next();

				if (map.containsKey(s)) {
					map.get(s).count++;
				}
				else {
					Entry entry = new Entry(s);
					entry.count++;
					map.put(s, entry);
				}
			}
			
			PriorityQueue<Entry> pq = new PriorityQueue<>(
					new Comparator<Entry>() {
						@Override
						public int compare(Entry o1, Entry o2) {
							if ( Integer.compare(o1.count, o2.count) == 0 ) {
								return o1.s.compareTo(o2.s);
							}
							else {
								return -1 *  Integer.compare(o1.count, o2.count);
							}
						}
						
					}
			);
			
			for(Entry entry : map.values()) {
				pq.add(entry);
			}
			
			int maxValue = pq.peek().count;
			while(true) {
				Entry e = pq.poll();
								
				if ( e != null && e.count == maxValue ) {
					System.out.println(e.s);
				}
				else {
					return;
				}
			}
		}
	}
	
	private static class Entry {
		
		public Entry(String s) {
			this.s = s;
		}
		public int count;
		public String s;
	}
}

Measured memory_bytes: 85864
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0){
      break;
    }
    for (int j = 0; j < W; j++){
      cout << '#';
    }
    cout << endl;
    for (int i = 1; i < H - 1; i++){
      cout << '#';
      for (int j = 1; j < W - 1; j++){
        cout << '.';
      }
      cout << '#' << endl;
    }
    for (int j = 0; j < W; j++){
      cout << '#';
    }
    cout << endl;
    cout << endl;
  }
}


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

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

using Point = complex<double>;
using Polygon = vector<Point>;

inline int sgn(const double &a) { return (a < -EPS ? -1 : (a > EPS ? 1 : 0)); }

inline bool eq(const Point &a, const Point &b) { return abs(a - b) < EPS; }

namespace std {
inline bool operator<(const Point &a, const Point &b) {
    if (sgn(a.real() - b.real()))
        return sgn(a.real() - b.real()) < 0;
    return sgn(a.imag() - b.imag()) < 0;
}
} // namespace std

double dot(const Point &a, const Point &b) { return real(conj(a) * b); }

double det(const Point &a, const Point &b) { return imag(conj(a) * b); }

struct Line {
    Point p1, p2;

    Line(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

    bool operator<(const Line &rhs) const {
        if (eq(p2, rhs.p2))
            return p1 < rhs.p1;
        return p2 < rhs.p2;
    }
    bool operator==(const Line &rhs) const {
        return (eq(p1, rhs.p1) && eq(p2, rhs.p2)) ||
               (eq(p1, rhs.p2) && eq(p2, rhs.p1));
    }
};

enum CCW {
    ONLINE_FRONT = -2,
    CLOCKWISE,
    ON_SEGMENT,
    COUNTER_CLOCKWISE,
    ONLINE_BACK
};

int ccw(Point p0, Point p1, Point p2) {
    Point a = p1 - p0;
    Point b = p2 - p0;
    if (sgn(det(a, b)) == 1)
        return COUNTER_CLOCKWISE;
    if (sgn(det(a, b)) == -1)
        return CLOCKWISE;
    if (sgn(dot(a, b)) == -1)
        return ONLINE_BACK;
    if (sgn(norm(b) - norm(a)) == 1)
        return ONLINE_FRONT;
    return ON_SEGMENT;
}

Polygon convex_hull(Polygon s) {
    int n = s.size(), k = 0;
    if (n < 3)
        return s;
    sort(s.begin(), s.end());

    Polygon ch(2 * n);

    // 下側凸包
    for (int i = 0; i < n; i++) {
        while (k >= 2 && ccw(ch[k - 2], ch[k - 1], s[i]) == CLOCKWISE)
            k--;
        ch[k++] = s[i];
    }

    // 上側凸包
    for (int i = n - 2, t = k + 1; i >= 0; i--) {
        while (k >= t && ccw(ch[k - 2], ch[k - 1], s[i]) == CLOCKWISE)
            k--;
        ch[k++] = s[i];
    }

    ch.resize(k - 1);
    return ch;
}

int main(){
    int n;
    cin >> n;
    Polygon p;
    for(int i=0;i<n;++i){
        double x, y;
        cin >> x >> y;
        p.push_back(Point(x, y));
    }
    Polygon ch = convex_hull(p);
    ch.push_back(ch[0]);
    ch.push_back(ch[1]);
    map<Point, double> ans;
    for(int i=1;i<ch.size()-1;++i){
        double ag1 = atan2(imag(ch[i+1]-ch[i]), real(ch[i+1]-ch[i]));
        double ag2 = atan2(imag(ch[i]-ch[i-1]), real(ch[i]-ch[i-1]));
        ans[ch[i]] = (ag1 - ag2) / (2*PI);
        if(ans[ch[i]] < 0)ans[ch[i]] += 1;
    }

    for(auto pt : p){
        printf("%.10f\n",ans[pt]);
    }

    return 0;
}


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

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

  int count = 0;

  for (int i = 0; i < 3; i++) {
    if (S[i] == 'o') {
      count++;
    }
  }

  cout << 700 + count * 100 << endl;

}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;
// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



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

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar[4] = {{0,1},{0,-1},{1,0},{-1,0}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
  cout << (n-1)/2+1 << endl;
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let s: String = read!();

    if s.chars().count() == 2 {
        println!("{}", s);
    } else {
        println!("{}", s.chars().rev().collect::<String>());
    }
}


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

using namespace std;

int main() 
{
    int n, x, y, z;
    scanf("%d", &n);
    
    deque<int> d;
    
    for(int i = 0; i < n; i++)
    {
        scanf("%d %d", &x, &y);
        
        if(x == 2)
        {
            if(y == 0)
                d.pop_front();
            else if(y == 1)
                d.pop_back();
        }
        else if(x == 1)
        {
            if(d.size() > 0)
            {
                printf("%d\n", d[y]);
            }
        }
        else
        {
            scanf("%d", &z);
            
            if(x == 0)
            {
                if(y == 0)
                    d.push_front(z);
                else if(y == 1)
                    d.push_back(z);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 4664
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1e5+10;
const int INF=1e9;
int n,k,s;
int main(){
	scanf("%d%d%d",&n,&k,&s);
	while(k){
		printf("%d",s);
		k--;n--;
		if(n==0) printf("\n");
		else printf(" ");
	}
	if(k==0&&n>0){
		if(s==INF){
			for(int i=1;i<n;++i) 
				printf("%d ",1);
			printf("%d\n",1);
			return 0;
		}
		else{
			for(int i=1;i<n;++i) 
				printf("%d ",INF);
			printf("%d\n",INF);
			return 0;
		}
	}
	return 0;
} 

Measured memory_bytes: 1280
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <time.h>
#include <stdlib.h>
#include <bitset>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define LL_INF 1e18

#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 1000000007
#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;

typedef long long int ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define nmax 3010

int n, m;
int dp[nmax][nmax];
char s[nmax], t[nmax], answer[nmax];

int main()
{
    scanf("%s", s + 1);
    scanf("%s", t + 1);

    n = strlen(s + 1);
    m = strlen(t + 1);

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (s[i] == t[j]) dp[i][j] = dp[i - 1][j - 1] + 1; else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

    int x = n, y = m;

    while (x > 0 && y > 0)
    {
        while (x > 0 && dp[x][y] == dp[x - 1][y]) x--;
        while (y > 0 && dp[x][y] == dp[x][y - 1]) y--;

        answer[dp[x][y]] = s[x];

        x--; y--;
    }

    puts(answer + 1);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

Measured memory_bytes: 35584
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,m,dis[1005][1005];
char arr[1005][1005];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

queue<pair<int,pii > >q;
bool inside(int x,int y){
    return x>=1 && x<=n && y>=1 && y<=m;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    memset(dis,-1,sizeof(dis));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>arr[i][j];
            if(arr[i][j]=='#'){
                dis[i][j]=0;
                q.push({i,{j,0}});

            }
        }
    }
    
    while(q.empty()==false){
        int r=q.front().fi;
        int c=q.front().se.fi;
        int cnt=q.front().se.se;
        q.pop();
        for(int i=0;i<4;i++){
            int nr=r+dx[i];
            int nc=c+dy[i];
            if(dis[nr][nc]==-1 && inside(nr,nc)){
                q.push({nr,{nc,cnt+1}});
                dis[nr][nc]=cnt+1;
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            ans=max(ans,dis[i][j]);
        }

    }
    cout<<ans<<endl;

}

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

int main()
{
    long long a,c,d;
    double b;
    scanf("%lld %lf",&a,&b);
    d=round(b*100);
  //  cout<<d<<endl;
    c=a*d;
    c/=100;
    printf("%lld",c);
    return 0;
}


Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define N 111111
#define M 222222
#define P 10001000
using namespace std;
int n,i,p[N];
long long a[N],b[N];
int main(){
	for(scanf("%d",&n),i=1;i<=n;i++)scanf("%d",&p[i]);
	for(i=1;i<=n;i++)a[i]=1ll*i*20003,b[i]=1ll*(n-i+1)*20003;
	for(i=1;i<=n;i++)a[p[i]]+=i,b[p[i]]+=i;
	for(i=1;i<=n;i++)printf("%lld%c",a[i],i==n?'\n':' ');
	for(i=1;i<=n;i++)printf("%lld%c",b[i],i==n?'\n':' ');
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> c(n);
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        c[i] = make_pair(a, b);
    }
    sort(begin(c), end(c));
    ll t = m;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += c[i].first * min(t, c[i].second);
        t -= c[i].second;
        if(t <= 0) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
lis = [int(input()) for _ in range(5)]
lis2 = [i % 10 for i in lis]

x = 0
a = 9
time = 0

for id,val in enumerate(lis2):
    if 0 < val < a:
        x = id
        a = val

for id2, val2 in enumerate(lis):
    if id2 == x:
        continue
    else:
        time += (-(-val2//10)) * 10

print(time+lis[x])


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
typedef pair<int, int> PP;
typedef pair<P, PP> PPP;
static const ll INF = 1LL << 60;

struct edge{
	int to; ll cost;
};
class Graph{
	public:
	vector<vector<edge> > adj;
	Graph(int V){
		adj.resize(V);
	}
	void add_edge(int s, edge e){
		adj[s].push_back(e);
	}
	vector<vector<vector<ll> > > dijkstra(int s, vector<int> &T, int &X){
		priority_queue<PPP, vector<PPP> , greater<PPP> > pqa;
		vector<vector<vector<ll> > >  dist(2, vector<vector<ll> >(X + 1, vector<ll>(adj.size(), INF)));
		dist[0][0][s] = 0;
		pqa.push(PPP(P(dist[0][0][s], s), PP(0, 0)));
		while(!pqa.empty()){
			PPP pp = pqa.top(); pqa.pop();
			int u = pp.first.second;
			PP c = pp.second;
			if(dist[c.first][c.second][u] < pp.first.first) continue;
			for(int v = 0; v < adj[u].size(); v++){
				edge e = adj[u][v];
				if((c.first == 0 && T[e.to] == 2) || (c.first == 1 && T[e.to] == 0)){
					if(c.second + e.cost < X) continue;
				}
				int b, d;
				if(T[e.to] == 0){
					b = 0;
					d = 0;
				}else if(T[e.to] == 2){
					b = 1;
					d = 0;
				}else{
					b = c.first;
					d = min(X, (int)(c.second + e.cost));
				}
				if(dist[b][d][e.to] > dist[c.first][c.second][u] + e.cost){
					dist[b][d][e.to] = dist[c.first][c.second][u] + e.cost;
					pqa.push(PPP(P(dist[b][d][e.to], e.to), PP(b, d)));
				}
			}
		}
		return dist;
	}
};

int main(){
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> T(N);
	for(int i = 0; i < N; i++) cin >> T[i];
	Graph G(N);
	for(int i = 0; i < M; i++){
		int A, B, D;
		cin >> A >> B >> D;
		A--; B--;
		G.add_edge(A, (edge){B, D});
		G.add_edge(B, (edge){A, D});
	}
	vector<vector<vector<ll> > > dist = G.dijkstra(0, T, X);
	ll res = INF;
	for(int i = 0; i < 2; i++){
		for(int j = 0; j <= X; j++){
			res = min(res, dist[i][j][N - 1]);
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 51296
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// https://www1181.hlsmp4.com/token=84ewH9fbxpp4czZeHrJcQA/1568133957/0.0.0.0/70/b/4d/030d7ca247fb28cf3effcf5c8e6cd4db-1080p.mp4
//もしも一番大きいやつならば
// Ci 最大値がiになる区間の個数
// sum of Ci * i

//二番目に大きいのは自分より大きいものをちょうど１個含む区間
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) {
        cin >> a[i];
        a[i]--;
    }
    vector<int> idx(n);
    REP(i, n) { idx[a[i]] = i; }
    set<int> s;
    ll ans = 0;
    for(int x = n - 1; x >= 0; x--) {
        int i = idx[x];
        ll c = 0;
        { // calc c
            s.insert(i);
            vector<int> l(2, -1);
            vector<int> r(2, n);
            {                        // calc l
                auto it = s.find(i); //いまxがいる場所のiterator
                REP(j, 2) {
                    if(it == s.begin())
                        break;
                    it--;
                    l[j] = *it; // iteratorの値をとる
                }
            }
            {                        // calc r
                auto it = s.find(i); //いまxがいる場所のiterator
                REP(j, 2) {
                    it++;
                    if(it == s.end())
                        break;
                    r[j] = *it; // iteratorの値をとる
                }
            }
            vector<int> ls(2);
            ls[0] = i - l[0];
            ls[1] = l[0] - l[1];
            vector<int> rs(2);
            rs[0] = r[0] - i;
            rs[1] = r[1] - r[0];
            c = (ll)ls[0] * rs[1] + (ll)ls[1] * rs[0];
        }
        ans += c * (x + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		StringBuffer sb = new StringBuffer(s);
		s = sb.reverse().toString();
		s = s + "0";
		char c[] = s.toCharArray();
		int n = s.length();
		int INF = Integer.MAX_VALUE/2;
		int dp[][] = new int[n+2][2]; //s下からi桁目までを決めた時の、最小利用枚数(j==0->繰り上がりなし、j==1->繰り上がりあり)
		for(int i=0;i<n+1;i++) {
			for(int j=0;j<2;j++)dp[i][j] = INF;
		}
		dp[0][0] = 0;
		for(int i=0;i<n;i++) {
			int now = c[i] - '0';
			for(int j=0;j<2;j++) {
				now += j;
				for(int a = 0;a<10;a++) {
					int ni = i+1, nj = 0;
					int b = a - now;
					if(b < 0) {
						b += 10;
						nj = 1;
					}
					dp[ni][nj] = Math.min(dp[ni][nj], dp[i][j] + a + b);
				}
			}
		}
		int ans = dp[n][0];
		System.out.println(ans);
	}
}


Measured memory_bytes: 68540
n = int(input())
v = list(map(int, input().split()))

cnt_arr = [dict() for _ in range(2)]

for i in range(n):
    cnt_arr[i % 2][v[i]] = cnt_arr[i % 2].get(v[i], 0) + 1

v_even = sorted(list(cnt_arr[0].items()), key=lambda x: x[1], reverse=True)[:2]  # [value, 出現数] * 2（上位2）
v_odd = sorted(list(cnt_arr[1].items()), key=lambda x: x[1], reverse=True)[:2]  # [value, 出現数] * 2（上位2）

keep = 0
flg = False
for even in v_even:  # [0]: 数値, [1]: 出現数
    for odd in v_odd:  # [0]: 数値, [1]: 出現数
        if even[0] != odd[0]:
            flg = True
            keep = max(keep, even[1] + odd[1])

ans = n - keep if flg else n // 2
print(ans)

Measured memory_bytes: 17692
#include<stdio.h>
int main(void){
    int a[100];
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;i>=0;i--){
        if(i<n-1) printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N, M;
    cin >> N >> M;
    
    int total_votes = 0;
    vector<int> vs(N);
    for (int &v : vs) {
        cin >> v;
        total_votes += v;
    }
    
    const int min_votes = ceil(total_votes / (4.0 * M));
    
    if (count_if(vs.cbegin(), vs.cend(), [min_votes](const int v){ return v >= min_votes; }) >= M) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
void solve();
int main()
{
	int t = 1;
//	cin >> t;
	for(int i=1; i <= t; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

void solve()
{
	string str; cin >> str;
	if(str[0] < 'a') cout << 'A';
	else			 cout << 'a';
}

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

int main(){
    int n,m,r;
    cin >> n >> m;
    if(n < m){
        int tmp = n;
        n = m;
        m = tmp;
    }
    r = n % m;
    while(r != 0){
        n = m;
        m = r;
        r = n % m;
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 3092
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    ll N,M; cin>>N>>M;
    string S,T; cin>>S>>T;
    ll lcm=N/__gcd(N,M)*M;
    ll g=__gcd(N,M);

    /*vector<char>s(lcm,' ');
    vector<char>t(lcm,' ');
    ll cnts=0,cntt=0;
    rep(i,lcm){
        if(i%(lcm/N)==0&&cnts<=N-1){
            s[i]=S[cnts];
            cnts++;
        }
        if(i%(lcm/M)==0&&cntt<=M-1){
            t[i]=T[cntt];
            cntt++;
        }
         if(s[i]!=' '&&t[i]!=' '){
            if(s[i]!=t[i]){
                cout<<-1<<endl;
                return 0;
            }
        }
        if(cnts>=N&&cntt>=M)break;

    }
    cout<<lcm<<endl;*/
    for(int i=0,j=0;i<N;i+=N/g,j+=M/g){
        if(S[i]!=T[j]){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<lcm<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s;
	
	cin>>s;
	
	for(int i = 0; i < s.size(); i++){
		if(i%2 == 0) cout<<s[i];
	}
	cout<<endl;
	
	
	return 0;
}

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

using ll = long long;
#define mod 1000000007


int main() 
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    ll l=s.size();
    if(s[l-1]=='s')
    {
    	s+="es";
    }
    else
    {
    	s+='s';
    }
    cout<<s<<endl;
	return 0;
}

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

#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define REP(i, n) for (long long i = 0; i < (n); i++)
const ll INF = 1LL << 60;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
};
ll modpow(ll m, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        ll t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void printInBase(int x, int y) {
    if (x < y) {
        cout << x;
        return;
    }
    int rem = x % y;
    printInBase(x / y, y);
    cout << rem;
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}

int main() {
    ll n;
    cin >> n;
    for (int i = sqrt(n); i > 0; i--) {
        if (n % i == 0) {
            string s;
            s = to_string(n / i);
            cout << s.size() << endl;
            break;
        }
    }
}

Measured memory_bytes: 3796
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        Node root = null;
        for (int i = 0; i < m; i++) {
            String cmd = scanner.next();
            if ("insert".equals(cmd)) {
                Node node = new Node(scanner.nextInt());
                if (root == null) {
                    root = node;
                    continue;
                }
                insert(root, node);
            } else if ("find".equals(cmd)) {
                System.out.println(root.doesContain(scanner.nextInt())? "yes" : "no");
            } else {
                StringBuilder sb = new StringBuilder();
                root.inOrder(sb);
                sb.append("\n");
                System.out.print(sb.toString());
                sb = new StringBuilder();
                root.preOrder(sb);
                sb.append("\n");
                System.out.print(sb.toString());
            }
        }

    }

    private static void insert(Node root, Node node) {
        Node parent = root;
        while (true) {
            if (node.key < parent.key) {
                if (parent.left == null) {
                    parent.left = node;
                    break;
                }
                parent = parent.left;
            } else {
                if (parent.right == null) {
                    parent.right = node;
                    break;
                }
                parent = parent.right;
            }
        }
    }

    private static class Node {
        int key;
        Node parent;
        Node left;
        Node right;

        private Node(int key) {
            this.key = key;
        }

        private void inOrder(StringBuilder sb) {
            if (left != null) {
                left.inOrder(sb);
            }
            sb.append(" " + String.valueOf(key));
            if (right != null) {
                right.inOrder(sb);
            }
        }

        private void preOrder(StringBuilder sb) {
            sb.append(" " + String.valueOf(key));
            if (left != null) {
                left.preOrder(sb);
            }
            if (right != null) {
                right.preOrder(sb);
            }
        }

        private boolean doesContain(int k) {
            if (k == key) {
                return true;
            } else if (k < key) {
                if (left == null) {
                    return false;
                }
                return left.doesContain(k);
            } else {
                if (right == null) {
                    return false;
                }
                return right.doesContain(k);
            }
        }
    }
}


Measured memory_bytes: 315084