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

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define pb push_back
#define ll long long
#define mp make_pair

bool comp(pair<ll, ll> a, pair<ll, ll> b)
{
    if (a.second < b.second)
        return true;
    else if (a.second == b.second)
        return a.first < b.first;
    return false;
}
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    For(i, 0, n)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    ll sum = a[n - 1];
    ll x = n - 2;
    for (ll i = n - 2; i >= 0; i--)
    {
        if (x >= 2)
            sum += a[i] * 2;
        else if (x >= 1)
            sum += a[i];
        x--;
        x--;
    }
    cout << sum << endl;
    return 0;
}


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

int main(int argc, char *argv[]) {
	int N = 0;
	int T = 0;
	int A = 0;
	std::vector<int> heights;

	std::cin >> N;
	std::cin >> T;
	std::cin >> A;
	double current_h;
	for (int i = 0; i < N; i++) {
		std::cin >> current_h;
		heights.push_back(current_h);
	}

	double min_temp_sub = DBL_MAX;
	double temp_sub = 0;
	double ave_temp = 0;
	int answer = 0;
	for(int j = 0; j < N; j++) {
		//  誤差を小さくするため、1000倍して演算する
		//  あと、浮動小数点として演算してほしいので、オペランドの
		//  ひとつは必ずdoubleに変換する
		ave_temp = T - ((static_cast<double>(heights[j]) * 6) / 1000);
		temp_sub = std::abs(A - ave_temp);
		if (temp_sub <= min_temp_sub) {
			min_temp_sub = temp_sub;
			answer = j + 1;
		}
	}

	std::cout << answer << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

typedef pair<int, int> P;

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(N-1));
  rep(i, N) rep(j, N-1) {
    cin >> A[i][j];
    A[i][j]--;
  }
  rep(i, N)
    reverse(A[i].begin(), A[i].end());
  vector<P> q;
  auto check = [&](int i) {
    if(!A[i].size()) return;
    int j = A[i].back();
    if(!A[j].size()) return;
    if(A[j].back() == i) {
      if(i > j)
        swap(i, j);
      q.push_back({i, j});
    }
  };
  rep(i, N)
    check(i);
  int ans = 0;
  while(q.size()) {
    ans++;
    sort(q.begin(), q.end());
    q.erase(unique(q.begin(), q.end()), q.end());
    vector<P> prev;
    swap(prev, q);
    for(P p : prev) {
      int i = p.first, j = p.second;
      A[i].pop_back();
      A[j].pop_back();
      check(i);
      check(j);
    }
  }
  rep(i, N) {
    if(A[i].size()) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4224
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
 
		Scanner sc = new Scanner(System.in);
 
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
 
		System.out.println(
				a.substring(0, 1).toUpperCase() + b.substring(0, 1).toUpperCase() + c.substring(0, 1).toUpperCase());
 
	}
}

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

template<typename T>
struct CumulativeSum2D{
    int H,W;
    vector<vector<T>> dat;
    CumulativeSum2D(vector<vector<T>> v){
        H=v.size(),W=v[0].size();
        dat.assign(H+1,vector<T>(W+1,0));
        for (int i=0;i<H;++i){
            for (int j=0;j<W;++j){
                dat[i+1][j+1]=v[i][j];
                dat[i+1][j+1]+=dat[i+1][j]+dat[i][j+1]-dat[i][j];
            }
        }
    }
    T query(int sx,int sy,int gx,int gy){ //[sx,gx),[sy,gy)
        return dat[gx][gy]-dat[sx][gy]-dat[gx][sy]+dat[sx][sy];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,K; cin >> H >> W >> K;
    vector<vector<int>> S(H,vector<int>(W));
    for (int i=0;i<H;++i){
        for (int j=0;j<W;++j){
            char c; cin >> c;
            S[i][j]=c-'0';
        }
    }
    CumulativeSum2D<int> CS(S);
    int ans=H*W;
    for (int bit=1<<H;bit<(1<<(H+1));++bit){
        if (!(bit&1)) continue;
        vector<int> order;
        for (int i=0;i<=H;++i) if (bit&1<<i){
            order.emplace_back(i);
        }
        int n=order.size(),cnt=n-2,ok=1,last=0;
        vector<int> now(n-1);
        for (int j=1;j<W+1;++j){
            int cut=0;
            for (int i=0;i<n-1;++i)
                if (K<CS.query(order[i],last,order[i+1],j)) cut=1;
            if (cut){
                ++cnt; last=j-1;
                for (int i=0;i<n-1;++i)
                    if (K<CS.query(order[i],j-1,order[i+1],j)) ok=0;
            }
        }
        if (ok) ans=min(ans,cnt);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
void ABC120(void);
void ABC121(void);
void ABC122(void);
void ABC123(void);
void ABC124(void);
void ABC125(void);
void ABC126(void);
void ABC127(void);
void ABC128(void);
void ABC129(void);

int main(void){
    ABC125();
}

void ABC125(void){
    int a,b,t;
    cin>>a>>b>>t;
    t=t/a;
    cout<<b*t<<endl;
}

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


int main() {

    int n;
    cin >> n;
    ll a = 2, b = 1;
    ll l = 0;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 1; i < n; ++i) {
        l = a + b;
        a = b;
        b = l;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int n,h,fa[440],pd[440],du[2][440];
int get(int x)
{
	return fa[x]==x?x:fa[x]=get(fa[x]);
}
int main()
{
	scanf("%d%d",&n,&h);
	for(int i=1;i<=h+h;i++) fa[i]=i;
	for(int i=1,a,b,c,d;i<=n;i++)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(c==0) du[0][h+a]++; else du[0][h-c]++;
		if(d==0) du[1][h-b]++; else du[1][h+d]++;
		fa[get(c==0?h+a:h-c)]=get(d==0?h-b:h+d);
	}
	for(int i=0;i<h;i++) 
		if(du[0][i]>du[1][i]) {puts("NO");return 0;} 
	for(int i=h+1;i<=h+h;i++)
		if(du[0][i]<du[1][i]) {puts("NO");return 0;}
	for(int i=0;i<=h+h;i++)
		if(du[0][i]!=du[1][i]||du[0][i]+du[1][i]==0) pd[get(i)]=1;
	for(int i=0;i<=h+h;i++)
		if(!pd[get(i)]) {puts("NO");return 0;}
	puts("YES"); return 0;
}

Measured memory_bytes: 3148
//saw

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  vector<string> v;
  int k,i,j;
  cin>>s>>k;
  int n=s.size();
  for(i=1;i<=k;i++)
    for(j=0;j+i<=n;j++)//sについて頭からj番目の文字からi文字分の文字列を取得してvに入れる。
      v.push_back(s.substr(j,i));//vは動的配列、尻から配列を入れる（まず一文字から回収していく。
  sort(v.begin(),v.end());//配列と違ってbeginとendを使う
  unique(v.begin(),v.end());
  cout<<v[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 1660
K, X = [int(i) for i in input().split(' ')]
min_ = -1000000
max_ = 1000000
result = []
for i in range(max(X - K + 1, min_), X):
    result.append(i)
for i in range(X, min(X + K, max_)):
    result.append(i)
print(' '.join([str(i) for i in result]))


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cities(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        cities.at(a-1) += 1;
        cities.at(b-1) += 1;
    }
    for (int i = 0; i < n; i++)
        cout << cities.at(i) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(x);
	cout << (x^1);
}



















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

int main(){
  double n,k; cin>>n>>k;
  double ans=0;

  for(int i=1;i<=n;i++){//i=サイコロの目
    double score=i;
    double p=1.0/n;
    while(score<k){
      
     score*=2.0;
     p/=2.0;
       }
    ans+=p;
  }
   printf("%.16f", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    IN(int, n);
    int t = 1;
    while (t*2<=n) {
        t*=2;
    }
    COUT(t);
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;
    if(s[s.size() - 1] == 's')s += "es";
    else s += 's';
    cout << s << endl;
}

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

int n,c,k;
int t[100001];

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

int main(){
	int i,j;
	int q,w,e,r,y;
	
	scanf("%d%d%d",&n,&c,&k);
	for(i=0;i<n;i++){
		scanf("%d",&t[i]);
	}
	
	qsort(t,n,sizeof(int),cmp);
	
	q=0;
	for(i=0;i<n;i++){
		w = 0;
		for(j=i;j<n;j++){
			if(t[j]>t[i]+k){
				break;
			}
			w++;
			if(w>c){
				break;
			}
		}
		q++;
		i=j-1;
	}
	printf("%d\n",q);
	return 0;
}

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

bool range(int x, int y, int w, int h){
  return (0 <= x and x < w) and (0 <= y and y < h);
}

int main(){
  int w, h;
  std::cin >> h >> w;
  vector<string> vs(h), ans;
  for (int i = 0; i < h; i++) std::cin >> vs[i];
  ans = vs;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int cnt = 0;
      if(vs[i][j] == '#')continue;
      for (int x = -1; x < 2; x++) {
        for (int y = -1; y < 2; y++) {
          int nx = j + x, ny = i + y;
          if(not range(nx, ny, w, h))continue;
          if(x == 0 and y == 0)continue;
          cnt += (vs[ny][nx] == '#');
        }
      }
      ans[i][j] = '0' + cnt;
    }
  }
  for (int i = 0; i < h; i++) {
    std::cout << ans[i] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int bar_num;
int bar_info[101][4];

int get_gcd(int a,int b) {
	if(a<b)return get_gcd(b,a);
	if(b<=0)return a;
	return get_gcd(b,a%b);
}

int get_weight(int id) {
	int a,b,gcd,force;
	if(id==0)return 1;
	a=get_weight(bar_info[id][2])*bar_info[id][0];
	b=get_weight(bar_info[id][3])*bar_info[id][1];
	gcd=get_gcd(a,b);
	force=a/gcd*b;
	return force/bar_info[id][0]+force/bar_info[id][1];
}

int main(void) {
	int i;
	int current;
	int found;
	while(1) {
		scanf("%d",&bar_num);
		if(bar_num==0)break;
		for(i=1;i<=bar_num;i++) {
			scanf("%d%d%d%df",
				&bar_info[i][0],&bar_info[i][1],
				&bar_info[i][2],&bar_info[i][3]);
		}
		current=-1;
		for(i=1;i<=bar_num;i++) {
			if(bar_info[i][2]==0 && bar_info[i][3]==0) {
				current=i;
				break;
			}
		}
		if(current<0)return 1;
		found=1;
		while(found) {
			found=0;
			for(i=1;i<=bar_num;i++) {
				if(bar_info[i][2]==current || bar_info[i][3]==current) {
					current=i;
					found=1;
					break;
				}
			}
		}
		printf("%d\n",get_weight(current));
	}
	return 0;
}

Measured memory_bytes: 0
lis = [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]

k=int(input())

print(lis[k-1])

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

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int r, g, b, n; cin >> r >> g >> b >> n;
	int cnt = 0;
	for (int i = 0; r * i <= n; i++) for (int j = 0; r * i + g * j <= n; j++) if ((n - r * i - g * j) % b == 0) cnt++;
	cout << cnt << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=(c/b);
  if(c%b)
    x++;
  int y=(a/d);
  if(a%d)
    y++;
  if(x<=y)
    cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 3632
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]:
        ans += 1

print(ans)


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

int main() {
 
  string S;
  cin >> S;
  
  int flag = 0;
  
  for(int i = 0; i < S.size(); i++) {
    for(int j = i + 1; j < S.size(); j++) {
      if(S[i] == S[j]) {
        flag = 1;
        break;
      }
    }
    if(flag == 1) {
      break;
    }
  }
  
  if(flag == 0) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
  
  return 0;
}

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

int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	const double PI = 2*acos(0.0);
	long double eps = 1e-6;
	long double d_ang; cin>>d_ang;
	d_ang/=180;
	d_ang *= PI;

	double angle = PI/2.0;
	double x=0.0, y=0.0;
	int ret=0;
	do{
		long double s=sin(angle);
		long double c=cos(angle);
		if(abs(s) < eps) s=0.0;
		if(abs(c) < eps) c=0.0;

		x += s;
		y += c;
		if(abs(x) < eps) x=0.0;
		if(abs(y) < eps) y=0.0;
		ret++; 
		angle -= d_ang;
	}while(x != 0.0 || y != 0.0);
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 4116
from decimal import *
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

BLOCK = '#'
ROAD = '.'


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


def main():
    H, W = MI()
    graph = [None] * H

    for i in range(H):
        graph[i] = list(S())

    dp = [[IINF] * W for i in range(H)]
    dp[0][0] = 0 if graph[0][0] == ROAD else 1

    for i in range(H):
        for j in range(W):
            for p in [(1, 0), (0, 1)]:
                ni = i + p[0]
                nj = j + p[1]
                if ni >= 0 and ni < H and nj >= 0 and nj < W:
                    cost = 0
                    if graph[i][j] == ROAD and graph[ni][nj] == BLOCK:
                        cost = dp[i][j] + 1
                    else:
                        cost = dp[i][j]
                    dp[ni][nj] = min(cost, dp[ni][nj])

    # print_matrix(dp)
    print(dp[H-1][W-1])


if __name__ == '__main__':
    main()


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

using namespace std;

const int N = 50;
const int mod = 1000000007;
int n;
struct TMatrix
{
    int f[N][N];

    TMatrix operator * (const TMatrix &h) const
    {
        TMatrix c;
        for (int i=0; i<n; i++)
        {
            for (int j=0; j<n; j++)
            {
                c.f[i][j] = 0;
                for (int k=0; k<n; k++)
                {
                    c.f[i][j] += (long long)f[i][k] * h.f[k][j] % mod;
                    c.f[i][j] %= mod;
                }
            }
        }
        return c;
    }

    int gg()
    {
        int r = 0;
        for (int i=0;i<n; i++)
        {
            for (int j=0; j<n; j++)
            {
                r = (r + f[i][j]) % mod;
            }
        }
        return r;
    }
};

TMatrix pw (TMatrix x, long long b)
{
    if (b==1)
        return x;
    TMatrix c = pw(x, b/2);
    c = c * c;
    if (b%2)
        c = c * x;
    return c;
}

int main()
{
    cin>>n; long long k; cin>> k;
    TMatrix s;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            cin >> s.f[i][j];
        }
    }
    s = pw(s, k);
    cout << s.gg();
    return 0;
}


Measured memory_bytes: 2560
n=int(input())
def f(x):
    ans=0
    while x>0:
        ans+=x%6
        x=x//6
    return ans
def g(x):
    ans=0
    while x>0:
        ans+=x%9
        x=x//9
    return ans
ans=n
for i in range(n+1):
    ans=min(ans,f(i)+g(n-i))
print(ans)


Measured memory_bytes: 9112
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <string>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <queue>

#define N 100009

using namespace std;

int a[N],cnt[2][N];
vector< pair<int,int> > odd,even;

int main(){
    int i,j,t1,t2,t3,t4,n,a1,a2,ans=1e9;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        cnt[i%2][a[i]]++;
    }
    for(i=1;i<=1e5;i++){
        if(cnt[0][i]){
            odd.push_back(make_pair(cnt[0][i],i));
        }
        if(cnt[1][i]){
            even.push_back(make_pair(cnt[1][i],i));
        }
    }
    odd.push_back(make_pair(0,1e5+1));
    even.push_back(make_pair(0,1e5+1));
    sort(odd.begin(),odd.end());
    reverse(odd.begin(),odd.end());
    sort(even.begin(),even.end());
    reverse(even.begin(),even.end());
    for(i=0;i<min((int)odd.size(),10);i++){
        for(j=0;j<min((int)even.size(),10);j++){
            if(odd[i].second==even[j].second){
                continue ;
            }
            ans=min(ans,n-odd[i].first-even[j].first);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using std::cerr;
using std::endl;

const int P = 998244353, N = 5e5 + 233;

inline int fpow(int x, int y) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}

int n, m, fac[N], inv[N], ans;

inline int binom(int x, int y) {
  if (x < y) return 0;
  return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}

int main() {
  for (int i = fac[0] = 1; i < N; ++i)
    fac[i] = 1ll * fac[i - 1] * i % P;
  inv[N - 1] = fpow(fac[N - 1], P - 2);
  for (int i = N - 1; i; --i )
    inv[i - 1] = 1ll * inv[i] * i % P;
  std::cin >> n >> m;
  if (n < m) std::swap(n, m);
  for (int i = 0; i <= m; ++i) {
    int tmp = 1ll * ((i & 1) ? P - 1 : 1) * binom(n, i) % P * binom(m, i) % P * fac[i] % P
      * fpow(m + 1, n - i) % P * fpow(n + 1, m - i) % P;
    ans = (ans + tmp) % P;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 7532
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {

  int n;
  cin >> n;

  int ans = 0;
  rep(i, n) {
    rep(j, n) {
      rep(k, n) {
        ans += 1;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int M1[] = CPUtils.readIntArray(2, in);
            int M2[] = CPUtils.readIntArray(2, in);
            if (M2[0] > M1[0])
                out.print(1);
            else
                out.print(0);
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



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

int main(){
    int x,y;
    cin>>x>>y;
    int ans=2e9;
    if(y>=x)ans=min(ans,y-x);
    x=-x;
    if(y>=x)ans=min(ans,y-x+1);
    x=-x,y=-y;
    if(y>=x)ans=min(ans,y-x+1);
    x=-x;
    if(y>=x)ans=min(ans,y-x+2);
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
import sys

n, m = map(int, input().split())

l = [int(x) for x in input().split()]

cnt = 0
for i in l:
    if float(i) < float(sum(l)*1/(4*m)):
        cnt += 1
    if cnt > len(l)-m:
        print("No")
        sys.exit()

print("Yes")



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

int main(){
    int n;
    cin >> n;
    int l[1000],r[1000];
    int R=0,L=0;
    for(int i=0;i<n;i++){
        cin >> l[i] >> r[i];
        R+=r[i];L+=l[i];
    }
    cout << R-L+n << endl;
}

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

int main(){
    int n;
    cin>>n;
    map<int,int> mp;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        mp[a]=i+1;
    }
    for(auto x:mp)cout<<x.second<<" ";
    cout<<""<<endl;
    return 0;
}

Measured memory_bytes: 5632
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    map<string,ll>m;
    ll q;cin>>q;
    while(q--){
        ll a;string key;cin>>a>>key;
        if(a==0){
            ll x;cin>>x;
            m[key]=x;
            //cout<<m[key]<<endl;
        }
        else if(a==1){
            cout<<m[key]<<endl;
        }
        else if(a==2){
                
        }
        else{
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 25904
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	a,b,c=MI()
	k=II()

	while b<=a:
		b*=2
		k-=1

	while c<=b:
		c*=2
		k-=1

	#print(a,b,c,k)

	if k>=0:
		ans="Yes"
	else:
		ans="No"

	print(ans)






if __name__ == "__main__":
	main()


Measured memory_bytes: 61928
#include<iostream>
#include<cstdio>

using namespace std;

const int maxn=2e6+5;
const int inf=(1<<31)-1;

int h,s[maxn];

void maxheapify(int i)
{
    int l,r,largest=i;
    l=2*i;
    r=2*i+1;
    if(l<=h&&s[largest]<s[l]){
        largest=l;
    }
    if(r<=h&&s[largest]<s[r]){
        largest=r;
    }
    if(largest!=i){
        swap(s[i],s[largest]);
        maxheapify(largest);
    }
}

int extract()
{
    int maxv;
    if(h<1){
        return -inf;
    }
    maxv=s[1];
    s[1]=s[h--];
    maxheapify(1);
    return maxv;
}

void increasekey(int i,int key)
{
    if(key<s[i]){
        return ;
    }
    while(i>1&&s[i/2]<s[i]){
        swap(s[i],s[i/2]);
        i=i/2;
    }
}

void insert(int key)
{
    h++;
    s[h]=key;
    increasekey(h,key);
}

int main()
{
    string com;
    int key;
    while(cin>>com){
        if(com=="end"){
            break;
        }else if(com=="extract"){
            printf("%d\n",extract());
        }else{
            scanf("%d",&key);
            insert(key);
        }
    }
    return 0;
}
/*
insert 8
insert 2
extract
insert 10
extract
insert 11
extract
extract
end
*/



Measured memory_bytes: 7084
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n;
  cin >> n;
  vi32 a(n);
  rep(i, n) cin >> a[i];
  i64 sum = 0;
  rep(i, n) sum += a[i];
  if (sum % ((i64) n * (n + 1) / 2) != 0) {
    cout << "NO" << endl;
    return 0;
  }
  i64 C = sum / ((i64) n * (n + 1) / 2);
  rep(i, n) {
    i64 D = a[(i + 1) % n] - a[i];
    if (C - D >= 0 && abs(C - D) % n == 0) continue;
    else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int isSheepSafe()
{
	int sheepNum, wolfNum;
	scanf("%d %d", &sheepNum, &wolfNum);

	if (wolfNum >= sheepNum)
	{
		return 0;
	}
	else
	{
		return 1;
	}
}

int main(int argc, const char* argv[])
{
	int sheepSafety = isSheepSafe();

	if (sheepSafety == 0)
	{
		printf("unsafe");
	}
	else
	{
		printf("safe");
	}

	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<functional>
 
#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
 
using namespace std;
 
unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
int main() {
 
  int n, cnt = 0;
  cin >> n;
 
  for (int i = 1; i<=n; i++) {
    if(digit(i) % 2 == 1)cnt++;
  }
 
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
// 101B.cpp
#include <iostream>

int main(int argc, const char * argv[]) {
    int n, sum = 0, temp;
    std::cin >> n;
    temp = n;
    while (temp) {
        sum += temp % 10;
        temp /= 10;
    }
    std::cout << (n % sum ? "No\n" : "Yes\n");
    return 0;
}


Measured memory_bytes: 256
/*
	Name: Prathamesh Shendarkar
	My Motto: IS TO NEVER GIVE UP
	My Belief: If you are not able to solve a particular question don't copy and paste a solution, 
			   no one is going to look into your account and tell you that, oh my look he has solved so many questions, 
			   remeber you are cheating on yourself, Just try to solve that question after some time or some days, 
			   or look upon a solution and check for the intiution or approach they have used, 
			   But never mug up there solution. 
			   Go for Learning don't copy plz.
*/

#include<bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define loopa(i,a,b) for( i=a;i<=b;i++)
#define loop(i,n)    for( i=0;i<n;i++)
#define pool(i,n)    for( i=n-1;i>=0;i--)
#define poop(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;

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

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

ll check_prime(ll n){
	for(ll i = 2;i<=ceil(sqrt(n));i++){
		if(n%i == 0){
			return 0;
		}
	}
	return 1;
}

bool check_princi(vector<ll> v){
	ll n = v.size();
	for(ll i = 1;i<n - 1;i++){
		if(v[i - 1] + v[i + 1] < v[i]){
			return false;
		}
	}
	return true;
}

int main(){
    fastio;
	ll n,m;
	cin >> n >> m;
	if(m >= n)
		cout << "unsafe" << "\n";
	else
		cout << "safe" << "\n";
    
}




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

class Edge{
	int from, to;
	public Edge(int from, int to) {
		super();
		this.from = from;
		this.to = to;
	}
}

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static int n, m, to[][];
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		n = fs.nextInt();
		m = fs.nextInt();
		to = new int[n][n];
		List<Edge> list = new ArrayList<>();
		for(int i=0;i<m;i++) {
			int a = fs.nextInt()-1, b = fs.nextInt()-1;
			to[a][b]=1;
			to[b][a]=1;
			list.add(new Edge(a,b));
		}
		int ans = 0;
		for(int i=0;i<m;i++) {
			int a = list.get(i).from;
			int b = list.get(i).to;
			to[a][b]=0;
			to[b][a]=0;
			if(!dfs(0,new int[n]))ans++;
			to[a][b]=1;
			to[b][a]=1;
		}
		System.out.println(ans);
	}
	static boolean dfs(int v,int visited[]) {
		visited[v]=1;
		boolean last = true;
		boolean res = false;
		for(int i=0;i<n;i++) {
			if(to[v][i]==1&&visited[i]==0) {
				last = false;
				res |= dfs(i,visited);
			}
		}
		if(last) {
			for(int i=0;i<n;i++) {
				if (visited[i]==0)return false;
			}
			return true;
		}
		return res;
	}
}


//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

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

Measured memory_bytes: 23124
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

int work (vi a)
{
    const int n = sz(a);
    if (n == 1)
    {
        assert(a[0] == 1);
        return 0;
    }

    ll sum = 0;
    int cnt = 0;
    bool was = false;
    for (int x : a)
    {
        sum += x;
        cnt += x % 2;
        was |= (x == 1);
    }

    if (was)
        return (sum - n) % 2 == 0 ? 0 : +1;

    assert(cnt > 0);
    if (cnt >= 2)
        return (sum - n) % 2 == 0 ? 0 : +1;

    int pos = -1;
    forn (i, n) if (a[i] % 2) pos = i;
    assert(pos != -1);
    if (a[pos] == 1)
        return 0;

    a[pos]--;
    int g = 0;
    forn (i, n) g = __gcd(g, a[i]);
    assert(g % 2 == 0);
    forn (i, n) a[i] /= g;
    return 1 - work(a);
}

void solve (int n)
{
    vi a(n);
    forn (i, n)
        cin >> a[i];

    int res = work(a);
    cout << (res == +1 ? "First" : "Second") << endl;
}

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

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 10112
#include <stdio.h>

#define W 0
#define G 1
#define B 2

int n, m[100][100], c[100], t, d[100], f[100];

void dfs(int u)
{
  int i;
  
  c[u] = G;
  d[u] = ++t;
  for (i = 0; i < n; i++){
    if (m[u][i] == 0)
      continue;
    if (c[i] == W)
      dfs(i);
  }
  c[u] = B;
  f[u] = ++t;
}

int main()
{
  int i, j, k, u, v;
  
  scanf("%d",&n);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      m[i][j] = 0;
  for (i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for (j = 0; j < k; j++){
      scanf("%d",&v);
      m[u-1][v-1] = 1;
    }
  }
  for (i = 0; i < n; i++)
    c[i] = W;
  t = 0;
  for (i = 0; i < n; i++)
    if (c[i] == W)
      dfs(i);
  for (i = 0; i < n; i++)
    printf("%d %d %d\n",i+1,d[i],f[i]);
    
  return 0;
}



Measured memory_bytes: 2112
N, A, B = map(int, input().split())
X = list(map(int, input().split()))

ans = 0

for n in range(N-1):
  if (X[n+1] - X[n]) * A > B:
    ans += B
  else:
    ans += (X[n+1] - X[n]) * A

print(ans)

Measured memory_bytes: 15020
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        n: usize,
        s: [char; n],
    }
    let mut set = std::collections::HashSet::new();
    for si in &s {
        set.insert(si);
    }

    if set.len() == 3 {
        println!("Three");
    } else {
        println!("Four");
    }
}


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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  int n, d; cin >> n >> d;
  cout << (n - 1) / (2*d + 1) + 1 << ende;

  return 0;
}


Measured memory_bytes: 256
require 'matrix'

def solve(line)
  a = Matrix[ [line[0].to_f, line[1].to_f], [line[3].to_f, line[4].to_f] ]
  b = Vector[line[2].to_f, line[5].to_f]
  s = a.inv * b

  return s.to_a

end

inputs = []
while (line = gets) != nil
  inputs.push(line.split())
end

for i in inputs
  s = solve(i)
  puts printf("%#0.3f %#0.3f", s[0], s[1])
end

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int isprime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0 && (i % 7 == 1 || i % 7 == 6) && (n / i % 7 == 1 || n / i % 7 == 6)) {
            return false;
        }
    }
    return true;
}

int toint(string s) {
    string b;
    copy_if(all(s), back_inserter(b), [](char c) { return c != ':'; });
    return stoi(b);
}

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    const int dir[6][2] = {{1, 1}, {1, 0}, {0, -1}, {-1, -1}, {-1, 0}, {0, 1}};

    int n; cin >> n;

    vector<int> v(100003), ps(100003);

    rep(i, 0, n) {
        int lo, hi; cin >> lo >> hi;
        ++v[--lo], --v[hi];
    }

    partial_sum(all(v), ps.begin());

    int ans = 0;
    rep(i, 1, 100001)
    if (ps[i] >= i)
        ans = i;
    cout << ans << endl;
}



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

using namespace std;

int main(void){
    
    //nはスイッチの個数 mは電球の個数
    int n, m;
    cin >> n >> m; 
    
    vector<vector<int>> s(m, vector<int>(n+1));
    vector<int> p(m), k(m);
    
    for(int i = 0; i < m; i++){
        cin >> k[i]; //電球iは ki個のスイッチにつながっている
        
        //電球iがつながっているスイッチについての情報
        for(int j = 0; j < k[i]; j++){
            cin >> s[i][j];
            s[i][j]--; //0-indexのためデクリメントしておくこと
        }
    }
    
    for (int i = 0; i < m; i++) cin >> p[i]; //電球iにつながるonのスイッチの個数（mod 2)
    
    int ans = 0;
    
    //スイッチのONOFFを全通り試す
    //右からi番目のビットが１であることと, スイッチiがONであることを同一視する.
    for(int bit = 0; bit < (1 << n); bit++){
        
        //最初は, 今回の試行が条件を満たすと仮定しておく
        int ok = 1;
        
        //電球iについて, つながっているONスイッチの個数　% 2 == p[i]かどうかを調べる
        for(int i = 0; i < m; i++){
            int swi = 0;
            
            for(int j = 0; j < k[i]; j++){
                if(bit & (1<<s[i][j])) swi++; //bitが立っていれば, switchONと考える. 
            }
            if(swi % 2!= p[i]) ok = 0; //つながっているONスイッチの個数が条件を満たさない
        }
        
        if (ok) ans++; //条件を満たすスイッチのONOFFを１通り発見した
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#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 <functional>
#include <numeric>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int e, f;

	e = (C + B - 1) / B;
	f = (A + D - 1) / D;

	if (e <= f) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    while(cin >> n, n){

        vector<int> p(n);
        rep(i, n){
            p[i] = i;
        }

        vector<string> f(n);
        vector<lint> w(n), s(n);
        rep(i, n){
            cin >> f[i] >> w[i] >> s[i];
        }

        vector<int> ans;
        lint mini = 1000000000000LL;

        do{

            bool flag = true;
            lint g = 0, cnt = 0;

            rep(i, n){
                flag &= cnt <= s[p[i]];
                cnt += w[p[i]];
                g += (lint)(n - i) * w[p[i]];
            }

            if(flag && mini > g){
                ans = p;
                mini = g;
            }

        }while(next_permutation(p.begin(), p.end()));

        repr(i, n){
            cout << f[ans[i]] << endl;
        }

    }

    return 0;
}


Measured memory_bytes: 3172