akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
int main()
{
    int N, ans = 0;
    cin >> N;
    vector<pair<int, int>> arr(N);
    rep(i, N)
    {
        int X, L;
        cin >> X >> L;
        arr[i] = {X + L, X - L};
    }
    sort(all(arr));
    int now = INT_MIN;
    rep(i, N)
    {
        if (now <= arr[i].second)
        {
            ans++;
            now = arr[i].first;
        }
    }
    cout << ans;
    return 0;
}

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

int main(){
	long long a, b; cin >> a >> b;
	cout << (a * b <= 0 ? "Zero" : ((a > 0 ? "Positive" : ((b - a + 1) & 1 ? "Negative" : "Positive")))) << endl;
	return 0;
}

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

using namespace std;

int main()

{

    int N;

    cin >> N;

    int a[100000] = { 0 };

    for (int i = 1; i <= 100; i++)

        for (int j = 1; j <= 100; j++)

            for (int k = 1; k <= 100; k++)

            {

               if( i* i + j * j + k * k + i * j + i * k + j * k<=10000)

                   a[i * i + j * j + k * k + i * j + i * k + j * k]++;

            }

    for (int i = 1; i <= N; i++)

    {

        cout << a[i] << endl;

    }

    return 0;

}

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

int main(void){
    int N, M ,X;
    int A[100];
    int cost1 = 0;
    int cost2 = 0;
    int i;

    scanf("%d %d %d\n",&N ,&M ,&X);
    //printf("%d",M);

    for(i = 0; i<M; i++){
       // printf("%d",i);
        scanf("%d",&A[i]); 
    }
    //printf("a");
   // printf("\n");
    for(i = 0; i < M; i++){
        if(X <=  A[i] && A[i] <= N)cost1++;
    }
    for(i = 0; i < M; i++){
        if(0 <= A[i] && A[i] <= X)cost2++;
    }
    if(cost1 > cost2)printf("%d\n",cost2);
    else printf("%d\n",cost1);
}

Measured memory_bytes: 128
// Created by Krishna Ashok
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cout<<#x<<"="<<x<<'\n'
#define ll long long
#define pr pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define rep(i,n) for(int i=0;i<(n);++i)
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#define fin ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007
const int INF=1e9;



void solve(){
  int n,a[3];
  cin>>n;
  ll dp[n+1][3];
  memset(dp,0LL,sizeof(dp));
  //cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
  for(int i=1;i<=n;i++){
      cin>>a[0]>>a[1]>>a[2];
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k)continue;
        dp[i][j]=max(dp[i][j],dp[i-1][k]+a[j]);
      }
    }
  }
  // for(int i=0;i<=n;i++){
  //   for(int x:dp[i]) cout<<x<<" ";
  //     cout<<"\n";
  // }
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<"\n";
}



int main()
{
    fin;
    
      solve();
        //cout<<solve()<<"\n";
    
    return 0;
}

Measured memory_bytes: 5976
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int c = D * 2 + 1;
        if(N % c == 0){
            System.out.println(N/c);
        }else{
            System.out.println(N/c+1);
        }
    }

    int gcd(int m, int n) {
        if (m < n) {
            return gcd(n, m);
        }
        if (n == 0) {
            return m;
        }
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 23764
N = int(input())
if N>=400 and N<=599:
    A=8
if N>=600 and N<=799:
    A=7
if N>=800 and N<=999:
    A=6
if N>=1000 and N<=1199:
    A=5
if N>=1200 and N<=1399:
    A=4
if N>=1400 and N<=1599:
    A=3
if N>=1600 and N<=1799:
    A=2
if N>=1800 and N<=1999:
    A=1
print(A)

Measured memory_bytes: 9180
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

void main() {
  long n, m;
  readf("%d %d\n", &n, &m);
  long[] a = readln.chomp.split.to!(long[]);
  long sum = 0;
  foreach(ai;a) sum += ai;
  sum = n - sum;
  writeln(sum >= 0 ? sum : -1);
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans = 0;

  int ma = min(a,k);
  ans += ma;
  k-=ma;

  int mb = min(b,k);
  k-=mb;

  int mc = min(c,k);
  ans += mc*-1;
  COUT(ans);
  return 0;
}


Measured memory_bytes: 3592
import java.util.*;

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

    if(A<=9 && B<=9){
      System.out.println(A*B);
    }else{
      System.out.println("-1");
    }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
/*
int dp[100];
int grundy(int L){
	if(dp[L]!=-1)return dp[L];
	if(L==0)return 1;
	set<int>se;
	for(int i=0;i<=L;i++){
		int x=0;
		for(int j=i;j<=L-1;j++){
			x^=grundy(j);
		}
		se.insert(x);
	}
	for(int i=0;;i++){
		if(!se.count(i))return dp[L]=i;
	}
}*/

ll grundy(ll h){
	h++;
	return h&-h;
}

struct node{
	int dep;
	node*nx[2];
}pool[200000];
node*root[2];
int pointer=0;

void add(string&s){
	if(root[s[0]-'0']==NULL){
		root[s[0]-'0']=&pool[pointer++];
	}
	node*t=root[s[0]-'0'];
	for(int i=1;i<s.size();i++){
		if(t->nx[s[i]-'0']==NULL){
			t->nx[s[i]-'0']=&pool[pointer++];
			t->nx[s[i]-'0']->dep=t->dep+1;
		}
		t=t->nx[s[i]-'0'];
	}
}
ll L;
ll x=0;
void dfs(node*t){
	if(t->nx[0]==NULL&&t->nx[1]==NULL)return;
	if(t->nx[0]==NULL){
		x^=grundy(L-(t->dep)-1);
	}
	else dfs(t->nx[0]);
	if(t->nx[1]==NULL){
		x^=grundy(L-(t->dep)-1);
	}
	else dfs(t->nx[1]);
}

char S[200000];
int main(){
	int n;scanf("%d%lld",&n,&L);L--;
	rep(i,n){
		scanf("%s",S);
		string s=S;
		add(s);
	}
	rep(i,2){
		if(root[i]==NULL)x^=grundy(L);
		else dfs(root[i]);
	}
	puts(x?"Alice":"Bob");
}

Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  int N;
  cin>>N;
  ll dp[110][4][4][4];
  dp[0][3][3][3]=1;
  
  rep(len,N){
    rep(c1,4){
      rep(c2,4){
        rep(c3,4){
          rep(a,4){
            if(c2==0&&c3==1&&a==2) continue;
            if(c2==1&&c3==0&&a==2) continue;
            if(c2==0&&c3==2&&a==1) continue;
            if(c1==0&&c3==1&&a==2) continue;
            if(c1==0&&c2==1&&a==2) continue;
            dp[len+1][c2][c3][a]+=dp[len][c1][c2][c3]%mod;
          }
        }
      }
    }
  }
  
  ll ans=0;
  
  rep(c1,4){
    rep(c2,4){
      rep(c3,4){
        ans+=dp[N][c1][c2][c3];
        ans%=mod;
      }
    }
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 256
#入力編
while True:
	str = input()
	if str == "-":break
	str_list=list(str)
	m = int(input())
	h = [0 for i in range(m)]
	for i in range(m):
		h[i] = int(input())
#処理編
	for i in range(m):
		str_list.extend(str_list[:h[i]])
		del str_list[:h[i]]
	print("".join(str_list))


Measured memory_bytes: 5604
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
	int[][] b = new int[n][3];
	for (int i = 0; i < m; i++) {
		int p = sc.nextInt();
		String s = sc.next();
		if (b[p - 1][0] == 0) {
			if ("AC".equals(s)) {
				b[p - 1][0] = i + 1;
			} else {
				b[p - 1][1]++;
			}
		}
	}
	int ok = 0;
	int ng = 0;
	for (int i = 0; i < n; i++) {
		if (b[i][0] > 0) {
			ok++;
			ng += b[i][1];
		}
	}
	System.out.println(ok + " " + ng);
  }
}

Measured memory_bytes: 67140
#include<stdio.h>

typedef struct tagDATA
{
    int num;
    int cnt;
} DATA;

int cmp(const void* a,const void* b);

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

int main(){
    int n,m,i,j,t;
    DATA dat[100];
    while(1)
    {
        scanf("%d %d",&n,&m);
        if(n==0&&m==0)break;
        for(j=0;j<m;j++)
        {
            dat[j].num=j+1;
            dat[j].cnt=0;
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                scanf("%d ",&t);
                if(t)dat[j].cnt++;
            }
        }
        qsort(&dat,m,sizeof(DATA),cmp);
        for(j=0;j<m;j++)
        {
            printf("%d",dat[j].num);
            if(j!=m-1)printf(" ");
        }
        printf("\n");
    }    
    return 0;
}

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

using namespace std;

long long n, m;
vector <int> a;
int main(){
  int tmp;
  cin >> n >> m;
  cin.ignore();
  long long sum = 0;
  for (int i = 0; i < m; i++){
    cin >> tmp;
    sum += tmp;
  }

  if(n < sum){
    cout << "-1" << endl;
    return 0;
  }
  cout << (n - sum) << endl;
  return 0;
}


Measured memory_bytes: 3632
function Main(input) {
  input = input.trim().slice('');
  var flag = 'Yes';
  for(var i = 0, len = input.length; i < len; i++) {
    if(i % 2 == 0) {
      if(input[i] == 'L') flag = 'No';
    } else {
      if(input[i] == 'R') flag = 'No';
    }
  }
  console.log(flag);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf-8'));


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N){
        cin >> a[i];
    }

    ll psum = 0, msum = 0;
    ll sum = 0;
    for (int i = 0; i < N;i++){
        sum += a[i];
        if(i%2==0&&sum<=0){
            psum += 1 - sum;
            sum = 1;
        }else if(i%2==1&&sum>=0){
            psum += 1 + sum;
            sum = -1;
        }
    }

    sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += a[i];
        if(i%2==0&&sum>=0){
            msum += 1 + sum;
            sum = -1;
        }else if(i%2==1&&sum<=0){
            msum += 1 - sum;
            sum = 1;
        }
    }
    cout << min(psum, msum);
}

Measured memory_bytes: 640
import sys
N,M=map(int,input().split())
if N==1 and M==1:
    print(1)
    sys.exit()
if N==1:
    print(M-2)
    sys.exit()
if M==1:
    print(N-2)
    sys.exit()
if N==2 or M==2:
    print(0)
    sys.exit()
print((M-2)*(N-2))

Measured memory_bytes: 3064
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

a = [v[i] for i in range(n) if i % 2 == 0]
b = [v[i] for i in range(n) if not i % 2 == 0]

a_count = Counter(a)
b_count = Counter(b)

a_sorted = sorted(a_count.items(), key=lambda x:x[1], reverse=True)
b_sorted = sorted(b_count.items(), key=lambda x:x[1], reverse=True)
ans = 0
if not a_sorted[0][0] == b_sorted[0][0]:
    ans = n - a_sorted[0][1] - b_sorted[0][1]
else:
    if len(b_sorted) == 1 and len(a_sorted) == 1:
        ans = n - a_sorted[0][1]
    elif len(b_sorted) == 1:
        ans = n - a_sorted[0][1]
    elif len(a_sorted) == 1:
        ans = n - b_sorted[0][1]
    else:
        ans = n - max(a_sorted[0][1] + b_sorted[1][1], a_sorted[1][1] + b_sorted[0][1])

print(ans)


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

#ifndef ONLINE_JUDGE
    #define gc getchar
    #define pc putchar
#else
    #define gc getchar_unlocked
    #define pc putchar_unlocked
#endif

using namespace std;

#define vi vector<int>
#define si set<int>
#define vs vector<string>
#define pii pair<int,int>
#define vpi vector<pii>
#define pri priority_queue<int>
#define rev_pri priority_queue<int,vector<int>,greater<int> >
#define mpi map<int,int>
#define i64 long long int
#define endl '\n'
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf INT_MAX/2
#define infll LLONG_MAX/3
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define eps 1e-8
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define dbg(i) printf("yo %d\n", i)
#define foreach(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define sqr(a) (a) * (a)
#define clr clear()
#define CASE(a) printf("Case %d: ",a)

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


//i64 gcd(i64 a,i64 b){if(!b)return a;return gcd(b,a%b);}

//inline void fastRead(int *a){register char c=0;while(c<33)c=gc();*a=0;while(c>33){*a=*a*10+c-'0';c=gc();}}

//inline void fastWrite(int a){char snum[20];int i=0;do{snum[i++]=a%10+48;a=a/10;}while(a!=0);i=i-1;while(i>=0)pc(snum[i--]);pc('\n');}

//i64 bigmod(i64 num,i64 n){if(n==0)return 1;i64 x=bigmod(num,n/2);x=x*x%mod;if(n%2==1)x=x*num%mod;return x;}

//i64 modinverse(i64 num){return bigmod(num,mod-2)%mod;}

//i64 po(i64 a,i64 b){i64 ans=1;while(b--)ans *= a;return ans;}

//i64 ncr(i64 n,i64 r){if(n==r)return 1;if(r==1)return n;if(dp[n][r]!=-1)return dp[n][r];return dp[n][r]=ncr(n-1,r)+ncr(n-1,r-1);}


// bit manipulations

//bool checkbit(int mask,int bit){return mask & (1<<bit);}

//int setbit(int mask,int bit){ return mask  (1<<bit) ; }

//int clearbit(int mask,int bit){return mask & ~(1<<bit);}

//int togglebit(int mask,int bit){return mask ^ (1<<bit);}



int main()
{
        string s;
        cin >> s;
        For(i,s.sz)
                if(s[i] == '?')
                        s[i] = 'D';
        cout << s << endl;














        return 0;
}




Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define fr first
#define sc second
#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 rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define snuke srand((unsigned)clock() + (unsigned)time(NULL));
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
// typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
// typedef vector<T> vt;
inline int getInt() {
    int x;
    scanf("%d", &x);
    return x;
}
template <typename T> inline istream &operator>>(istream &i, v(T) & v) {
    rep(j, sz(v)) i >> v[j];
    return i;
}
template <typename T> string join(const v(T) & v) {
    stringstream s;
    rep(i, sz(v)) s << ' ' << v[i];
    return s.str().substr(1);
}
template <typename T> inline ostream &operator<<(ostream &o, const v(T) & v) {
    if(sz(v))
        o << join(v);
    return o;
}
template <typename T1, typename T2>
inline istream &operator>>(istream &i, pair<T1, T2> &v) {
    return i >> v.fi >> v.se;
}
template <typename T1, typename T2>
inline ostream &operator<<(ostream &o, const pair<T1, T2> &v) {
    return o << v.fi << "," << v.se;
}
template <typename T> inline ll suma(const v(T) & a) {
    ll res(0);
    for(auto &&x : a)
        res += x;
    return res;
}
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;
}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame                                                                   \
    {                                                                          \
        puts("-1");                                                            \
        return 0;                                                              \
    }
#define yn                                                                     \
    { puts("Yes"); }                                                           \
    else {                                                                     \
        puts("No");                                                            \
    }

int x[5];

int main() {
    rep(i, 5) {
        cin >> x[i];
        if(x[i] == 0)
            cout << i + 1 << endl;
    }
}

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

using namespace std;

int main()
{
  int n,ans=0;

  scanf("%d",&n);
  n*=2;
  vector<int> data(n);
  for(int c=0;c<n;c++)
  scanf("%d",&data[c]);
  sort(data.begin(),data.end());
  for(int c=0;c<data.size();c+=2)
  ans+=data[c];
  printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
int f(int x, int y)
{
	int temp = x;
	for (int i = 1; i < y; i++)
		x = x * temp;
	return x;
}
int main()
{
	int x;
	int  ans = 0;
	scanf("%d", &x);
	for (int i = 1; i <=sqrt(x); i++)
		for (int j = 2; j < 10; j++)
		{
			if (f(i, j) <= x)
				ans = max(ans,f(i,j));
		}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	answer := calcNoneTaxedPrice(a, b)
	fmt.Println(answer)
}

func calcNoneTaxedPrice(tax8Percent, tax10Percent int) int {
	var candidates [2]int
	candidates[0] = tax8Percent * 100 / 8
	candidates[1] = tax10Percent * 100 / 10
	min := 10000
	for _, v := range candidates {
		for i:= 0; i <= 10; i++ {
			price := v +i
			if price*8/100 == tax8Percent && price/10 == tax10Percent {
				if min > price {
					min = price
				}
			}
		}
	}
	if min != 10000 {
		return min
	}
	return -1
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,i,m,n,t=0;
  string s;
  cin>>x>>s;
  for(i=0;i<s.size();i++)
  {
    if(int(s[i])+x>90) cout<<char(int(s[i])+x-26);
    else  cout<<char(int(s[i])+x);
  }



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[100005][3];
int a[3];
int main(){
    int n, ans = 0;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d", &a[0], &a[1], &a[2]);
        for(int j=0;j<3;j++){
            int mx = 0;
            for(int k=0;k<3;k++){
                if(j == k) continue;
                mx = max(mx, dp[i-1][k]);
            }
            dp[i][j] = max(dp[i][j], mx+a[j]);
            ans = max(ans, dp[i][j]);
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int t;
ll l;
ll phi(ll x)
{
	ll res=x;
	for(int i=2;i*i<=x;i++)
	{
		if(x%i==0)
		{
			res=res/i*(i-1);
			while(x%i==0)
				x/=i;
		}
	}
	if(x>1)
		res=res/x*(x-1);
	return res;
}
ll ksm(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
int main(){
	int kase=0;
	ll l;
	cin>>l;
	ll mod=l/__gcd(7ll,l)*9ll;
	ll p=phi(mod);
	ll res=1e18;
	for(ll x=1;x*x<=p;x++)
	{
		if(p%x!=0) continue;
	if(ksm(10,x,mod)==1) 
		res=min(res,x);
	if(ksm(10,p/x,mod)==1) 
		res=min(res,p/x);
	}
	if(res==1e18)
		cout<<"-1"<<endl;
	else
		cout<<res<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cctype>
#define il inline
#define vd void
#define rg register
#define ll long long
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();

int main(){
	int a=rd(),b=rd();
	rt(6-a-b);
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 2304
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
csum=[0]*n
csum[0]=arr[0]
ans=1
for i in range(1,n):
  csum[i]=arr[i]+csum[i-1]
for i in range(1,n):
  if arr[-i]<=csum[-(i+1)]*2:
    ans+=1
  else:
    break
print(ans)

Measured memory_bytes: 14276
import sys
 
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
inf = float("INF")
a,b,q = map(int, input().split())
s = [None] * (a + 3)
s[0:2] = [-inf,-inf]
s[-1] = inf
t = [None] * (b + 3)
t[0:2] = [-inf,-inf]
t[-1] = inf
for i in range(a):
	s[i+2] = int(input())
for i in range(b):
	t[i+2] = int(input())

from bisect import bisect_left

dp0 = [None] * (a+3)
dp1 = [None] * (b+3)

def f(s,t,x,ss,i):
  if i == 0 and dp0[ss] != None: return abs(x - s[ss]) + dp0[ss]
  elif i == 1 and dp1[ss] != None: return abs(x - s[ss]) + dp1[ss]
  tr = bisect_left(t, s[ss])
  tl = tr - 1
  if i == 0: dp0[ss] = min(abs(s[ss] - t[tl]), abs(s[ss] - t[tr]))
  if i == 1: dp1[ss] = min(abs(s[ss] - t[tl]), abs(s[ss] - t[tr]))
  return abs(x - s[ss]) + min(abs(s[ss] - t[tl]), abs(s[ss] - t[tr]))


for _ in range(q):
  ans = inf
  x = int(input())
  sr = bisect_left(s, x)
  ans = min(ans, f(s,t,x,sr,0))
  ans = min(ans, f(s,t,x,sr - 1,0))
  tr = bisect_left(t, x)
  ans = min(ans, f(t,s,x,tr,1))
  ans = min(ans, f(t,s,x,tr - 1,1))
  print(ans)
  


Measured memory_bytes: 122076
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#define CO(a, b, c) ((a)?(b):(c))
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;


int main(void)
{
	
	int n, m;
	cin >> n >> m;
	vector<int> weight(n+1);
	vector< vector<int> > paths(n+1, vector<int>());
	vector<int> ans(n+1);
	int tmp1, tmp2;
	for (int i = 0; i < m; ++i)
	{
		cin >> tmp1 >> tmp2;
		paths[tmp1].push_back(tmp2);
		paths[tmp2].push_back(tmp1);
	}
	vector<int> stack(1, 1);
	int count = 0;
	while(true)
	{
		++count;
		vector<int> tmp;//次訪問するところ
		for (auto &&i : stack)//訪問元
		{
			for (auto it = paths[i].begin(); it != paths[i].end(); it++)//訪問先
			{
				if (!ans[*it])//初めて訪れたか？
				{
					ans[*it] = i;
					tmp.push_back(*it);
				}
			}
		}
		stack = tmp;
		if (stack.empty())
		{
			break;
		}
	}
	if (*min_element(ans.begin()+2, ans.end())==0)
	{
		cout << "No" << endl;
		//return 0;
	}
	cout << "Yes" << endl;
	for (auto it = ans.begin()+2; it != ans.end(); ++it)
	{
		cout << *it << endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 10996
char r[99],g[99],*G,d[99],*D;main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,D=d,G=g,c=*G++;*(G-1);)c==*D?D++,c=r[i++]:(putchar(c),c=*G++);exit(0);}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	if(y%2==1)
	cout<<"No\n";
	else
	{
		if(y<2*x || y>4*x)
		cout<<"No\n";
		else
		cout<<"Yes\n";
	}
	return 0;
	
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define	fast						ios::sync_with_stdio(false);cin.tie(0);cout.tie(NULL);
#define rep(i,n)						for(int i = 1; i<=n; i++)
#define all(p)						p.begin(),p.end()
#define	mem(ar,val)					memset(ar, val, sizeof(ar))
#define sz(c)						(int)c.size()
#define pb(x)						push_back(x)
#define mkp(x,y)					make_pair(x,y)
#define SS(a,b)						scanf("%lld%lld",&a,&b)
#define SSS(a,b,c)						scanf("%lld%lld%lld",&a,&b,&c)
#define S(a)						scanf("%lld",&a)
#define PP(a,b)						printf("%lld %lld\n",a,b)
#define PPP(a,b,c)						printf("%lld %lld %lld\n",a,b,c)
#define P(a)						printf("%lld\n",a)
#define ff						first
#define ss						second
#define gap                     <<" "<<
#define ll						long long
#define nl						"\n"
#define MAX(a, b)					((a) > (b) ? (a) : (b))
#define MIN(a, b)					((a) < (b) ? (a) : (b))
#define FI						freopen("input.txt", "r", stdin);
#define FO						freopen("output.txt", "w", stdout);
using namespace std;
const int INF = 0x7f7f7f7f;
const int modu = 1e9 + 7;
const int N = 1e5+1;
int main()
{
//	fast
	ll k,n;
	SS(k,n);
	ll mx = 0, sum = 0, pre = -1, ans = INF;
	ll ar[n];
	for(int i = 0; i<n; i++)
	{
		S(ar[i]);
		if(pre == -1)
		{
			pre = ar[i];
			continue;
		}
		ll dif = abs(pre - ar[i]);
		sum += dif;
		if(dif>mx) mx = dif;
		
		pre = ar[i];
		
	}
	if(sum<ans) ans = sum;
	
	ll dif = abs(pre - k) + abs(ar[0]-0);
	sum += dif;
	if(dif>mx) mx = dif;
	sum = sum - mx;
	if(sum<ans) ans = sum;
	cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define PA pair<PB,int>
#define PB pair<int,int>
#define F first
#define S second

void f(int M,int T,int P,int R){
  int ans[52]={};
  int ptime[52]={};
  int ttime[52][11]={};

  while(R--){
    int m,t,p,j;
    cin>>m>>t>>p>>j;
    if(j==0){
      ans[t]++;
      ptime[t]+=m+ttime[t][p];
    }else{
      ttime[t][p]+=20;
    }
  }

  vector<PA> v;
  for(int i=1;i<T+1;i++){
    v.push_back(PA(PB(P-ans[i],ptime[i]),T-i));
  }
  sort(v.begin(),v.end());

  for(int i=0;i<T-1;i++){
    if(v[i].F.F==v[i+1].F.F&&v[i].F.S==v[i+1].F.S){
      cout<<T-v[i].S<<"=";
    }else{
      cout<<T-v[i].S<<",";
    }
  }
  cout<<T-v[T-1].S<<endl;
}


int main(){

  int M,T,P,R;
  while(true){
    cin>>M>>T>>P>>R;
    if(M==0) break;
    f(M,T,P,R);
  }
}



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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int width,height;
int m,n;

string str;

int main(){
    int i,j,k;
    int x,y,a,b;
    
    cin >> str;
    
    set<char> sc;
    for (i=0;i<n;i++){
        sc.insert(str[i]);
        if (3<=sc.size()) break;
    }
    
    if (sc.size()==2){
        cout << "Second" << endl;
        return 0;
    }
    
    bool second = str.size()%2 == 1;
    
    if (str[0]!=str[str.size()-1]){
        second = !second;
    }
    
    if (second){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

func main() {
	const COEFFICIENT = 0.006
	var n int
	var t, a float64
	fmt.Scan(&n, &t, &a)

	var min float64
	var point int
	for i := 0; i < n; i++ {
		var h float64
		fmt.Scan(&h)
		temp := t - h*COEFFICIENT
		diff := math.Abs(float64(temp - a))
		if i == 0 {
			min = diff
			point = 1
			continue
		}
		if diff < min {
			min = diff
			point = i + 1
		}
	}
	fmt.Println(point)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF = 1e18;

int main()
{
   ll n,w,i,j;
    ll sum_val = 0;
    cin>>n>>w;
    vector<ll> wt(n),p(n);
    for(i = 0 ; i < n ; i++)
    {
        cin>>wt[i]>>p[i];
        sum_val += p[i];
    }

     vector<ll> dp(sum_val+1,INF); //0 to sum_val(the minimum weight for making value sum exactly i)
dp[0] = 0;
     for(i = 0 ; i < n ; i++)
    {  for(j = sum_val-p[i]; j>=0 ; j--)
        {
            dp[j+p[i]] = min(dp[j+p[i]],wt[i]+dp[j]);
        }
    }
    ll ans = 0;
    for(i = 0 ; i <= sum_val ; i++)
    {
        if(dp[i]<=w)
        {
            ans = max(ans,i);
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>

#define int long long
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

using namespace std;

int N, Z, W;
int a[2001];

signed main()
{
    cin >> N >> Z >> W;
    REPS(i, N) cin >> a[i];

    int ans = N > 1 ? max(abs(a[N-1] - a[N]), abs(a[N] - W)) : abs(a[N] - W);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left, bisect_right
sys.setrecursionlimit(10**6)

N=int(sys.stdin.readline().strip())
A=[None]+map(int, sys.stdin.readline().split())

al=[ [] for _ in range(N+1) ]	#隣接リスト
for i in range(N-1):
	u,v=map(int, sys.stdin.readline().split())
	al[u].append(v)
	al[v].append(u)


LIS=[ float("inf") for _ in range(N+1)] 
LIS[0]=float("-inf")
ans={}  #頂点i:LISの長さ

def dfs(cur,par):
    idx=bisect_left(LIS, A[cur])
    old=LIS[idx]
    LIS[idx]=A[cur]
    ans[cur]=bisect_left(LIS, float("inf"))-1 #LISの長さ
    for to in al[cur]:
        if par==to: continue    #遷移先が親であれば、遷移しない
        dfs(to,cur)
    LIS[idx]=old
        
dfs(1,-1)

for i in range(1,N+1):
    print ans[i]

Measured memory_bytes: 379656
#include<stdio.h>
int main(void)
{
	int a[3];
	int max = 0;
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	for(int i = 0;i < 3;i++){
		for(int j = 0; j < 3;j++){
			if (a[i] < a[j]) {
				max = a[i];
				a[i] = a[j];
				a[j] = max;
			}
		
		}
	}
	
	printf("%d", a[2] * 10 + a[1] + a[0]);

	return 0;
}



Measured memory_bytes: 128
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue
const ll Maxn=1e5;
ll x[2*Maxn+3],y[2*Maxn+3];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll F[2*Maxn];
ll Find(ll a)
{
    return F[a]==0?a:F[a]=Find(F[a]);
}
int main()
{

ll n;
cin>>n;
for(int i=1;i<=n;i++)
 {
     ll a,b;
     cin>>a>>b;
     ll z,zz;
     z=Find(a);zz=Find(b+Maxn);
     if(z!=zz)
     {
         F[z]=zz;
     }
 }
 for(ll i=1;i<=Maxn;i++)
    x[Find(i)]++;
 for(ll i=Maxn+1;i<=Maxn*2;i++)
    y[Find(i)]++;
    ll sum=0;
    for(ll i=Maxn;i<=2*Maxn;i++)
      
        sum+=(ll)(x[i])*(y[i]);
    cout<<sum-n;
}



Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

    public static void main(String [] args) {
        final Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        boolean win = false;
        for (int i = 0; i < N; ++i) {
            int num = scanner.nextInt();
            if (num % 2 == 1) {
                win = true;
            }
        }
        if (win) {
            System.out.println("first");
        } else {
            System.out.println("second");
        }
    }
}


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

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

    bool flg = true;
    int cnt = 0;
    for (int i = 1; i < s.length(); i++) {
        if (s[i] == 'C' && 2 <= i && i <= s.length() - 2) {
            cnt++;
        } else if (s[i] != 'C' && (s[i] < 'a' || 'z' < s[i])) {
            flg = false;
        }
    }
    if (s[0] != 'A' || cnt != 1) flg = false;

    cout << (flg ? "AC" : "WA") << endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, M;
vector <int> Graph[int(1e5+5)];

bool visited[int(1e5+5)];
bool color[int(1e5+5)];


bool check(){
  queue <int> que;
  que.push(1); visited[1] = true;

  while (!que.empty()){
    int Q = que.front(); que.pop();

    for (int i = 0; i < Graph[Q].size(); i++){
      int next = Graph[Q][i];
      if (!visited[next]){
        visited[next] = true;
        if (color[Q]) color[next] = false;
        else color[next] = true;
        que.push(next);
        continue;
      }

      if (color[Q] == color[next]) return false; 
    }
  }
  return true;
}

int main(){
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int A, B; cin >> A >> B;
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }

  if (!check()){
    cout << N * (N - 1) / 2 - M << endl;
    return 0;
  }

  ll B = 0, W = 0;
  for (int i = 1; i <= N; i++){
    if (color[i]) B++;
    else W++;
  }

  cout << B * W - M << endl;


  return 0;
}


Measured memory_bytes: 9448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int d;
int main() {
 cin>>d;
 if(d == 25) cout << "Christmas" <<endl;
 if(d == 24) cout << "Christmas Eve" <<endl;
  if(d == 23) cout << "Christmas Eve Eve" <<endl;
  if(d == 22) cout << "Christmas Eve Eve Eve" <<endl;
 

}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n,q;
    string s;
    cin >> n >> s >> q;

    while(q--) {
        int k;
        cin >> k;

        ll d,m,dm;
        d = m = dm = 0;

        ll ans = 0;
        rep(i, n) {
            if (s[i] == 'D') {
                d++;
            } else if (s[i] == 'M') {
                m++;
                dm += d;
            }

            if (i >= k) {
                if (s[i - k] == 'D') {
                    d--;
                    dm -= m;
                } else if (s[i - k] == 'M') {
                    m--;
                }
            }

            if (s[i] == 'C') ans += dm;
        }

        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

const int N = 1e5 + 7;
int main(){
	ios_base::sync_with_stdio (false);
    cout << fixed;
    cout.precision(10);
	//freopen ("joke.in","r",stdin);
	//freopen ("joke.out","w",stdout);

  	int n;
	cin >> n;
	vector<int> v(n);
  	vector<int> cnt_even(N, 0);
  	vector<int> cnt_odd(N, 0);

    for(int i = 0; i < n; ++i){
    	cin >> v[i];
      	if(i % 2) cnt_odd[v[i]]++;
      	else cnt_even[v[i]]++;
    }

    vector<pair<int, int>> even;
    vector<bool> even_taken(N, false);
    for(int i = 0; i < n; i += 2){
    	if(!even_taken[v[i]]){
    		even.push_back(make_pair(cnt_even[v[i]], v[i]));
    		even_taken[v[i]] = true;
    	}
    }
	
    vector<pair<int, int>> odd;
    vector<bool> odd_taken(N, false);
    for(int i = 1; i < n; i += 2){
    	if(!odd_taken[v[i]]){
    		odd.push_back(make_pair(cnt_odd[v[i]], v[i]));
    		odd_taken[v[i]] = true;
    	}
    }
	
	sort(even.begin(), even.end(), std::greater<pair<int, int>>());
  	sort(odd.begin(), odd.end(), std::greater<pair<int, int>>());

  	int res = N;
  	if(even[0].second != odd[0].second){
  		res = n - even[0].first - odd[0].first;
  	}else{
  		if(even.size() == 1 && odd.size() == 1){
  			res = n / 2;
  		}else{
  			if(even.size() > 1){
  				res = min(res, n - even[1].first - odd[0].first);
  			}
  			if(odd.size() > 1){
  				res = min(res, n - even[0].first - odd[1].first);
  			}
  		}
  	}
  	cout << res;

    return 0;
}


Measured memory_bytes: 2680
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int h, w;
  char mat[105][105];
  cin >> h >> w;

  bool delRow[105]{};
  bool delCol[105]{};
  for (int i = 0; i < h; ++i) {
    cin >> mat[i];
    if (all_of(mat[i], mat[i]+w, [](char c){return c == '.';})) {
      delRow[i] = true;
    }
  }

  auto f = [&](int row) {
    for (int i = 0; i < h; ++i) if (mat[i][row] != '.') return false;
    return true;
  };

  for (int i = 0; i < w; ++i) {
    if (f(i)) delCol[i] = true;
  }

  for (int i = 0; i < h; ++i) {
    if (delRow[i]) continue;
    for (int j = 0; j < w; ++j) {
      if (!delCol[j]) putchar(mat[i][j]);
    }
    putchar('\n');
  }

  return 0;
}



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

std::string s;
std::string t;

int main(){
  
  std::cin >> s >> t;
  int ans = 0;
  for(int i = 0;i <= s.size() - t.size();++i){
    
	int cnt = 0;
    for(int j = 0;j < t.size();++j)
      if(s[i + j] == t[j]) cnt++;
    
    ans = std::max(ans,cnt);
  }
  
  std::cout << t.size() - ans << std::endl;
  
  return 0;
}

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

typedef long long ll ;
const ll INF = 1LL << 60;

int main() {

  int N;
  cin >> N;
  vector< double > X(N),Y(N);
  vector< char > D(N);
  vector< double > ti;
  REP(i,N) cin >> X[i] >> Y[i] >> D[i];

  double minc;
  double mdec;
  double mstay;
  ti.push_back(0);	// 時間0も候補
  
  // 右方向:Xmax候補
  minc = mdec = mstay = -INF;
  REP(i,N) {
    if (D[i]=='R') minc = max(minc, X[i]);
    else if (D[i]=='L') mdec = max(mdec, X[i]);
    else mstay = max(mstay, X[i]);
  }
  // RがLを追い越す
  if (minc != -INF && mdec != -INF) ti.push_back( (mdec - minc)/2 );
  // RがU/Dを追い越す
  if (minc != -INF && mstay != -INF) ti.push_back( mstay - minc );
  // LがU/Dを追い越す
  if (mdec != -INF && mstay != -INF) ti.push_back( mdec - mstay );

  // 左方向:Xmin候補
  minc = mdec = mstay = INF;
  REP(i,N) {
    if (D[i]=='R') minc = min(minc, X[i]);
    else if (D[i]=='L') mdec = min(mdec, X[i]);
    else mstay = min(mstay, X[i]);
  }
  // LがRを追い越す
  if (minc != INF && mdec != INF) ti.push_back( (mdec - minc)/2 );
  // RがU/Dを追い越す
  if (minc != INF && mstay != INF) ti.push_back( mstay - minc );
  // LがU/Dを追い越す
  if (mdec != INF && mstay != INF) ti.push_back( mdec - mstay );

  // 上方向:Ymax候補
  minc = mdec = mstay = -INF;
  REP(i,N) {
    if (D[i]=='U') minc = max(minc, Y[i]);
    else if (D[i]=='D') mdec = max(mdec, Y[i]);
    else mstay = max(mstay, Y[i]);
  }
  // UがDを追い越す
  if (minc != -INF && mdec != -INF) ti.push_back( (mdec - minc)/2 );
  // UがL/Rを追い越す
  if (minc != -INF && mstay != -INF) ti.push_back( mstay - minc );
  // DがL/Rを追い越す
  if (mdec != -INF && mstay != -INF) ti.push_back( mdec - mstay );

  // 下方向:Ymin候補
  minc = mdec = mstay = INF;
  REP(i,N) {
    if (D[i]=='U') minc = min(minc, Y[i]);
    else if (D[i]=='D') mdec = min(mdec, Y[i]);
    else mstay = min(mstay, Y[i]);
  }
  // UがDを追い越す
  if (minc != INF && mdec != INF) ti.push_back( (mdec - minc)/2 );
  // UがL/Rを追い越す
  if (minc != INF && mstay != INF) ti.push_back( mstay - minc );
  // DがL/Rを追い越す
  if (mdec != INF && mstay != INF) ti.push_back( mdec - mstay );

  double ans = INF;
  for ( auto t: ti ) {
//    cout << t << endl;
    if ( t < 0 ) t = abs(t);
    double xmax, ymax, xmin, ymin;
    xmax = ymax = -INF;
    xmin = ymin = INF;
    REP(i,N) {
      double xi = X[i];
      double yi = Y[i];
      if (D[i] == 'R') xi += t;
      else if (D[i] == 'L') xi -= t;
      else if (D[i] == 'U') yi += t;
      else yi -= t;
      xmax = max( xmax, xi );
      ymax = max( ymax, yi );
      xmin = min( xmin, xi );
      ymin = min( ymin, yi );
    }
//    cout << xmax<< " " << xmin << " " << ymax << " " <<ymin << endl;
    ans = min( ans, (xmax-xmin)*(ymax-ymin) );
  }
  cout << fixed << setprecision(10) << ans << endl;
//  cout << ans << endl;

}



Measured memory_bytes: 1920
N=("0"+input())[::-1]
ans=0
kuriagari=0
for i in range(len(N)):
  n=int(N[i])+kuriagari
  if n==5:
    if i+1<len(N):
      if int(N[i+1])>=5:
        ans+=(10-n)
        kuriagari=1
      else:
        ans+=n
        kuriagari=0
    else:
      ans+=n
      kuriagari=0
  elif n<=5:
    ans+=n
    kuriagari=0
  else:
    ans+=(10-n)
    kuriagari=1

print(ans)

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

int main(){
  int a,b;
  cin >> a >> b;
  int tmp = b-a;

  int ans = 0;
  for(int i = 1;i <= tmp;i++){
    ans += i;
  }

  cout << ans - b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using Vl = vector<ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}

int main(){
    ll n;
  	cin >> n;
    vector<ll> a(n);
  	ll res;
    rep(i, n){
        cin >> a[i];
        if(i == 0)res = a[0];
        res = gcd(res, a[i]);
    }
    cout << res << endl;
}



Measured memory_bytes: 3968
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = (0..N)
        .map(|_| {
                let mut line: String = String::new();
                std::io::stdin().read_line(&mut line).unwrap();
                line.trim().parse().unwrap()
        })
        .collect();

    let ans = {
        let mut s = std::collections::HashSet::new();
        for &a in &A {
            if s.contains(&a) { s.remove(&a); }
            else { s.insert(a); }
        }
        s.len()
    };

    println!("{}", ans);
}


Measured memory_bytes: 8444
from collections import defaultdict
import heapq
n,m=map(int,input().split())
dic=defaultdict(list)
for i in range(n):
    a,b=map(int,input().split())
    dic[a]+=[-b]
    
li=[]
ans=0

for i in range(1,m+1):
    if dic[i]:
        for j in dic[i]:
            heapq.heappush(li,j)
    if li:
        ans+=heapq.heappop(li)
print(-ans)

Measured memory_bytes: 27676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll modpow(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        //ret %= MOD;
        n >>= 1;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 0, 61) {
        ll sum1 = 0;
        rep(j, 0, n) {
            if (a[j] & (1LL << i)) sum1++;
        }
        ans += (modpow(2, i, MOD) * ((sum1 * (n - sum1)) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560