akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        vector<int> v;
        rep(i,n){
            int inp;
            cin >> inp;
            v.pb(inp);
        }
        sort(all(v));
        int result = 0;
        rep(i,v.size()){
            range(j,i,v.size()){
                result+=v[i];
            }
        }
        cout << result << endl;
    }
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(0)!='A'){
    cout << "WA" << endl;
    return 0;
  }
  bool flag=false;
  int c;
  for(int i=2;i<S.size()-1;i++){
    if(S.at(i)=='C'){
      if(!flag){
        flag=true;
        c=i;
      }else{
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  if(!flag){
    cout << "WA" << endl;
    return 0;
  }
  for(int i=1;i<S.size();i++){
    if(i==c){
      continue;
    }
    if(!((S.at(i)>='a')&&(S.at(i)<='z'))){
      cout << "WA" << endl;
      return 0;
    }
  }
  cout << "AC" << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    x=a[2]-a[0]
    y=a[3]-a[1]

    print(str(a[2]-y)+" "+ str(a[3]+x)+" "+str(a[0]-y)+" "+str(a[1]+x)+" ")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  vector<lint> S(N+1);
  REP(i, N) S[i+1] = S[i] + A[i];
  lint ans = 1e15;
  FOR(i, 2, N-1) {
    int l = 0;
    int r = i;
    while(r-l > 1) {
      int m = (l+r) / 2;
      if(S[m] >= S[i] - S[m]) {
        r = m;
      } else {
        l = m;
      }
    }
    lint ma = S[r];
    lint mi = S[i] - S[r]; 
    if(r != 0 && S[i]-S[r-1]*2 < ma - mi ) {
      ma = S[i] - S[r-1];
      mi = S[r-1];
    }

    l = i;
    r = N;
    while(r-l > 1) {
      int m = (l+r) / 2;
      if(S[m] - S[i] >= S[N] - S[m]) {
        r = m;
      } else {
        l = m;
      }
    }
    if(S[N] - 2*S[r-1] + S[i] < 2*S[r] - S[i] - S[N]) {
      r--;
    }
    ma = max(max(ma, S[r] - S[i]), S[N] - S[r]);
    mi = min(min(mi, S[r] - S[i]), S[N] - S[r]);

    if(ma-mi < ans) ans = ma-mi;
    
  }
  cout << ans << endl;
}

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

#define int long long

int32_t main ()
{
    int a, b, c;
    cin>>a>>b>>c;
    int cc=1;
    while(cc<90000000) {
        if((a*cc)%b == c) {
            cout<<"YES"<<endl;
            return 0;
        }
        cc++;
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	map<char, ll>mp;
	rep(i, 0, N) {
		string s; cin >> s;
		mp[s[0]]++;
	}
	ll ans = 0;
	char ch[] = { 'M','A','R','C','H' };
	rep(i, 0, 5) {
		if (!mp.count(ch[i]))continue;
		rep(j, i + 1, 5) {
			if (!mp.count(ch[j]))continue;
			rep(k, j + 1, 5) {
				if (!mp.count(ch[k]))continue;
				ans += mp[ch[i]] * mp[ch[j]] * mp[ch[k]];
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] S = Console.ReadLine().ToCharArray();
            

            bool kisu = true;
            bool gusu = true;
            



            for (int i= 0; i < S.Length; i++)
            {
                if (i % 2 == 1)
                {
                    if (S[i] == 'R')
                    {
                        kisu = false;
                        //Console.WriteLine("Un_Ok");
                        break;
                    }
                    else
                    {
                        //Console.WriteLine("Ok");
                    }
                }
                else
                {
                    if (S[i] == 'L')
                    {
                        gusu = false;
                        //Console.WriteLine("Un_Ok");
                        break;
                    }
                    else
                    {
                       // Console.WriteLine("Ok");
                    }
                }
            }

            if(kisu == true && gusu == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");

            }

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF 1e18
//#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

int w, h;
char r1[60][60], r2[60][60];
int dx[] = {1, 0, -1, 0}, dy1[] = {0, -1, 0, 1}, dy2[] = {0, 1, 0, -1};
bool vis[51][51][51][51];

bool in(int x, int y) { return 0 <= x && x < h && 0 <= y && y < w; }
bool solve(int X1, int Y1, int X2, int Y2)
{
    typedef pair<P, P> PP;
    queue<PP> que;
    que.push(PP(P(X1, Y1), P(X2, Y2)));
    vis[X1][Y1][X2][Y2] = true;
    while (!que.empty())
    {
        PP pp = que.front();
        que.pop();
        P L = pp.first, R = pp.second;
        int x1 = L.first, y1 = L.second, x2 = R.first, y2 = R.second;
        rep(i, 4)
        {
            int nx1 = x1 + dx[i], ny1 = y1 + dy1[i];
            int nx2 = x2 + dx[i], ny2 = y2 + dy2[i];
            if (!in(nx1, ny1) || r1[nx1][ny1] == '#')
                nx1 = x1, ny1 = y1;
            if (!in(nx2, ny2) || r2[nx2][ny2] == '#')
                nx2 = x2, ny2 = y2;
            if (r1[nx1][ny1] == '%' && r2[nx2][ny2] == '%')
                return true;
            if (r1[nx1][ny1] == '%' || r2[nx2][ny2] == '%')
                continue;
            if (vis[nx1][ny1][nx2][ny2])
                continue;
            vis[nx1][ny1][nx2][ny2] = true;
            que.push(PP(P(nx1, ny1), P(nx2, ny2)));
        }
    }
    return false;
}

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

    while (1)
    {
        cin >> w >> h;
        if (w == 0)
            break;
        rep(i, h)
        {
            rep(j, w) cin >> r1[i][j];
            rep(j, w) cin >> r2[i][j];
        }
        rep(i, h) rep(j, w) rep(k, h) rep(l, w) vis[i][j][k][l] = false;
        int lx, ly, rx, ry;
        rep(i, h) rep(j, w) if (r1[i][j] == 'L') lx = i, ly = j;
        rep(i, h) rep(j, w) if (r2[i][j] == 'R') rx = i, ry = j;
        cout << (solve(lx, ly, rx, ry) ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 10440
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define INF 1010101010
#define MOD 1000000007

int N, K;

int main() {
    char c;
    cin >> c;
    for (const char &v: "aiueo") 
        if (c == v) {
            cout << "vowel" << endl;
            return 0;
        }
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABN = GetInput_long();
            var _A = ABN[0];
            var _B = ABN[1];
            var _maxNum = ABN[2];
            
            long max = 0;
            long x = 0;
            long rate = 0;
            if (_B == 1)
            {
                Console.WriteLine(max);
                return;
            }
            while (x<=_maxNum)
            {
                var floor =(_A*x)/_B-_A*(x/_B);
                if (max < floor)
                {
                    max = floor;
                }
                rate++;
                var next = _B * rate - 1;
                if (next <= _maxNum) x = next;
                else
                {
                    if (x == _maxNum) break;
                    x = _maxNum;
                }
            }
            Console.WriteLine(max);
        }
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion

        static long mod = 1000000000 + 7;
    }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[111111][2];

void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

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

	string str;cin >> str;
	dp[0][0] = 1;

	REP(i, str.size()) {
		if(str[i] == '1'){
			mod_add(dp[i+1][1], dp[i][0]);
			mod_add(dp[i+1][0], dp[i][0] * 2);
			mod_add(dp[i+1][1], dp[i][1] * 3);
		}
		else {
			mod_add(dp[i+1][0], dp[i][0]);
			mod_add(dp[i+1][1], dp[i][1] * 3);
		}
	}

	cout << (dp[str.size()][1] + dp[str.size()][0]) % MOD << endl;

	return 0;
}


Measured memory_bytes: 2000
package main

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

func main() {
	s, t := readR(), readR()

	// dp[i][j] = sをi文字目、tをj文字目まで使用した際の最大の部分列長
	dp := make([][]int, len(s)+1)
	for i := 0; i <= len(s); i++ {
		dp[i] = make([]int, len(t)+1)
	}

	for i := 1; i <= len(s); i++ {
		for j := 1; j <= len(t); j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1])
			}
		}
	}

	cnt := dp[len(s)][len(t)]
	ans := make([]rune, cnt)
	for i, j := len(s), len(t); cnt >= 0 && i > 0 && j > 0; {
		if dp[i][j] == dp[i-1][j] {
			i--
		} else if dp[i][j] == dp[i][j-1] {
			j--
		} else {
			ans[cnt-1] = s[i-1]
			cnt--
			i--
			j--
		}
	}
	fmt.Println(string(ans))
}

func max(a ...int) int {
	m := a[0]
	for i := 1; i < len(a); i++ {
		if m < a[i] {
			m = a[i]
		}
	}
	return m
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


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

using namespace std;

const int maxn = 5e5 + 5;
int n, q, a[maxn], c[maxn], last[maxn], ans[maxn];
struct Query
{
    int l, r, id;
    bool operator < (const Query& q1) const {return r < q1.r;}
} que[maxn];
inline int lowbit(int x) {return x & -x;}
void update(int k, int v)
{
    for(int i = k; i <= n; i += lowbit(i)) c[i] += v;
}
int query(int k)
{
    int res = 0;
    for(int i = k; i; i -= lowbit(i)) res += c[i];
    return res;
}
void move(int k)
{
    if(last[a[k]]) update(last[a[k]], -1);
    update(k, 1);
    last[a[k]] = k;
}
int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for(int i = 0; i < q; ++i)
    {
        scanf("%d%d", &que[i].l, &que[i].r);
        que[i].id = i;
    }
    sort(que, que + q);
    for(int i = 1; i <= que[0].r; ++i) move(i);
    for(int i = 0; i < q; ++i)
    {
        int l = que[i].l, r = que[i].r;
        ans[ que[i].id ] = query(r) - query(l - 1);
        if(i == q - 1) break;
        for(int j = que[i].r + 1; j <= que[i + 1].r; ++j) move(j);
    }
    for(int i = 0; i < q; ++i) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 17412
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        List<int> A = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();

        int count = 0;
        while (!A.Any(o => o % 2 == 1))
        {
            A = A.Select(o => o / 2).ToList();
            count++;
        }

        Console.WriteLine(count);
    }
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy" << '\n';
	else if (s == "Rainy") cout << "Sunny" << '\n';
	else cout << "Rainy" << '\n';
	return 0;
}

Measured memory_bytes: 3580
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = []
for i in range(n):
    lst1.append([int(readline()),i])

lst2 = sorted(lst1)
eo = [0]*2

for i,(j,k) in enumerate(lst2):
    if even(i):
        if not even(k):
            eo[0] += 1
    else:
        if even(k):
            eo[1] += 1



print(min(eo[0],eo[1])+abs(eo[1]-eo[0]))



Measured memory_bytes: 86732
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int n; cin>>n;
  int h[101];
  int i,j,k;
  for(i=0;i<n;i++){
    cin>>h[i];
  }

  int ans=0;
  int tmp=0;

  for(i=0;i<n;i++){
    if(h[i]>=tmp) ans++;
    tmp=max(h[i],tmp);
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*;
import java.math.BigDecimal;
import java.math.RoundingMode;

class Main{
	public static void main(String[] args){
      Scanner scn = new Scanner(System.in);
      int l = scn.nextInt();
      double third = (double)l/3;
      BigDecimal bd = new BigDecimal(third*third*third);
      System.out.println(bd.setScale(12, RoundingMode.HALF_UP));
	}
}

Measured memory_bytes: 21716
N=int(input())
A=list(map(int,input().split()))

def check():
    balls = [None] * N  # 0 or 1
    for i in range(N-1,-1,-1):
        k = i+1
        if 2*k > N:
            balls[i] = A[i]
            continue
        r = 0
        for j in range(2*k-1,N,k):
            r = (r + balls[j]) & 1
        balls[i] = r ^ A[i]
    return [i+1 for i, b in enumerate(balls) if b]

c = check()
if c is None:
    print(-1)
else:
    print(len(c))
    if c:
        print(*c)

Measured memory_bytes: 12724
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define BIG 100000000

ll  lcm(ll a,ll b)
{
    ll GCD=__gcd(a,b);
    ll lcm=(a*b)/GCD;
    return lcm;
}
ll dp[1000005];
ll weight[1000005];
ll total,val;
int main()
{
    cin>>total>>val;
     weight[0]=1e9;
    for ( int i = 1; i <=total; i++ )
        cin>>weight[i];


    for(int i=2;i<=total;i++)
    {
        dp[i]=1e18;
        for(int j=1;j<=val;j++)
            if(i-j>=1)
            dp[i]=min(dp[i],abs(weight[i]-weight[i-j])+dp[i-j]);

    }
    cout<<dp[total]<<endl;
    return 0;
}



Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> conn(n);
  REP(i, m) {
    int k;
    cin >> k;
    REP(j, k) {
      int s;
      cin >> s;
      s--;
      conn[s].push_back(i);
    }
  }
  vector<int> p(m);
  REP(i, m) { cin >> p[i]; }

  i64 ans = 0;
  const int L = 1LL << n;
  REP(state, L) {
    vector<int> lamp = p;
    REP(i, n) {
      if (state & (1 << i)) {
        for (int k : conn[i]) {
          lamp[k] ^= 1;
        }
      }
    }
    int num_on = 0;
    REP(i, m) {
      if (lamp[i] == 0) ++num_on;
    }
    if (num_on == m) {
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3544
#include<iostream>

using namespace std;

int main(){
    char c[5]={0};
    cin>>c;
    int T=5,f=0;
    while(T--){
        if(c[T]=='7'){
            f=1;
            break;
        }
    }
    if(f) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

int zet(int x){
  if(x>=0){
    return x;
  }
  else{
    return -x;
  }
}
  
int main() {
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  
  int sum=0;
  vector<int> b(n);
  for(int j=0;j<n;j++){
    sum+=v[j];
    b[j]=sum;
  }
  
  //bはちゃんと動いてる
      
  vector<int> a(n);
  for(int k=0;k<n;k++){
    a[k]=zet(sum-b[k]*2);
  }
  
  sort(a.begin(),a.end());
  
  cout << a[0];
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[11];
int main(void) {
    while(~scanf("%s", s)) {
        if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') puts("Yes");
        else puts("No");
    }
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
sum = 1
t = 0
for i in range(1,n):
    t = 0
    for j in range(0,i):
        if h[j] <= h[i]:
            t += 1
        else:
            t += 0
    if t == i:
        sum += 1
    else:
        sum += 0

print(sum)


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int a, b, c;
    char op;
    scanf("%d %c %d", &a, &op,&b);
    
    while(op != '?'){
        if(op == '+'){
            c = a + b;
        }
        else if(op == '-'){
            c = a - b;
        }
        else if(op == '/'){
            c = a / b;
        }
        else if(op == '*'){
            c = a * b;
        }
        printf("%d\n", c);
        scanf("%d %c %d", &a, &op,&b);
    }
}


Measured memory_bytes: 2040
#include <iostream>
#include <vector>
using namespace std;
template<class T>inline bool chmax(T& a,T b){
 if(a<b){a=b; return true;} return false;
}

int N,M;
vector<vector<int>> G;

int dp[100100];
int rec(int v){
	if(dp[v]!=-1)return dp[v];//already updated
	int res=0;
	for (auto nv:G[v]){
		chmax(res,rec(nv)+1);
	}
	return dp[v]=res;//memo and return
}

int main(){
	cin>>N>>M;
	G.assign(N,vector<int>());
	for (int i=0;i<M;++i){
		int x,y;cin>>x>>y;
		--x,--y;//0-index
		G[x].push_back(y);
	}

	for (int v=0;v<N;++v)dp[v]=-1;

	int res=0;
	for(int v=0;v<N;++v)chmax(res,rec(v));
	cout<<res<<endl;
}

Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip> 
using namespace std;
 
int main() {
	int n;
	cin>>n;
	int a[200001],b[200001];
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	if(n%2==1){
		cout<<b[(n+1)/2]-a[(n+1)/2]+1<<endl;
	}
	else cout<<b[n/2]+b[n/2+1]-a[n/2]-a[n/2+1]+1<<endl;
	
  return 0;
}



Measured memory_bytes: 5112
#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
  int i=0;
  int x=0,y=0;
  int sum=0;

  while(scanf("%d %d",&x, &y)!=EOF)
    {
      sum=x+y;
      i=1;
      while(sum>=10)
        {
          sum/=10;
          i++;
	}

      printf("%d\n", i);
    }
}

Measured memory_bytes: 1188
N, K, Q = map(int, input().split())

point = [K]*N
A = [0]*Q

for i in range(Q):
    A[i] = int(input())
    point[A[i]-1] += 1

for p in point:
    p -= Q
    if p > 0:
        print("Yes")
    else:
        print("No")


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(),a.end());
  int ans = 0;
  for(int i=0; i<N; i++){
    if(i%2==0) ans+=a.at(i);
    else ans-=a.at(i);
  }
  cout << ans << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main(){
  int n;
  cin >> n;
  if(n <= 999)cout << "ABC" << endl;
  else cout << "ABD" << endl;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;

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;
}

const int MAX_N = 100000;

int main(void) {
    int n, k;
    char s[MAX_N + 2];
    char prev;
    int current_happy = 0;
    int count = 0;

    cin >> n >> k >> s;

    prev = s[0]; 
    for (int i = 1; i < n; i++) {
        if (s[i] != prev) {
            count++;
            prev = s[i];
        } else {
            current_happy++;
        }
    }
    count++;

    // printf("count: %d, current_happy: %d\n", count, current_happy);

    cout << min(n - 1, current_happy + 2 * min(k, (count / 2))) << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n;

const int INF = 1 << 29;
int a, b, c;
vector<int> cal;
int main(void)
{
	while(cin >> n && n)
	{
		cin >> a >> b >> c;
		cal.resize(n);
		for (int i = 0; i < n; i++)
		{
			cin >> cal[i];
		}
		sort(cal.begin(), cal.end(), greater<int>());
		
		double pc = (double)a / (double)c;
		int anscal = c;
		int money = a;
		for (int i = 0; i < n; i++)
		{
			int tmpcal = anscal + cal[i];
			double tcp = (double)tmpcal / (double)(money + b);
			if(pc < tcp)
			{
				pc = tcp;
				anscal = tmpcal;
				money += b;
			}
		}

		cout << (int)pc << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		long result = 0;
		int MOD = 1000000007; 
		Prime p = new Prime(1000000);
		HashMap<Integer, Integer> mapAll = new HashMap<Integer, Integer>();
		for(int i = 0; i < n; i++){
		    HashMap<Integer, Integer> map = p.factorization(a[i]);
		    for(Integer key : map.keySet()){
		        mapAll.put(key, max(mapAll.getOrDefault(key, 0), map.get(key)));
		    }
		}
		//System.out.println(mapAll.toString());
		long lcm = 1;
		for(Integer key : mapAll.keySet()){
		    lcm *= pow(key, mapAll.get(key), MOD);
		    lcm %= MOD;
		}
		
		for(int i = 0; i < n; i++){
		    result += lcm*inv(a[i], MOD);
		    result %= MOD;
		}
		
		// 出力
		System.out.println(result);
	}

	public static long pow(long a, long n, long MOD) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a)%MOD;
	        }
	        a=(a*a)%MOD;
	        n>>=1;
	    }
	    return res%MOD;
	}

	public static long inv(long a, long MOD) {
	    return pow(a, MOD - 2, MOD);
	}
	
}

class Prime {
    int n;
    ArrayList<Integer> primes;
    int[] seive;
    
    public Prime(int n){
        this.n = n;
        int[] seive = new int[n+1];
        Arrays.fill(seive, -1);
        ArrayList<Integer> primes = new ArrayList<Integer>();
        for(int i = 2; i <= n; i++){
            if(seive[i] != -1) continue;
            primes.add(i);
            seive[i] = i;
            for(long j = (long)i*i; j <= n; j += i){
                if(seive[(int)j] == -1) seive[(int)j] = i; 
            }
        }
        this.seive = seive;
        this.primes = primes;
    }
    
    public boolean isPrime(int x){
        return seive[x] == x;
    }
    
    public HashMap<Integer, Integer> factorization(int x){
        HashMap<Integer, Integer> factorization = new HashMap<Integer, Integer>();
        ArrayList<Integer> factorList = factorList(x);
        if(factorList.size() == 0) return factorization;
        for(Integer i : factorList){
            int cnt = factorization.getOrDefault(i, 0);
            factorization.put(i, cnt + 1);
        }
        return factorization;
    }
    
    private ArrayList<Integer> factorList(int x){
        ArrayList<Integer> factorList = new ArrayList<Integer>();
        while(x != 1){
            factorList.add(seive[x]);
            x /= seive[x];
        }
        return factorList;
    }
    
}



Measured memory_bytes: 46560
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int d[102];
	int n;
	int f;
	int f2;
	int diff;
	int before;
	while(cin>>n,n){
		for(int i=1;i<=n+1;i++)cin>>d[i];
		for(int i=1;i<=n+1;i++){
			before=-1;
			f=1;
			f2=1;
			for(int j=1;j<=n+1;j++){
				if(j!=i){
					if(before==-1)before=d[j];
					else if(f2){
						f2=0;
						diff=d[j]-before;
						before=d[j];
					}
					else{
						if(diff!=d[j]-before)f=0;
						before=d[j];
					}
				}
			}
			if(f){
				cout<<d[i]<<endl;
				i+=200;
			}
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N,M;
 cin >> N >> M;
 int S =0;
 vector<int> a(N);  
for(int i=0; i<N; i++){
    cin >> a[i] ;
    S += a[i];
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
int D = S;
S /= 4*M;
if(D%(4*M) == 0){
if(a[M-1] < S){
 cout << "No" << endl;
}
else {
  cout << "Yes" << endl;
}
}
else{ 
if(a[M-1] <= S){
 cout << "No" << endl;
}
else {
  cout << "Yes" << endl;
}
}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		ArrayList<Integer> al = new ArrayList<Integer>();
		int s = Integer.parseInt(sc.next());
		int yono = 1;
		while(!al.contains(s)){
			al.add(s);
			yono++;
			if(s % 2 == 0) s /= 2;
			else s = 3 * s + 1;
		}
		ou.println(yono);
		ou.flush();
	}
}

Measured memory_bytes: 35720
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;


     signed main(){
         cout << std::fixed << std::setprecision(15);
int x,y;
cin>>x>>y;
if(abs(x-y)<=1)cout<<"Brown"<<endl;
else cout<<"Alice"<<endl;
     }

 


 






    





      

        


Measured memory_bytes: 256
N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=0
if 2*N<=K:
    for i in V:
        if i>=0:
            ans+=i
else:
    for a in range(min(N,K)+1):
        for b in range(min(N,K)+1-a):
            v=[]
            value=sum(V[:a])
            v.extend(V[:a])
            if b!=0:
                value=value+sum(V[-b:])
                v.extend(V[-b:])
            v.sort()
            for i in range(min(a+b,min(N,K)-a-b)):
                if v[i]<0:
                    value=value-v[i]
                else:
                    break
            ans=max(ans,value)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
#define int long long
#define vbe(sdk) sdk.begin(), sdk.end()
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; ++i)
#define rloop(i, a, b) for (int i = a; i >= b; --i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int>>
#define vll vector<int>
#define mint map<int, int>
#define arry(x) (int)x.size()
#define sll set<int>
#define pll pair<int, int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;
const int MAX = 100001;


void solve()
{
        int n;
        cin>>n;
        if(n>=30)
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
        
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif


    int t = 1;
    //    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

struct UnionFind {
	vector<int> par, siz;
	UnionFind(int n): par(n), siz(n,1) {
		rep(i,n) par[i] = i;
	}
	int find(int x) {
		return par[x] == x ? x: par[x] = find(par[x]);
	}
	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return false;
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return siz[find(x)];
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i,m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}

	int ans = 0;
	rep(i,m) {
		UnionFind uf(n);
		rep(j,m) {
			if (i == j) continue;
			uf.unite(a[j], b[j]);
		}
		if (uf.size(a[i]) != n || uf.size(b[i]) != n) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int fact_arr[100000];
int fact(int n){
    if(fact_arr[n]!=0)
        return fact_arr[n];
    if(n==0)
        return fact_arr[n]=1;
    return fact_arr[n]=fact(n-1)*n%mod;
}
int pow(int x,int n){
    int ret=1;
    while(n){
        if(n&1)
            (ret*=x)%=mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return ret;
}
int inv(int n){
    return pow(n,mod-2);
}
signed main(){
    int n,x[100000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x[i];
    int arr[99999];
    for(int i=0;i<n-1;i++)
        arr[i]=fact(n-1)*inv(i+1)%mod;
    for(int i=1;i<n-1;i++)
        (arr[i]+=arr[i-1])%=mod;
    int ans=0;
    for(int i=0;i<n-1;i++)
        (ans+=(x[i+1]-x[i])*arr[i])%=mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 4732
//package ac144;
import java.lang.*;
import java.math.*;
import java.util.Scanner;
import java.io.*;
public class Main {
	static Scanner scn = new Scanner(System.in);
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int x= scn.nextInt();
		boolean flag = false;
		for(int i =1;i<=9;i++) {
			if(x%i==0) {
				int on = x/i;
				if(on<=9&&on>=1) {
					flag = true;
				}
			}
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int N;
set<int> st;
int main(){
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		int d;
		scanf("%d", &d);
		st.insert(d);
	}
	printf("%d\n", (int)st.size());
	return 0;
}

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

int main(){
    int n, x, i, res = 0, max, temp1 = 0, temp2 = 0;

    cin >> x >> n;

    int a[n];

    if(n > 0){
        for(i = 0; i < n; i++){
            cin >> a[i];
        }
        sort(a, a + n);

        max = *max_element(a, a + n);
        res = 0;

        for(i = 1; i <= max + 1; i++){
            if(!(binary_search(a, a + n, i))){
                temp1 = abs(i - x);
                temp2 = abs(x - res);
                if(temp2 > temp1){
                    res = i;
                }
            }
        }
    }
    else{
        res = x;
    }

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

Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
typedef long long LL;
string a,b;
string z;
LL gcd(LL a,LL b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
int main()
{
    LL n,m;
    cin >> n>>m;
    cin >> a;
    cin >>b;
    if(a.length()<b.length())
    {
        z=a;
        a=b;
        b=z;
        int zz=n;
        n=m;
        m=zz;
    }
    if(n%m ==0)
    {
        int z=n/m;
        int i;
        for(i=0;i<b.length();i++)
            if(b[i]!=a[i*z])
                break;
        if(i!=b.length())
            cout<<-1<<endl; 
        else
            cout<<n<<endl;
    }
    else
    {
        LL gyz=gcd(n,m);
        LL sum=n*m/gyz;
	        LL a1=sum/n;
	        LL a2=sum/m;
			int star1=0;
			int star2=0;
			while(star1<a.length())
			{
			//	cout <<star1<<star2<<a[star1]<<b[star2]<<endl;
				if(a[star1]!=b[star2])
					break;
				star1+=a2;
				star2+=a1;
			} 
			if(star1>=a.length())
				cout<<sum<<endl;
			else
				cout<< -1<<endl; 
    }
    return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
if M % 2 == 1:
  print(-1)
  exit()
  
E = []
A = [[] for _ in range(N)]
for _ in range(M):
  i, j = map(int, input().split())
  E.append([i-1, j-1])
  A[i-1].append(j-1)
  A[j-1].append(i-1)

tree = [[] for _ in range(N)]
visited = [False] * N
queue = [0]
visited[0] = True
while queue:
  i = queue.pop()
  for j in A[i]:
    if not visited[j]:
      tree[i].append(j)
      tree[j].append(i)
      visited[j] = True
      queue.append(j)

D = [0] * N
for i, j in E:
  if i not in tree[j]:
    print(i+1, j+1)
    D[i] += 1

def f(parent, i):
  for j in tree[i]:
    if j == parent:
      continue
    f(i, j)
    if D[j] % 2 == 0:
      print(i+1, j+1)
      D[i] += 1
    else:
      print(j+1, i+1)
      D[j] += 1
  return

f(0, 0)


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

int main() {
	int digit, a, b, num, i;
	cin >> a >> b;
	digit = log10(b) + 1;
	num = b + a * pow(10, digit);
	for (i = 1; i <= 316; ++i) {
		if (num == i * i) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

  int a, b;
  for (a = 0;; ++a)
    for (b = -a; b < a; ++b)
      if (pow(a, 5) - pow(b, 5) == x)
        goto fin;

fin:
  cout << a << " " << b << endl;
}

Measured memory_bytes: 4096
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
        String[] array = br.readLine().split(" ");
        String str=array[N-1];
        for(int i=N-2;i>-1;i--) str+=" "+array[i];
        System.out.println(str);
	}
}

Measured memory_bytes: 17068
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=1e5+1;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define sclli(x) scanf("%lld",&x);
#define pii pair<int,int>
#define plli pair<long long int ,lont long int>
#define foit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr);
#define sz(x) x.size()

int main()
{
    
    fast
    int n;
    cin>>n;
    int arr[3][n],dp[3][n];
    fo(i,0,n)
    {cin>>arr[0][i]>>arr[1][i]>>arr[2][i];}
    dp[0][0]=arr[0][0];
    dp[1][0]=arr[1][0];
    dp[2][0]=arr[2][0];
    fo(i,1,n)
    {
        fo(j,0,3)
        {
            dp[j][i]=0;
            fo(k,0,3)
            {
                if(j!=k)
                dp[j][i]=max(dp[j][i],dp[k][i-1]+arr[j][i]);
            }
        }
    }
    cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}

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

namespace AtCoder
{
    class Program
    {
        static long n;

        static void Main(string[] args)
        {
            n = long.Parse(Console.ReadLine());
            long ans = n * (n - 1) / 2;
            //for (int i = 1; i < n; i++) {
            //    ans += i % (i + 1);
            //}
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
n = int(input())
a = list(map(int, input().split()))

a = sorted([aa-i for i, aa in enumerate(a, start = 1)])
med = (a[n//2-1]+a[n//2])//2 if n%2 == 0 else a[n//2]
ans = sum([abs(aa - med) for aa in a])
print(ans)


Measured memory_bytes: 25196
//
//AtCoder Beginner Contest 111
//C
//https://atcoder.jp/contests/abc111/tasks/arc103_a
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<pair<int,int>> vOddCnt(100010);
    vector<pair<int,int>> vEvenCnt(100010);

    REP(i,n){
        int v;
        cin >> v;
        if (i%2==0) {
            vOddCnt[v].first++;
            vOddCnt[v].second=v;
        }else {
            vEvenCnt[v].first++;
            vEvenCnt[v].second=v;
        }
    }
    sort(RALL(vOddCnt));
    sort(RALL(vEvenCnt));

    int ans=0;
    if (vOddCnt[0].second == vEvenCnt[0].second){
        int a1 = (n/2 - vOddCnt[0].first) + (n/2 - vEvenCnt[1].first);
        int a2 = (n/2 - vOddCnt[1].first) + (n/2 - vEvenCnt[0].first);
        ans = min(a1, a2);
    }else{
        ans += n/2 - vOddCnt[0].first;
        ans += n/2 - vEvenCnt[0].first;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4824
a = input()
b = list(a)
c = list(a[::-1])
if b == c:
    print(0)
else:
    d = len(a)
    count = 0
    for i in range(0,d):
        if b[i] != c[i]:
            count += 1
        else:
            pass
    print(int(count/2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(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 INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
vector<T> make_vec(size_t a) { return vector<T>(a, INF); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

signed main() {
    INIT;
    cin >> N;
    vi a(N);
    cin >> a;
    sort(ALL(a));
    UNIQUE(a);
    ans = a.size();
    if (ans % 2 == 0)
        ans--;
    cout << ans << endl;
}

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

#define lint long long

#define Pair pair<string, int>;
const int INF = 1E9;

int main(){
    int N;
    cin >> N;
    
    vector<string> S(N);
    vector<int> P(N);
    
    for(int i = 0; i < N; ++i){
        cin >> S[i] >> P[i];
    }
    
    vector<pair<pair<string, int>, int>> List(N);
    
    for(int i = 0; i < N; ++i){
        List[i] = make_pair(make_pair(S[i], -P[i]), i + 1);
    }
    
    sort(List.begin(), List.end());
    
    for(auto e : List){
        cout << e.second << endl;
    }
    
}



Measured memory_bytes: 256
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int n;
int a[101];

//何項目,今の値,かな...
//

long long dp[103][23];

long long dfs(int _a,int _b) {

    if(_a==n-1) {
        if(_b == a[n-1]) {
            return 1;
        }
        else {
            return 0;
        }
    }
    if(dp[_a][_b]!=-1) return dp[_a][_b];

    long long res = 0;

    if(a[_a]+_b<=20) {
        res+=dfs(_a+1,a[_a]+_b);
    }
    if(0<=_b - a[_a]) {
        res += dfs(_a+1,_b-a[_a]);
    }

    return dp[_a][_b]=res;

}

int main()
{
    cin>>n;
    rep(i,n) cin>>a[i];
    rep(i,103) rep(j,23) dp[i][j]=-1;

    cout<<dfs(1,a[0])<<endl;


    return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
int MIN(int a,int b){return  a<b?a:b;}
int main(){
  long long  n,i,a[100010],b[100100],c,s=0;
  scanf("%lld",&n);
  n++;
  for(i=0;i<n;i++)scanf("%lld",&a[i]);
  for(i=1;i<n;i++)scanf("%lld",&b[i]);
  for(i=1;i<n;i++){
    c=MIN(b[i],a[i-1]);
    s+=c;
    b[i]-=c;
    c=MIN(b[i],a[i]);
    s+=c;
    a[i]-=c;
  }
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 1664
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<char> = s.trim().chars().collect();

    for e in &v {
        if *e == 'Y' {println!("Four"); return;}
    }
    println!("Three");
}



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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

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

    int a = S / 100;
    int b = S % 100;

    if (0 < a && a < 13) {
        if(0 < b && b < 13) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    } else {
        if(0 < b && b < 13) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }


    return 0;
}

Measured memory_bytes: 256