akhauriyash/Code-Regression huggingface dataset:
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
          ll x,y,a,b,c;
          cin>>x>>y>>a>>b>>c;
          ll p[a],q[b],r[c];
          for(int i=0;i<a;i++)
            cin>>p[i];
          for(int i=0;i<b;i++)
            cin>>q[i];
          for(int i=0;i<c;i++)
            cin>>r[i];
          sort(p,p+a);
          sort(q,q+b);
          sort(r,r+c);
          reverse(p,p+a);
          reverse(q,q+b);
          reverse(r,r+c);
           priority_queue <pair<ll,ll>> v;
      for(int i=0;i<x;i++)
        v.push({p[i],1});
      for(int j=0;j<y;j++)
        v.push({q[j],2});
      for(int i=0;i<c;i++)
        v.push({r[i],3});
        ll sum=0;
        ll count = 0;
        ll want=x+y;
    while (!v.empty())
    {
        pair<ll,ll> pi=v.top();
        v.pop();
        ll val=pi.fr;
        ll node=pi.se;
        if(node==1)
        {
            if(x>0)
            {
                sum+=val;
                x--;
                count++;
            }
        }
        else if(node==2)
        {
            if(y>0)
            {
                sum+=val;
                y--;
                count++;
            }
        }
        else
        {
            sum+=val;
            count++;
        }
        if(count==want)
        {
            break;
        }
    }
    cout<<sum<<endl;
}

}



























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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()


bool judge(int bit, int N,  vector<vector<int64_t>> persons){
  REP(i,N){
    
    if( !(bit & (1 << i))) continue;

    REP(j,N){
      if(persons[i][j] == 1 && !(bit & (1 << j))) return false;
      if(persons[i][j] == 0 && (bit & (1 << j))) return false;
    }
  }
  return true;

}

int main() {
  //std::cout << std::fixed << std::setprecision(20);
  int64_t N;
  cin >> N;

  vector<vector<int64_t>> persons(N,vector<int64_t>(N,-1));
  vector<int64_t> person(N,1);

  REP(i,N){
    int64_t A;
    cin >> A;
    REP(j,A){
      int64_t x, y;
      cin >> x >> y;
      persons[i][x-1] = y;
    }
  }

  //bit全探索
  int res = 0;
  for(int bit = 0; bit < (1 << N); ++bit){
    if(judge(bit, N, persons)){
      int count = 0;
      REP(i,N){
        if(bit & (1 << i)) count++;
      }
      res = max(res, count);

    }
  }


  cout << res << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char x = sc.next().charAt(0);
    	char y = sc.next().charAt(0);
      
      	if(x == y){
        	System.out.println("=");
        }else if(x < y){
        	System.out.println("<");
        }else{
        	System.out.println(">");
        }
    }
}

Measured memory_bytes: 35712
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] a = sc.nextLine().toCharArray();
		char[] b = sc.nextLine().toCharArray();
		for (int i = 0; i < 3; i++) {
			if (a[i] != b[2-i]) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

struct S {
    int w, s, v;
    void read() {
        scanf("%d%d%d", &w, &s, &v);
    }
    bool operator <(const S& b) const {
        return w + s < b.w + b.s;
    }
};

int main() {
    int n;
    scanf("%d", &n);
    vector<S> in(n);
    int MAX_S = 20123;
    for(int i = 0; i < n; ++i) {
        in[i].read();
        //~ MAX_S = max(MAX_S, in[i].s + in[i].w);
    }
    sort(in.begin(), in.end());
    vector<ll> dp(MAX_S + 1);
    // dp[i] - best score of boxes with total weight i
    for(S block : in) {
        for(int w = min(block.s, MAX_S - block.w); w >= 0; --w) {
            dp[w+block.w] = max(dp[w+block.w], dp[w] + block.v);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= MAX_S; ++i) {
        answer = max(answer, dp[i]);
    }
    printf("%lld\n", answer);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n,z,w;
    cin>>n>>z>>w;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin>>a[i];
    }

    auto dp=make_vec<ll>(n+10,2);
    for(int i = n - 1; i >= 0; i--) {
        dp[i][0]=-LINF;
        ll y=(i==0 ? w : a[i-1]);
        chmax(dp[i][0],abs(y-a[n-1]));
        for(int j = i+1; j < n; j++) {
            chmax(dp[i][0],dp[j][1]);
        }

        dp[i][1]=LINF;
        ll x=(i==0 ? z : a[i-1]);
        chmin(dp[i][1],abs(x-a[n-1]));
        for(int j = i+1; j < n; j++) {
            chmin(dp[i][1],dp[j][0]);
        }
    }
    cout<<dp[0][0]<<endl;

}



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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
using namespace std;
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    int N, K;
    string S;
    cin >> N >> S >> K;
    rep(i, N) {
        if (S[i] != S[K - 1]) {
            S[i] = '*';
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)

ans = 0
for i in range(2 ** (N - 1)):
    nums = []
    num = ''
    for j in range(N):
        num += S[j]
        if (i >> j) & 1:
            nums.append(int(num))
            num = ''
    else:
        nums.append(int(num))
    ans += sum(nums)

print(ans)


Measured memory_bytes: 69804
s = input()
pat = []
for i in range(2**3):
    tmp = ['']
    for j in range(3):
        if i >> j & 1:
            tmp.append('+')
        else:
            tmp.append('-')
    pat.append(tmp)

for p in pat:
    tmp = ''
    for i, j in zip(p, s):
        tmp += i+j
    if eval(tmp) == 7:
        print(tmp + '=7')
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define INF 1000000000;
using namespace std;
int n,dis[41],t[41],maxball,ans,memo[3][41];

void saiki(int x,int now,int ball,int sum,int kai){
  maxball=max(maxball,kai);
  if(kai==n&&!ball)ans=min(ans,sum);

  if(ball)saiki(0,now+x*(1+ball),0,sum+x,kai);
  if(ball==3||kai==n) return;
  
  int nx=dis[kai];
  int nsum=sum+abs(x-nx);
  int nnow=now+abs(x-nx)*(1+ball);
  if(nnow<=t[kai]&&memo[ball][kai]>nsum){
    memo[ball][kai]=nsum;
    saiki(nx,t[kai],ball+1,nsum,kai+1);
  }
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<3;i++)
      for(int j=0;j<n;j++) memo[i][j]=INF;
    for(int i=0;i<n;i++)cin >>dis[i]>>t[i];
  
    maxball=0,ans=INF;
    saiki(0,0,0,0,0);
    if(maxball==n)cout <<"OK "<<ans<<endl;
    else cout<<"NG "<<maxball+1<<endl;
  }
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<3;i++){
        if(s[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3624
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	bb := make([]int, n)

	ab := make(AB, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	for i := 0; i < n; i++ {
		bb[i] = getNextInt(scanner)
	}

	for i := 0; i < n; i++ {
		ab[i].c = aa[i] - bb[i]
		ab[i].i = i
	}
	sort.Sort(ab)
	ans := 0
	var horobiyo int64
	for i := 0; i < n && ab[i].c < 0; i++ {
		horobiyo += int64(ab[i].c)
		ans++
	}
	for i := n - 1; i >= 0 && ab[i].c >= 0 && horobiyo < 0; i-- {
		horobiyo += int64(ab[i].c)
		ans++
	}
	if horobiyo < 0 {
		fmt.Fprintln(writer, -1)
		return
	}
	fmt.Fprintln(writer, ans)
}

type abchan struct {
	i, c int
}

type AB []abchan

func (a AB) Len() int           { return len(a) }
func (a AB) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a AB) Less(i, j int) bool { return a[i].c < a[j].c }


Measured memory_bytes: 7936
use std::io::{stdin, stdout, StdinLock, StdoutLock, BufReader, BufWriter, BufRead, Write};

fn main() {
    let (std_in, std_out) = (stdin(), stdout());
    let mut io = IO::new(std_in.lock(), std_out.lock());
    let tmp = io.rv::<i32>();
    let (n, m) = (tmp[0], tmp[1]);
    let a = io.rv::<i32>();

    let mut sum = 0;
    for x in a {
        sum += x;
    }
    if n - sum >= 0 {
        io.w(n - sum);
    } else {
        io.w(-1);
    }
}


struct IO<'a> {
    br: BufReader<StdinLock<'a>>,
    bw: BufWriter<StdoutLock<'a>>,
}

#[allow(dead_code)]
impl IO<'_> {
    fn new<'a>(il: StdinLock<'a>, ol: StdoutLock<'a>) -> IO<'a> {
        IO {br: BufReader::new(il), bw: BufWriter::new(ol) }
    }

    fn r<T: std::str::FromStr>(&mut self) -> T {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().parse().ok().unwrap()
    }

    fn rb(&mut self) -> Vec<u8> {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().as_bytes().to_vec()
    }

    fn rv<T: std::str::FromStr>(&mut self) -> Vec<T> {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
    }

    fn rvb(&mut self) -> Vec<Vec<u8>> {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().split_whitespace().map(|e| e.as_bytes().to_vec()).collect()
    }

    fn w<T: std::fmt::Display>(&mut self, x: T) {
        let _ = writeln!(self.bw, "{}", x);
    }

    fn wb(&mut self, s: &[u8]) {
        let _ = writeln!(self.bw, "{}", unsafe{std::str::from_utf8_unchecked(s)});
    }

    fn wv<T: std::fmt::Display>(&mut self, v: &[T]) {
        let _ = write!(self.bw, "{}", v[0].to_string());
        for x in v[1..].iter() {
            let _ = write!(self.bw, " {}", x.to_string());
        }
        let _ = writeln!(self.bw);
    }

    fn wvb(&mut self, v: &[Vec<u8>]) {
        let _ = write!(self.bw, "{}", unsafe{std::str::from_utf8_unchecked(&v[0])});
        for x in v[1..].iter() {
            let _ = write!(self.bw, " {}", unsafe{std::str::from_utf8_unchecked(x)});
        }
        let _ = writeln!(self.bw);
    }
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, -1, 1};

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int h,w;cin>>h>>w;
  string mp[100];
  bool res=true;
  for(int i=0;i<h;i++)cin>>mp[i];
  for(int y=0;y<h;y++){
    for(int x=0;x<w;x++){
      if(mp[y][x]=='.')continue;
      int cnt=0;
      for(int k=0;k<4;k++){
        int ny = dy[k]+y;
        int nx = dx[k]+x;
        if(0<=ny&&ny<h&&0<=nx&&nx<w&&mp[ny][nx]=='#')cnt++;
      }
      if(!cnt)res=false;
    }
  }
  cout<<(res ? "Yes" : "No")<<endl;

  return 0;
}


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

const int INFTY = 1000000001;

int num;

void merge(int A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int*L = new int[n1 + 1];
	int*R = new int[n2 + 1];
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1] = INFTY;
	R[n2] = INFTY;
	for (int i = 0, j = 0, k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
			num++;
		}
		else {
			A[k] = R[j];
			j++;
			num++;
		}
	}
	delete[] R;
	delete[] L;
}

void mergeSort(int A[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main() {
	int n = 0;
	cin >> n;
	static int A[500000];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	mergeSort(A, 0, n);
	for (int i = 0; i < n; i++) {
		if (i != n - 1) {
			cout << A[i] << " ";
		}
		else {
			cout << A[i] << endl;
		}
	}
	cout << num << endl;

	return 0;
}

Measured memory_bytes: 6852
#include <stdio.h>

int main(){

  long S,s,c,p=1;
  int k,l,i;
  int m,n=0;
  long a=1;
  long ans=0;
  scanf("%ld", &S);
  s=S;
  while(s>0){
    n++;
    s/=10;
  }

  for(m=1;m<=n;m++){
    s=S;
    l=n-m+1;
    k=1;
    while(s>=a){
      c=s%(a*10);
      p=1;
      if(k==1||k==l)
        for(i=1;i<=n-m-1;i++)p*=2;
      else
        for(i=1;i<=n-m-2;i++)p*=2;
      for(i=1;i<=p;i++)
        ans+=c;
      k++;
      s/=10;
    }
    a*=10;
  }

  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define PB push_back
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define PIE (3.14159265358979323846)
#define MOD 1000000007;
using namespace std;

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

    vector<int> arr {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};
    int k {};
    cin >> k;
    cout<<arr.at(k-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int A,B,C;
	vector<int> N;
	cin >> A >> B >> C;
	N.push_back(A);
	N.push_back(B);
	N.push_back(C);
	sort(N.begin(),N.end());
	cout << 10*N[2]+N[1]+N[0] << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int e; cin >> e;
	while(e){
		int min = 1 << 21;
		for(int i = 0; i * i * i <= e; i++){
			for(int j = 0; j * j + i * i * i <= e; j++){
				if(e - (i * i * i + j * j) + j + i < min){
					min = e - (i * i * i + j * j) + j + i;
				}
			}
		}
		cout << min << endl;

		cin >> e;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64

vector<int> e[10101];

signed main() {
  int n;cin>>n;
  for(int i=0;i<n-1;++i){
    int a,b;cin>>a>>b;--a;--b;
    e[a].emplace_back(b);
    e[b].emplace_back(a);
  }

  vector<int> c(n);
  for(int i=0;i<n;++i) cin>>c[i];
  sort(c.begin(), c.end(), greater<int>());
  int sc = accumulate(c.begin(), c.end(), 0LL) - c.front();
  cout<<sc<<endl;

  int s=0;
  for(int i=0;i<n;++i){
    if(e[i].size()<e[s].size()) s=i;
  }

  
  vector<bool> visited(n,false);
  stack<int> st;
  st.push(s);

  int id = 0;
  vector<int> ans(n,0);
  while(!st.empty()){
    int fr=st.top();st.pop();
    ans[fr] = c[id++];
    visited[fr] = true;
    
    
    for(int j=0;j<e[fr].size();++j){
      int nx=e[fr][j];
      if (visited[nx]) continue;
      st.push(nx);
    }
  }

  for(int i=0;i<n;++i) {
    if (i>0) cout << " ";
    cout << ans[i];
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 1152
use std::io;
use std::str::FromStr;
use std::collections::HashMap;
use std::cmp;
use std::fs::File;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: usize = input();
    let v = input_vec();
    let mut odds: HashMap<u64, u64> = HashMap::new();
    let mut evens: HashMap<u64, u64> = HashMap::new();

    for i in 0..n {
        if i % 2 == 0 {
            let num = evens.entry(v[i]).or_insert(0);
            *num += 1;
        } else {
            let num = odds.entry(v[i]).or_insert(0);
            *num += 1;
        }
    }
    let mut odds_vec: Vec<_> = odds.iter().collect();
    odds_vec.sort_by(|x, y| y.1.cmp(&x.1));
    // println!("{:?}", odds_vec);

    let mut evens_vec: Vec<_> = evens.iter().collect();
    evens_vec.sort_by(|x, y| y.1.cmp(&x.1));
    // println!("{:?}", evens_vec);

    if odds_vec[0].0 == evens_vec[0].0 {
        let mut tmp1 = n as u64 - odds_vec[0].1;
        if evens_vec.len() > 1 {
            tmp1 -= *evens_vec[1].1;
        }

        let mut tmp2 = n as u64 - evens_vec[0].1;
        if odds_vec.len() > 1 {
            tmp2 -= *odds_vec[1].1;
        }
        println!("{}", cmp::min(tmp1, tmp2));
    } else {
        println!("{}", n as u64 - odds_vec[0].1 - evens_vec[0].1);
    }

}


Measured memory_bytes: 11624
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var R = int.Parse(Console.ReadLine());
            var answer = R * 2 * Math.PI;
            Console.WriteLine(answer);
        }
    }
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input();

    map< string, int > cnt;
    range(i, 0, N) {
        string s;
        cin >> s;

        cnt[s]++;
    }

    int m = 0;
    for (auto p: cnt) chmax(m, p.second);

    for (auto p: cnt) if (p.second == m) cout << p.first << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int a, b, c;
		cin >> a >> b >> c;
		if(a > b)swap(a, b);
		if(c < a || c > b)cout << "No\n";
		else cout << "Yes\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt(), q = in.nextInt();
        RSumQ rSumQ = new RSumQ(n, 0);
        for (int i = 0; i < q; i++) {
            int cmd = in.nextInt(),
                    x = in.nextInt(),
                    y = in.nextInt();
            if (cmd == 0) {
                rSumQ.add(x, y);
            }else {
                System.out.println(rSumQ.getSum(x,y));
            }
        }
    }
}

class RSumQ {
    int[] heap;
    int n;

    RSumQ(int n, int val) {
        this.n = n;
        // create heap size as 2*(log(upper2(n))+1)
        heap = new int[heap_size(n)];
        Arrays.fill(heap, val);
    }

    private static int heap_size(int n) {
        int ret = 1;
        while (ret < n) { // get ret(2*p) >= n
            ret *= 2;
        }
        return ret*2;
    }

    void add(int i, int val) {
        i -= 1;
        if (i < 0 || i >= n) {
            return;
        }
        if (n == 1) {
            heap[1] += val;
            return;
        }

        add(i, val, 0, n, 1);
    }

    private void add(int i, int val, int l, int r, int ih) {
        if (r - l == 1) {
            heap[ih] += val;
            return;
        }

        int mid = (l + r) / 2;
        if (i < mid) {
            add(i, val, l, mid,ih * 2);
        } else {
            add(i, val, mid, r,ih * 2 + 1);
        }
        heap[ih] = heap[ih * 2] + heap[ih * 2 + 1];
    }

    int getSum(int s, int t) {
        s -= 1;
        //TODO:boundary check
        return getSum(s, t, 0, n, 1);
    }

    private int getSum(int s, int t, int l, int r, int ih) {
        if (s>=t) {
            return 0;
        }
        if (s == l && t == r) {
            return heap[ih];
        }

        int mid = (l + r) / 2;
        return getSum(Math.max(s, l), Math.min(t, mid), l, mid, ih * 2) +
                getSum(Math.max(s, mid), Math.min(t, r), mid, r, ih * 2 + 1);
    }
}



Measured memory_bytes: 104416
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (a,b,c) = get!(usize, usize, usize);
    if a < b {
        if a < c && c < b {
            println!("Yes");
        } else {
            println!("No");
        }
    } else {
        if a > c && c > b {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 8572
N, M = map(int, input().split())
g = [0] * (N+1)
ans = 0
for i in range(M):
  l, r = map(int, input().split())
  g[l-1] += 1
  g[r] -= 1
for i in range(N):
  g[i+1] += g[i]
  ans += g[i] == M
print(ans)

Measured memory_bytes: 6900
n= int(input())
A = list(map(int, input().split()))

zero = 0
if zero in A:
    print("0")
else:
    for i in range(n):
    
        temp = A[i]
        if i ==0:
            kakeru = temp
        else:
            kakeru = kakeru*temp
        if kakeru >10**18:
            kakeru = -1
            break
    
    print(kakeru)


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

clock_t present = clock();
void complexiti(){
	present = clock() - present;
	cerr << "TIME : " << float(present)/CLOCKS_PER_SEC << '\n';
}

void solver(){
	//~ type your code here
	int n ;
	cin >> n;
	vector<int> a(n+10,0),v,ans(n+10,0);
	for(int i = 1 ; i <= n ; ++i){
		cin >> a[i];
	}
	for(int i = n ; i >= 1 ; --i){
		int sum = 0;
		for(int j = i+i ; j <= n ; j += i){
			sum += ans[j];
		}		
		sum %= 2;
		if(sum == 0 && a[i] == 1)ans[i] = 1;
		else if(sum == 1 && a[i] == 1)ans[i] = 0;
		else if(sum == 1 && a[i] == 0)ans[i] = 1;
		else ans[i] = 0;
		if(ans[i] == 1){
			v.push_back(i);
		}
	}
	cout << v.size() << endl;
	for(auto i:v){
		cout << i << " ";
	}
	cout << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int queries = 1;
	//~ cin >> queries;
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	complexiti();
	return 0;
}


Measured memory_bytes: 3192
N = int(input())
W = []

before = "kt"

for i in range(N):
    tmp = input()
    tmp2 = list(tmp)

    if before != "kt":
        if tmp2[0] == before and tmp not in W:
            before = tmp2[-1]
            W.append(tmp)
            continue
        else:
            print("No")
            exit()
    else:
        before = tmp2[-1]
        W.append(tmp)

print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int p=0;
	REP(i,a+1){
		REP(j,b+1){
			REP(k,c+1){
				if(i*500+j*100+k*50==x){
					p++;
				}
			}
		}
	}
	cout<<p<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
const int inf=0x3f3f3f3f;

int main()
{
    ios::sync_with_stdio(false);
    string s;cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

void solve() {
    for (int i = 1; i <= 5; ++i) {
        int x;
        std::cin >> x;
        if (x == 0) {
            std::cout << i << "\n";
            return;
        }
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <unistd.h>
#define inf 1000000007LL
#define INF 1000000000000000007LL
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector< pair<int,int> >
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define BIT(i) (1LL<<(i))
#define LOG(x) (63-__builtin_clzll(x))
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<=(n); ++i)
#define pv(...) cerr<<'\n',dbg(#__VA_ARGS__, __VA_ARGS__)
#define ps(x) {cerr<<'\n'<<#x<<":\n:";for(auto q:(x)){cerr<<q<<" ";}cerr<<'\n';}
#define pa(x, xs) {cerr<<'\n'<<#x<<":\n:";for(int q=0; q<=(xs); ++q){cerr<<x[q]<<" ";}cerr<<'\n';}
#define pal(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 3-(int32_t)log10(q):3)<<x[q]<<'\n';}cerr<<'\n';}
#define ppii(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 6-(int32_t)log10(q):6)<<x[q].first<<" "<<setw(5)<<x[q].second<<'\n';}cerr<<'\n';}
#define pm(x, xn, xm) {cerr<<'\n'<<#x<<":\n";for(int qa=0; qa<=(xn); ++qa){for(int qb=0; qb<=(xm); ++qb){cerr<<setw(6)<<x[qa][qb]<<" ";}cerr<<'\n';}cerr<<'\n';}
#define endr cerr<<'\n'
#define endl '\n'
#ifndef DEBUG
#define cerr if(0)cout
#define pv(...) if(0)endr
#define ps(x) if(0)endr
#define pa(x, xs) if(0)endr
#define pal(x, xs) if(0)endr
#define ppii(x, xs) if(0)endr
#define pm(x, xn, xm) if(0)endr
#endif
using namespace std;
template<class T> void dbg(const char* xn, T x){cerr<<xn<<": "<<x<<"\n";} template<class T, class... TA> void dbg(const char* xn, T x, TA... t){while(*xn!=',')cerr<<*xn++;cerr<<": "<<x<<",";dbg(xn+1, t...);}
template<class T> inline bool upd_max(T &x, T y){return y>x?x=y,true:false;} template<class T> inline bool upd_min(T &x, T y){return y<x?x=y,true:false;}
const int N = 307;
#define int long long

int n, A[N][N], G[N][N], cnt[N][N];


void floyd()
{
  rep1(k, n) rep1(i, n) rep1(j, n)
  {
    if (A[i][j] + A[i][k] < A[j][k]) cout<<"-1", exit(0);
    if (A[i][k] + A[k][j] == A[i][j]) ++cnt[i][j];
  }

  rep1(i, n) rep1(j, n)
  {
    if (cnt[i][j] == 2) G[i][j] = G[j][i] = A[i][j];
  }
}

void solve()
{
  cin>>n;
  rep1(i, n) rep1(j, n)
  {
    cin>>A[i][j];
  }

  floyd();

  pm(A, n, n);
  pm(G, n, n);

  int rst = 0;
  rep1(i, n) rep1(j, n) rst += G[i][j];
  cout<<rst/2;
}

int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(NULL);
cout<<fixed<<setprecision(10);

  solve();

return 0;
}


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

using namespace std;
typedef long long ll;
  
int main() {
    int n, m;
    ll x, y, z;
    array<vector<ll>, 8> sum;
    
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y >> z;
        sum[0].push_back(x + y + z);
        sum[1].push_back(x - y + z);
        sum[2].push_back(x + y - z);
        sum[3].push_back(x - y - z);
    }
    
    std::sort(sum[0].begin(), sum[0].end(), greater<ll>());
    std::sort(sum[1].begin(), sum[1].end(), greater<ll>());
    std::sort(sum[2].begin(), sum[2].end(), greater<ll>());
    std::sort(sum[3].begin(), sum[3].end(), greater<ll>());
    
    array<ll, 8> ret{0};
    for (int j = 0; j < 4; ++j) {
        for (int i = 0; i < m; ++i) {
            ret[j * 2] += sum[j][i];
            ret[j * 2 + 1] -= sum[j][n - 1 - i];
        }
    }
    
    ll max_ = ret[0];
    for (int i = 1; i < 8; ++i) {
        if (ret[i] > max_) max_ = ret[i];
                            
    }
    cout << max_ << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 
    int n;
    cin >> n;
 
    int p_min = 1000000000;
    int ans = 0;
 
    for(int i = 0; i < n; ++i){
        int p;
        cin >> p;
        p_min = min(p, p_min);
        if(p_min == p)++ans;
    }
 
    cout << ans << endl;
 
}

Measured memory_bytes: 256
while 1:
	n,p = map(int,raw_input().split())
	if n == 0: break
	have = [0]*n
	stone = p
	i = 0
	while 1:
		if stone > 0:
			have[i] += 1
			stone -= 1
		else:
			stone += have[i]
			have[i] = 0
		if have[i] == p:
			break
		i = (i+1)%n
	print i

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

c = 0
f = 0
for i in range(N):
    if A[i] < 0:
        c += 1
    elif A[i] == 0:
        f = 1
    A[i] = abs(A[i])
    
if f == 1 or c % 2 == 0:
    ans = sum(A)
else:
    ans = sum(A) - 2 * min(A)
    
print(ans)


Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define TAM 101
#define M 1000000007
#define add(a,b) (((a)+(b))%M)
#define sub(a,b) (((a)+M-(b))%M)
#define mul(a,b) int(ll(a)*(ll)b%ll(M))

int memo[TAM][TAM*TAM];
int kpow[TAM], n, k;

int f ( int i, int c ) {
	int&rf = memo[i][c];
	if ( rf != -1 ) return rf;
	if ( i == 0 ) return rf = 0;
	rf = 0;

	for ( int ai = 0; ai <= min(i,k); ++ai )
		rf = add ( rf, add ( mul((ai+c)%i, kpow[i-1]), f(i-1, c+(c+ai)/i) ) );
	for ( int ai = i+1; ai <= k; ++ai )
		rf = add ( rf, add ( mul(ai+c, kpow[i-1]), f(i-1, c) ) );
	return rf;
}

int a[TAM], b[TAM];

int solveBrute ( ) {
	int r = 0;
	while ( true ) {
		bool flag = false;
		for ( int i = 1; i <= n; ++i ) {
			if ( b[i] == i ) {
				for ( int j = 1; j < i; ++j )
					b[j]++;
				b[i] = 0;
				flag = true;
				break;
			}
		}
		if ( !flag ) break;
	}
	for ( int i = 1; i <= n; ++i ) r += b[i];
	return r;
}

int brute ( int i ) {
	if ( i > n ) {
		memcpy ( b, a, sizeof(int)*(n+1) );
		return solveBrute();
	}
	int r = 0;
	int& ai = a[i];
	for ( ai = 0; ai <= k; ++ai )
		r = add ( r, brute(i+1) );
	return r;
}

int main() {
	scanf ( "%d%d", &n, &k );
	kpow[0] = 1;
	for ( int i = 1; i <= n; ++i )
		kpow[i] = mul(kpow[i-1],(k+1));
	memset ( memo, -1, sizeof(memo) );

	//printf ( "brute: %d\n", brute(1) );
	printf ( "%d\n", f(n,0) );
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  int minNum = n+1;
  int ans = 0;
  rep(i, n){
    int num;
    cin >> num;
    if (minNum > num){
      ans++;
      minNum = num;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    ans = {'AC':0,'WA':0,'TLE':0,'RE':0}
    for i in range(n):
        s = input()
        ans[s] += 1
    print('AC x',ans['AC'])
    print('WA x',ans['WA'])
    print('TLE x',ans['TLE'])
    print('RE x',ans['RE'])
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9208
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

template <class RandomIt>
size_t bsort(RandomIt first, RandomIt last) {
    /* Bubble sort */
    size_t times=0;
    for (RandomIt it=first; it<last; ++it)
        for (RandomIt it2=last-1; it2>it; --it2)
            if (it2[0] < it2[-1]) {
                swap(it2[0], it2[-1]);
                ++times;
            }

    return times;
}

template <class RandomIt, class Comp>
size_t bsort(RandomIt first, RandomIt last, Comp comp) {
    /* Bubble sort */
    size_t times=0;
    for (RandomIt it=first; it<last; ++it)
        for (RandomIt it2=last-1; it2>it; --it2)
            if (comp(it2[0], it2[-1])) {
                swap(it2[0], it2[-1]);
                ++times;
            }

    return times;
}

template <class RandomIt>
size_t ssort(RandomIt first, RandomIt last) {
    /* Selection sort */
    size_t times=0;
    for (RandomIt it=first; it<last; ++it) {
        RandomIt min_=it;
        for (RandomIt it2=it+1; it2<last; ++it2)
            if (*it2 < *min_)
                min_ = it2;

        if (it != min_) {
            swap(*it, *min_);
            ++times;
        }
    }

    return times;
}

template <class RandomIt, class Comp>
size_t ssort(RandomIt first, RandomIt last, Comp comp) {
    /* Selection sort */
    size_t times=0;
    for (RandomIt it=first; it<last; ++it) {
        RandomIt min_=it;
        for (RandomIt it2=it+1; it2<last; ++it2)
            if (comp(*it2, *min_))
                min_ = it2;

        if (it != min_) {
            swap(*it, *min_);
            ++times;
        }
    }

    return times;
}

template <class Index, class T>
bool is_stable(vector<pair<Index, T>> sorted, const vector<T> table[]) {
    Index rank_=0;
    size_t j=0;
    for (size_t i=0; i<sorted.size(); ++i, ++j) {
        if (rank_ < sorted[i].first) {
            rank_ = sorted[i].first;
            j = 0;
        }

        if (table[rank_][j] != sorted[i].second)
            return false;
    }
    return true;
}

template <class Index, class T>
struct IndexCompare {
    bool operator()(pair<Index, T> x, pair<Index, T> y) {
        return x.first < y.first;
    }
};

int main() {
    size_t N;
    scanf("%zu\n", &N);

    vector<pair<int, char>> A(N), A_bub, A_sel;
    vector<char> rank_[10];
    for (size_t i=0; i<N; ++i) {
        scanf("%c%d ", &A[i].second, &A[i].first);
        rank_[A[i].first].push_back(A[i].second);
    }

    A_bub = A_sel = A;
    IndexCompare<int, char> idxcmp;

    bsort(A_bub.begin(), A_bub.end(), idxcmp);
    for (size_t i=0; i<N; ++i) {
        pair<int, char> p=A_bub[i];
        printf("%c%d%c", p.second, p.first, i<N-1? ' ':'\n');
    }

    printf("%s\n", is_stable(A_bub, rank_)? "Stable":"Not stable");

    ssort(A_sel.begin(), A_sel.end(), idxcmp);
    for (size_t i=0; i<N; ++i) {
        pair<int, char> p=A_sel[i];
        printf("%c%d%c", p.second, p.first, i<N-1? ' ':'\n');
    }

    printf("%s\n", is_stable(A_sel, rank_)? "Stable":"Not stable");
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int w[n] = {0}, e[n] = {0};
  for(int i = 0; i < n; ++i) {
    if(i == 0) {
      if(s[i] == 'E') e[0]++;
      else w[0]++;
    } else {
      if(s[i] == 'E') {
        e[i] = e[i-1] + 1;
        w[i] = w[i-1];
      } else {
        e[i] = e[i-1];
        w[i] = w[i-1] + 1;
      }
    }
  }
  int ans = e[n-1] - e[0];
  for(int i = 1; i < n; ++i) {
    int tmp = w[i-1] + e[n-1] - e[i];
    ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2948
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
l = []
for i in range(n):
    l.append(input())

print(len(set(l)))

Measured memory_bytes: 35576
L, R = list(map(int, input().split()))

if R - L > 2020:
  print(0)
  exit()

ans = 10 ** 20
for i in range(L, R):
  for j in range(i + 1, R + 1):
    ans = min(ans, i * j % 2019)

print(ans)

Measured memory_bytes: 42092
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int count = 0;
		int up = 0;
		int down = 0;

		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		for(int i = 0; i < N-1; i++){
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		}

		System.out.println(count);

		sc.close();
	}
};


Measured memory_bytes: 23764
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {
			String str = sc.nextLine();
			if (str.equals(".")) {
				break;
			}

			Stack<Integer> st = new Stack<Integer>();
			st.push(0);
			boolean TF = true;

			for (int i = 0; i < str.length() && TF; i++) {
				char c = str.charAt(i);

				switch (c) {
				case '(':
					st.push(1);
					break;
				case ')':
					if (st.lastElement() == 1) {
						st.pop();
					} else {
						TF = false;
					}
					break;
				case '[':
					st.push(2);
					break;
				case ']':
					if (st.lastElement() == 2) {
						st.pop();
					} else {
						TF = false;
					}
					break;
				default:
					break;
				}
			}
			if (TF && st.size() == 1) {
				System.out.println("yes");
			} else {
				System.out.println("no");

			}

		}

	}

}

Measured memory_bytes: 33996