akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
char a[10010],b[10050],c[10005],d[10005];
//int x[100005];
int main()
{
    long long int n,m,i,x,y,z;
    scanf("%lld %lld",&n,&m);
    long long int s=11111111110,k=n/2,l=m/2;
    for(i=1;i<=n;i++)
    {
        x=i*m;
        y=(n-i)*l;
        z=(n-i)*(m-l);
        long long int m1=max(max(x,y),z);
        long long int m2=min(min(x,y),z);
        s=min(s,m1-m2);

    }
    for(i=1;i<=m;i++)
    {
        x=i*n;
        y=(m-i)*k;
        z=(m-i)*(n-k);
        long long int m1=max(max(x,y),z);
        long long int m2=min(min(x,y),z);
        s=min(s,m1-m2);

    }
    if(n%3==0||m%3==0)
    {
        s=0;
    }else
    {
        s=min(s,min(m,n));
    }
    printf("%lld",s);
    return 0;
}


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

using namespace std;

int main()
{
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  
  if(a1 + a2 + a3 >= 22) cout << "bust\n";
  else cout << "win\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
ll m;
ll mpow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= x;
            res %= m;
        }
        x = x * x % m;
        n >>= 1;
    }
    return res;
}
ll dp[1 << 19][11];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k >> m;
    if (n - 1 > 2 * k - 1) {
        cout << mpow(k, n) << endl;
        return 0;
    }
    for (int i = 1; i <= k; i++) {
        dp[0][i] = 1;
    }
    for (int i = 0; i < (1 << (2 * k - 1)); i++) {
        if (__builtin_popcount(i) >= n) {
            continue;
        }
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                if ((i >> (j - l + k - 1)) & 1) {
                    continue;
                }
                (dp[i | (1 << (j - l + k - 1))][l] += dp[i][j]) %= m;
            }
        }
    }
    ll res = 0;
    for (int i = 0; i < (1 << (2 * k - 1)); i++) {
        if (__builtin_popcount(i) == n - 1) {
            for (int j = 1; j <= k; j++) {
                res += dp[i][j];
                res %= m;
            }
        }
    }
    cout << (mpow(k, n) - res + m) % m << endl;
}



Measured memory_bytes: 48220
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

N=int(input())
for h in range(1,3501):
    for n in range(h,3501):
        if (4*h*n-N*n-N*h)!=0:
            if (N*h*n)%(4*h*n-N*n-N*h)==0 and (N*h*n)//(4*h*n-N*n-N*h)>0:
                print(h,n,(N*h*n)//(4*h*n-N*n-N*h))
                exit()

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

int a[101];
bool dp[100005];

main()
{
	int n , k;
	cin >> n >> k;
	
	for(int i = 1; i <= n; i++){
		scanf("%d" , &a[i]);
	}
	
	sort(a + 1 , a + n + 1);
	
	for(int i = 1; i <= k; i++)
	{
		//cout << i << endl;
		for(int j = 1; j <= n; j++)
		{
			if( i - a[j] >= 0 )
				if( !dp[ i - a[j] ] )
					dp[i] = 1;
		}
		
	}
	
	if( dp[k] ){
		puts("First");
	}
	else{
		puts("Second");
	}
	
	
}


Measured memory_bytes: 384
<?php
$output = array();

while (true) {

  $words = array();
  $times = array();
  $score = array();
  $minMember = array();
  $member = 0;

  // ?????°??????
  $member = trim(fgets(STDIN));

  // ????????????
  if ($member == "0") {
    break;
  }

  // ?????°??????????????°?????????
  for ($j = 0; $j < $member; $j++) {

    // ????????§??????
    $words = preg_split("/[\s]/", trim(fgets(STDIN)));

    // ???????????????
    $name = $words[0];

    // score?????????????????????????????????
    $score[$name] = 0;

    // ?¨??????????????????\?????????????????°????????????
    $kind = $words[1];

    for ($k = 2; $k < count($words); $k++) {
      // ????????£??????????????????
      $times[$words[$k]][] = $name;
    }
  }

  // ?????°?¨????
  foreach ($times as $key => $value) {

    $number = count($value);

    foreach ($value as $character) {
      $score[$character] += $member - $number + 1;
    }
  }

  // ????????¢????°????????????¢???
  $min = min($score);

  foreach ($score as $key => $value) {
    if ($min == $value) {
      $minMember[] = $key;
    }
  }

  // ????????????
  sort($minMember);

  // ??????
  $output[] = $min . ' ' . $minMember[0];
}

// ??????
foreach ($output as $key => $value) {
  print $output[$key] . PHP_EOL;
}

Measured memory_bytes: 15464
import numpy as np
n = int(input())
n_list = np.array(list(map(int,input().split())))
syoujun_list =np.array(range(1,n+1))
different = n_list - syoujun_list
if np.count_nonzero(different) ==2 or np.count_nonzero(different) ==0:
    print('YES')
else:
    print('NO')

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

#define int long long

signed main()
{
    int i=0, j=0, ans=0;
    
    int k, n, a[200000];
    cin>>k>>n;
    for(i;i<n;i++){
        cin>>a[i];
        if(i>0){
            if(a[i]-a[i-1]>j)
                j=a[i]-a[i-1];
        }
    }
    if(a[0]+(k-a[n-1])>j)
        j=a[0]+(k-a[n-1]);

    cout<<k-j<<endl;
    return 0;
}

Measured memory_bytes: 1792
N = input()
ans = []
for i in range(len(N)):
  ans.append(N[0])
if int(''.join(ans)) >= int(N):
    print(''.join(ans))
    exit()
ans = []
for i in range(len(N)):
  ans.append(str(int(N[0]) + 1))
print(''.join(ans))


Measured memory_bytes: 38256
<?php
$coins = array(500, 100, 50, 10);
$flg = false;

while (fscanf(STDIN, "%d" , $cost) && $cost) {
  $mycoins = explode(' ', trim(fgets(STDIN)));

  if ($flg) print "\n";
  $flg = true;
  
  $a = $b = $c = $d = $min = 10000;
  $cnt = 0;
  foreach ($mycoins as $value) {
    $cnt += $value;
  }

  for ($i = 0; $i <= $mycoins[0]; $i++) { // 10
    for ($j = 0; $j <= $mycoins[1]; $j++) { // 50
      for ($k = 0; $k <= $mycoins[2]; $k++) { // 100
        for ($l = 0; $l <= $mycoins[3]; $l++) { // 500
          $sum = $i * 10 + $j * 50 + $k * 100 + $l * 500;
          if ($sum < $cost) continue;
          $sum -= $cost;
          $count = $cnt - $i - $j - $k - $l;
          foreach ($coins as $value) {
            $count += (int)($sum / $value);
            $sum %= $value;
          }
          if ($count < $min) {
            $min = $count;
            $a = $i;
            $b = $j;
            $c = $k;
            $d = $l;
          }
        }
      }
    }
  }
  if ($a) print "10 " . $a . "\n";
  if ($b) print "50 " . $b . "\n";
  if ($c) print "100 " . $c . "\n";
  if ($d) print "500 " . $d . "\n";
}

Measured memory_bytes: 6672
n = int(input())
s = input()
ans = 0
for i in range(10):
  idx1 = s[:-2].find(str(i))
  if idx1 >= 0:
    for j in range(10):
      idx2 = s[idx1+1:-1].find(str(j))
      if idx2 >= 0:
        ans += len(set(s[idx1+idx2+2:]))
print(ans)

Measured memory_bytes: 3060
n = int(input())
li = []

for _ in range(n):
    s = input()
    count = 0
    while True:
        if count + 1 >= len(s):
            break
        if s[count] == '(' and s[count+1] == ')':
            s = s[:count] + s[count+2:]
            count = max(0, count-1)
        else:
            count += 1
    li.append(s)

li2 = []
for i in li:
    count = 0
    for j in range(len(i)):
        if i[j] == ')':
            count += 1
        else:
            break
    li2.append((count, len(i) - count))

li3 = []
li4 = []

for i in li2:
    if i[0] <= i[1]:
        li3.append(i)
    else:
        li4.append(i)

li3.sort()
li4.sort(key = lambda x: x[1], reverse = True)

now = [0,0]

for l,r in li3:
    if l == 0 and r == 0:
        pass
    elif l == 0:
        now[1] += r
    else:
        now[1] -= l
        if now[1] < 0:
            print('No')
            exit()
        now[1] += r

for l,r in li4:
    if l == 0 and r == 0:
        pass
    elif r == 0:
        now[1] -= l
        if now[1] < 0:
            print('No')
            exit()
    else:
        now[1] -= l
        if now[1] < 0:
            print('No')
            exit()
        now[1] += r

if now[0] == 0 and now[1] == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 232384
a,b,c = map(int,input().split())
K = int(input())
j = K
for i in range(K):
    if b-a>0:
        break
    b *=2
    if b-a>0:
        j = K-(i+1)
        break
if b-a<=0:
    print('No')
    exit()
if j==0:
    if c-b >0:
        print('Yes')
        exit()
if c*(2**j)-b >0:
    print('Yes')
else:
    print('No')

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int x,n;
    cin>>x>>n;
    unordered_set<int> p(n);
    for (int i = 0; i < n; i++)
    {
        int pp;
        cin>>pp;
        p.emplace(pp);
    }
    int ans;
    for (int i = 0; i < 110; i++)
    {
        int tmp;
        tmp=x-i;
        if(p.find(tmp)==p.end())
        {
            ans=tmp;
            break;
        }
        tmp=x+i;
        if(p.find(tmp)==p.end())
        {
            ans=tmp;
            break;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <random>

using namespace std;

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << (char)(toupper(a[0])) << (char)toupper(b[0]) << (char)toupper(c[0]) <<  endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def main():
    s = input()
    l = len(s)
    while s:
        if s[-5:] == "dream":
            s = s[:-5]
        elif s[-7:] == "dreamer":
            s = s[:-7]
        elif s[-5:] == "erase":
            s = s[:-5]
        elif s[-6:] == "eraser":
            s = s[:-6]
        else:
            print("NO")
            return
    print("YES")



if __name__ == "__main__":
    main()


Measured memory_bytes: 77192
n = int(input())
s = ""
for i in range(n):
    s += input()
print("AC x " + str(s.count("AC")))
print("WA x " + str(s.count("WA")))
print("TLE x " + str(s.count("TLE")))
print("RE x " + str(s.count("RE")))

Measured memory_bytes: 9396
N = int(input())
A = tuple(map(int, input().split()))
mod = 10**9+7

def solve(N, A):
    ans = 0
    for k in range(61):
        num1 = 0
        for a in A:
            if (a >> k) & 1:
                num1 += 1
        ans += (num1 * (N-num1)) << k
        ans %= mod
    return ans
    
print(solve(N, A))


Measured memory_bytes: 43748
#include <bits/stdc++.h>
using namespace std;
#define sorted(vector) sort(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)


int main(void){
    int n,k,tmp;
    vector<int> v,motimono,ans;
    cin>>n>>k;
    for(int i=0  ;i<n  ;i++){
        cin>>tmp;
        v.push_back(tmp);
    }
    
    
    if (k>=n){
        k-=n;
        ans.append(vsum(v));
        sorted(v);
        for(int i=0  ;i<k  ;i++){
            for(int j=0  ;j<min<unsigned long>(k,v.size())  ;j++){
                v[j]=0;
                ans.append(vsum(v));
            }
        }
    }else{
        for(int i=0  ;i<n  ;i++){
            v.append(v[i]);
        }
        for(int j=1  ;j<k+1  ;j++){  //長さ
            for(int i=n-j  ;i<n+1  ;i++){ //開始index
                vector<int> motimono;
                for(int r=i  ;r<i+j  ;r++){
                    motimono.append(v[r]);
                }
                ans.append(vsum(motimono));
                sorted(motimono);
                for(int i=0  ;i< min<unsigned long>(k-j,motimono.size())  ;i++){
                    motimono[i]=0;
                    ans.append(vsum(motimono));
                }
            }
        }
    }
    cout<<vmax(ans)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;

int main(void) {
	int x; cin >> x;
	double m = 0;
	if (x == 1) { cout << 1 << endl; return 0; }
	for (double i = 2;i<=1000; i++) {
		for (double j = 2;pow(i,j)<=x; j++) {
			m = max(m, pow(i,j));
		}
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if ((a == b && b == c && c == a) || (a != b && b != c && c != a)) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }

  }

}


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

int main(){
  int p, q, r;
  cin >> p >> q >> r;
  
  if(min({p, q, r}) == q){
    cout << min(p, q) + min(p, r) << endl;
  } else{
    cout << min(p, q) + min(q, r) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fin(ans) cout << ans << endl

int main(void) {
  int a, b, c, d, e;
  cin >> a >> b;
  cin >> c >> d;
  e = c - a;
  if (e == 1 || e == -11) {
    fin(1);
  } else {
    fin(0);
  }
  return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	LL n;
	cin >> n;
	if (n == 0) {
		cout << 0 << endl;
	}

	string ans;
	while (n != 0) {
		int a = n%-2;
		if (a == -1) {
			a = 1;
			n = n/-2 + 1;
		}
		else {
			n = n/-2;
		}
		ans = to_string(a) + ans;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;
ll ans=1;
int n,a[N],cnt[N];

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	cnt[0]=3;
	for(int i=1;i<=n;i++){
		(ans*=1ll*cnt[a[i]])%=mod;
		cnt[a[i]]--;
		cnt[a[i]+1]++;
	}
	write(ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;

int main(){
    int A_1, A_2, A_3;
    cin >> A_1 >> A_2 >> A_3;
    if(A_1 + A_2 + A_3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int dp[10][10];
int main()
{
	int N;
	cin >> N;
	int ans = 0;
	fx(N) {
		int y = x + 1;
		while (y/10>0) {
			y /= 10;
		}
		int a = y;
		int b = (x + 1) % 10;
		dp[a][b]++;
	}
	fx(10) {
		fy(10) {
			ans += dp[x][y] * dp[y][x];
		}
	}
	ce(ans)


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long int n, m, sum=0;
    scanf("%ld%ld", &n, &m);
    if(n == (m / 2))
        sum = n;
    else if (n > (m / 2))
        sum = (m / 2);
    else if (n < (m / 2))
    {
        sum = n + ((m/2)-n) / 2;
    }
    printf("%ld\n", sum);
    return 0;
}


Measured memory_bytes: 128
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

bool Check(int i, LL A, LL B) {
	LL nowsum = 0;
	while (i > 0) {
		nowsum += i % 10;
		i /= 10;
	}
	if (nowsum >= A && nowsum <= B)
		return true;
	else
		return false;
}

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N, A, B,ans=0;
	cin >> N >> A >> B;
	FOR(i, 1, N + 1) {
		if (Check(i, A, B)) {
			ans += i;
		}
	}
	O(ans)

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    int a,b;
    cin>>a>>b;
    int c[14]={0,14,2,3,4,5,6,7,8,9,10,11,12,13};
    
    
    if(c[a]>c[b]){
        cout<<"Alice"<<endl;
    }else if(c[b]>c[a]){
        cout<<"Bob"<<endl;
    }else{
        cout<<"Draw"<<endl;
    }
return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  ll N; cin >> N;
  rep(h,3500) rep(n,3500) {
    ll x = N*n*h;
    ll y = 4*n*h - (n+h)*N;
    if (y>0 && x%y==0) {
      ll w = x/y;
      cout << h << " " << n << " " << w << endl;
      return 0;
    }
  }
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> numbers(N);
    int sum = 0;
    for(int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        numbers.at(i) = a;
        sum += a;
    }
    int i = 1;
    vector<int>dcs(0);
    while(i * i <= sum)
    {
        if(sum % i == 0)
        {
            dcs.push_back(i);
            dcs.push_back(sum / i);
        }
        i++;
    }
    sort(dcs.begin(), dcs.end(), greater<int>());
    for(int dc: dcs){
        vector<long long> mods(0);
        for(int j = 0; j < N; j++){
            mods.push_back(numbers.at(j) % dc);
        }
        sort(mods.begin(), mods.end());
        vector<long long> ruisekiMods(0);
        long long ruiseki = 0;
        for(long long md: mods){
            ruiseki += md;
            ruisekiMods.push_back(ruiseki);
        }
        for(int j = 0; j < ruisekiMods.size(); j++){
            long long decrementTotal;
            long long incrementTotal;
            decrementTotal = ruisekiMods[j];
            incrementTotal = 1LL * (ruisekiMods.size() - 1 - j) * dc - (ruisekiMods[ruisekiMods.size() - 1] - ruisekiMods[j]);
            if(decrementTotal == incrementTotal && decrementTotal <= K){
                cout << dc << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front

typedef long long int ll;
typedef pair<int, int> ii; // are aligned to the right like this
typedef vector<ii> vii;  //vector pair
typedef vector<int> vi;   //vector integer
typedef vector<string> vs; //vector string


int main() 
{
    int n;
  cin>>n;
  if(n==0)
    cout<<1;
  else
    cout<<0;
}
 

Measured memory_bytes: 3560
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int comp (const void * elem1, const void * elem2)
{
    int f = *((int*)elem1);
    int s = *((int*)elem2);
    if (f > s) return  1;
    if (f < s) return -1;
    return 0;
}

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

int main(int argc, char* argv[])
{
    int n;
    long long int x[100000] = {0};
    cin >> n;
    for (int i = 0; i<n; i++) {
        cin >> x[i];
    }

    qsort (x, n, sizeof(*x), asc);

    long long int answer = 1;
    int s = 0;
    int s2 = 0;
    for (int i = 1; i < n ; i++) {
        if (x[i-1] == x[i]){
            s2 ++;
            answer = answer * x[i];
            //cout << "can use " << x[i] << " " << s2 << "answer " << answer  << endl;

            i++;
            s++;s++;
            if (s2 == 2) {
                cout << answer << endl;
                return 0;
            }
        }


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

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int n = sc.nextInt();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                int a = sc.nextInt();
                ans += (a - 1);
            }
            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 25936
N,M = map(int,input().split())

AC = [0]*N
WA = [0]*N
AC_cnt = 0
WA_cnt = 0

p = [0]*M
S = [0]*M

for i in range(M):
    p[i],S[i] = map(str, input().split())

for i in range(M):
    q_num = int(p[i])
    if AC[q_num-1] == 0:
        if S[i] == "AC":
            AC[q_num-1] = 1
        else:
            WA[q_num-1] += 1

for i in range(N):
    if AC[i] == 1:
        WA_cnt += WA[i]
        AC_cnt += 1

print(AC_cnt,WA_cnt)


Measured memory_bytes: 93612
n=int(input())
a=list(map(int, input().split()))
dp=[0]*n
dp[1]=abs(a[1]-a[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]))
print(dp[-1])


Measured memory_bytes: 84892
#include <iostream>
#include <string>

int main()
{
    std::string Str;
    std::cin >> Str;
    for (std::size_t i = 0; i < Str.size() - 1; ++i)
    {
        if (Str[i] == 'A' && Str[i + 1] == 'C')
        {
            std::puts("Yes");
            return 0;
        }
    }

    std::puts("No");

    return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s, t;
    cin >> s >> t;
    char sp[s.size()];
    char tp[t.size()];
    REP(i, s.size()) {
        sp[i] = s[i];
    }
    REP(i, t.size()) {
        tp[i] = t[i];
    }
    sort(sp, sp + s.size(), less<char>());
    sort(tp, tp + t.size(), greater<char>());
    REP(i, min(s.size(), t.size())) {
        if(sp[i] < tp[i]) {
            cout << "Yes" << endl;
            return 0;
        }else if(sp[i] > tp[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    if(s.size() < t.size()) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
// #define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

/*---------------------------------------------------------------------------------------------------*/

int n,m;
int pa[200005],sz[200005];

map<int,vi> mp;

void begin_dsu()
{
    f(i,n+1)
        pa[i]=i,sz[i]=1;
}

int root(int x)
{
    while(x!=pa[x])
        {
        pa[x]=pa[pa[x]];
        x=pa[x];
        }
    return x;
}
void Union(int x,int y)
{
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)
        return;
    if(sz[rx]>sz[ry])
    {
        pa[ry]=rx;
        sz[rx]+=sz[ry];
    }
    else
    {
        pa[rx]=ry;
        sz[ry]+=sz[rx];
    }
}


void solve()
{
   cin >> n >> m;
   begin_dsu();
   f(i,m)
   {
       int x,y;
       cin >> x >> y;
       Union(x,y);
   }
   fp(i,1,n)
   {
       mp[root(i)].pb(i);
   }
   int mxm=0;
   for(auto x:mp)
   {
       vi v=x.S;
       mxm=max(mxm,(int)v.size());
   }
   cout << mxm << '\n';
  return;
} 

signed main()
{
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 28536
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int n, m;
vector<int> x, l;
ll ans = 0;

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        x.push_back(a);
    }
    sort(x.begin(), x.end());
    for (int i = 0; i + 1 < m; i++)
    {
        int d = abs(x[i] - x[i + 1]);
        ans += d;
        l.push_back(d);
    }
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    for (int i = 0; i < min(n - 1, m - 1); i++)
    {
        //out << l[i] << endl;;
        ans -= l[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private BufferedReader br;
	private int a, b, c, count;
	private StringTokenizer st;
	private int[][] cook;
	private boolean Isloop;

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		new Main().start();
	}

	private void start() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		st = new StringTokenizer(br.readLine());
		a = Integer.parseInt(st.nextToken());
		b = Integer.parseInt(st.nextToken());
		c = Integer.parseInt(st.nextToken());
		cook = new int[2][3];
		cook[1][0] = a;
		cook[1][1] = b;
		cook[1][2] = c;
		count = 0;
		Isloop = false;
		while (true) {
			if (cook[1][0] % 2 == 1 || cook[1][1] % 2 == 1 || cook[1][2] % 2 == 1) {
				break;
			}
			cook[0][0] = (cook[1][1] / 2) + (cook[1][2] / 2);
			cook[0][1] = (cook[1][0] / 2) + (cook[1][2] / 2);
			cook[0][2] = (cook[1][1] / 2) + (cook[1][0] / 2);
			for (int i = 0; i < 3; i++) {
				cook[1][i] = cook[0][i];
			}
			if (cook[1][0] == a && cook[1][1] == b && cook[1][2] == c) {
				Isloop = true;
				break;
			}
			count++;
		}
		if (Isloop) {
			System.out.println("-1");
		} else {
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int a,b,c;
    cin>>a>>b>>c;
    long long int d[10];
    d[0]=a*c-b;
    for(int i=0;i<10;i++){
        cout<<d[i]<<endl;
        if(i<9) d[i+1]=a*d[i]-b;
    }
}


Measured memory_bytes: 256
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<lint> cnt(N+1);
    cnt[0]=0;
    cnt[1]=0;
    reps(i,2,N) {
        cnt[i]=cnt[i-1];
        if((S[i-2]=='A')&&(S[i-1]=='C')) cnt[i]++;
    }
    vector<int> r(Q), l(Q);
    rep(i,Q) cin >> l[i] >> r[i];
    rep(i,Q) cout << cnt[r[i]]-cnt[l[i]] << endl;
	return 0;
}

Measured memory_bytes: 2688
N = int(input())
a = list(map(int, input().split()))

# 箱に書かれた数字が大きい順にボールを入れるか決定していくとi以上のiの倍数
# についてはすでにボールを入れるか入れないかを決定している

ans = [0] * N
for i in range(N - 1, -1, -1):
    if (i == N - 1):
        if (a[i] == 0):
            continue
        else:
            ans[i] = 1
            continue

    elif (i == 0):
        sum_a = sum(ans)
    else:
        sum_a = sum(ans[i::(i + 1)])

    if (a[i] == 0 and sum_a % 2 == 0):
        continue
    elif(a[i] == 0 and sum_a % 2 == 1):
        ans[i] = 1
    elif (a[i] == 1 and sum_a % 2 == 0):
        ans[i] = 1
    elif (a[i] == 1 and sum_a % 2 == 1):
        continue
    else:
        print(-1)
        exit()

M = 0
new_ans = []
for i in range(N):
    if (ans[i] == 1):
        M += 1
        new_ans.append(i + 1)

if (M == 0):
    print(M)
    exit()
print(M)
print(*new_ans)


Measured memory_bytes: 17860
#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)
const long long INF = numeric_limits<long long>::max();
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int a, b;
    cin>>a>>b;
    int res{};
    for( int i = a; i <= b; ++i )
    {
        string tmp = to_string(i);
        reverse(ALL(tmp));
        i == stoi(tmp) ? res++ : res;
    }
    cout << res << endl;
}

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

int main()
{
    int N;
    int y=0;
    cin >> N;
    string o = to_string(N);
    for (int i = 0; i < 3; i++)
    {
        if (o[i] == '7')
        {
            cout << "Yes";
            y += 1;
            break;
        }
    }
    if (y == 0)
    {
        cout << "No";
    }
}

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

using namespace std;

int a[333][333];
int sum[333 * 333];
pair<int, int> p[333 * 333];

int main() {
  int h, w, d;
  scanf("%d %d %d", &h, &w, &d);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf("%d", &a[i][j]);
      p[a[i][j]] = {i, j};
    }
  }
  auto dist = [&](pair<int,int>& a, pair<int,int>& b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
  };
  for (int i = 1; i <= h * w - d; i++) {
    sum[i + d] = sum[i] + dist(p[i], p[i + d]);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r;
    scanf("%d %d", &l, &r);
    printf("%d\n", sum[r] - sum[l]);
  }
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        int N = sc.nextInt();
        for(int i = 0; i<N; i++) {
            int x = sc.nextInt();
            int c = (map.containsKey(x))? map.get(x): 0;
            map.put(x,++c);
        }
        int sum = 0;
        for(int k: map.keySet()) {
            if(k-map.get(k)>0) {
                sum += map.get(k);
            }else {
                sum += map.get(k)-k;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 61936
N = int(input())
A =list(map(int,input().split()))
B =list(map(int,input().split()))
C =list(map(int,input().split()))
sum=0
old =100
sum_val =0
for x in A:
    B_index = x-1
    sum +=B[x-1]
    if B_index ==old+1:
        sum +=C[old]
    old = B_index
print(sum)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
arai = sum(A)
sunuke = 0
ans = 10000000000000000
for i in A[:-1]:
    arai -= i
    sunuke += i
    x = abs(sunuke - arai)
    if x < ans:
        ans = x
print(ans)

Measured memory_bytes: 76752
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvcha;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);

  char　小文字のほうが32大　　  　大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  int i = sqrt ( n ) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除             */

int a = 0, b = 0, c = 0, d = 0, x = 0, y = 0
, z = 0, n = 0, sum = 0, i = 0, ans = 0, cnt = 0;
string s = "";

int main(void) {
	string t,u;
	cin >> s >> t >> a >> b >> u;
	if (u == s)cout << a - 1 <<" "<< b << rt;
	else cout << a <<" "<< b - 1 << rt;
	please AC;
}

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

int main(){
    int K;
    std::string S;
    std::cin >> K >> S;
    
    if(K >= S.size()){
        std::cout << S << std::endl;
    }else{
        for(int i=0; i<K; i++){
            std::cout << S[i];
        }
        std::cout << "..." << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 3624
//一道可以收在blog的题~
//一开始很没思路 然后想贪心结果失败
//后来看到题解 才知道可以巧妙枚举~ 
//模拟4的T2也是巧妙枚举！！
#include <cstdio> 
#include <cstring>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long
const int MAXN=2*1e5+10;

LL a[MAXN];
LL ans1,ans2,ans3,ans4;
LL Min=INF;
int n;

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i],a[i]=a[i-1]+a[i];
	int l=1,r=3;
	for (int i=2;i<=n-2;i++)
	{
		while (l<i && abs(a[l]-a[0]-abs(a[i]-a[l]))>=abs(a[l+1]-a[0]-abs(a[i]-a[l+1]))) l++; 
		while (r<n && abs(a[r]-a[i]-abs(a[n]-a[r]))>=abs(a[r+1]-a[i]-abs(a[n]-a[r+1]))) r++;
		ans1=a[l]-a[0];
		ans2=a[i]-a[l];
		ans3=a[r]-a[i];
		ans4=a[n]-a[r];
	//	printf("%d %d %d %d\n",ans1,ans2,ans3,ans4);
		Min=min(Min,max(ans1,max(ans2,max(ans3,ans4)))-min(ans1,min(ans2,min(ans3,ans4))));
	}
	cout<<Min<<endl;
	return 0;
} 

Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <iostream>
#include <utility>
#include <vector>

int ans = 0;
int main()
{
    int n;
    std::cin >> n;
    std::vector<int> v_odd;
    std::vector<int> v_even;
    std::vector<std::pair<int, int>> odd_l{};
    std::vector<std::pair<int, int>> even_l{};
    for (int i = 0; i < n / 2; i++) {
        int v1;
        std::cin >> v1;
        v_odd.emplace_back(v1);
        int v2;
        std::cin >> v2;
        v_even.emplace_back(v2);
    }
    for (const auto& v : v_odd) {
        bool is = false;
        for (auto& e : odd_l) {
            if (e.first == v) {
                e.second++;
                is = true;
                break;
            }
        }
        if (not is) {
            int v_ = v;
            odd_l.push_back(std::make_pair<int, int>(std::move(v_), 1));
        }
    }
    for (const auto& v : v_even) {
        bool is = false;
        for (auto& e : even_l) {
            if (e.first == v) {
                e.second++;
                is = true;
                break;
            }
        }
        if (not is) {
            int v_ = v;
            even_l.push_back(std::make_pair<int, int>(std::move(v_), 1));
        }
    }
    std::sort(odd_l.begin(), odd_l.end(), [](auto& a, auto& b) { return a.second > b.second; });
    std::sort(even_l.begin(), even_l.end(), [](auto& a, auto& b) { return a.second > b.second; });

    if (odd_l.at(0).first != even_l.at(0).first) {
        std::cout << n - odd_l.at(0).second - even_l.at(0).second << std::endl;
        return 0;
    }

    std::pair<int, int> a;
    a.first = -1;
    a.second = 0;
    if (odd_l.size() == 1) {
        odd_l.emplace_back(a);
    }
    if (even_l.size() == 1) {
        even_l.emplace_back(a);
    }

    if (odd_l.at(1).second + even_l.at(0).second > odd_l.at(0).second + even_l.at(1).second) {
        std::cout << n - odd_l.at(1).second - even_l.at(0).second << std::endl;
    } else {
        std::cout << n - odd_l.at(0).second - even_l.at(1).second << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <algorithm>
#include <stdint.h>

using namespace std;

int max (int a, int b)
{
  return (a>b)? a : b;
}

int main()
{
  int64_t N, K;
  cin >> N >> K;

  int64_t cnt=0;

  for (int64_t b=K; b <= N; ++b) {
    if (b==0)
      continue;
    int64_t x = (N+1)/b*(b-K) + max(0,(N+1)%b-K) + ((K==0)?-1:0);
    cnt += x;

    //cerr << b << ':' << x << endl; 
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

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

ll ModInverse(ll a,ll m){
	ll x,y;
	if(Extgcd(a,m,x,y)==1) return (x+m)%m;
	return 0;
}

ll fact[220001];

void InitFact(ll n,ll m){
	fact[1]=1;
	for(ll i=2; i<=n; ++i) fact[i]=(i*fact[i-1])%m;
}

ll ModFact(ll n,ll p,ll &e){
	e=0;
	if(n==0) return 1;

	ll res=ModFact(n/p,p,e);
	e+=n/p;

	if(n/p%2!=0) return res*(p-fact[n%p])%p;
	return res*fact[n%p]%p;
}

ll ModComb(ll n,ll k,ll p){
	if(n<0||k<0||n<k) return 0;
	ll e1,e2,e3;
	ll a1=ModFact(n,p,e1),a2=ModFact(k,p,e2),a3=ModFact(n-k,p,e3);
	if(e1>e2+e3) return 0;
	return a1*ModInverse(a2*a3%p,p)%p;
}

void Solve(){
	const ll mod=1000000007;
	InitFact(220000,mod);
	ll n,m,k;
	cin >> n >> m >> k;

	ll res=0;
	REP(i,0,k+1){
		ll a=(ModComb(n+2*i,i,mod)-ModComb(n+2*i,i-1,mod)+mod)%mod;
		ll b=(ModComb(m+2*(k-i),k-i,mod)-ModComb(m+2*(k-i),(k-i)-1,mod)+mod)%mod;
		ll c=ModComb(n+m+2*k,n+2*i,mod);
		res+=a*b%mod*c%mod;
		res%=mod;
	}

	cout << res << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 2908
#include<stdio.h>
#include<stdio.h>
int search_line(char *n, char c) {
	char num[3][3];
	int i, j,a=0,flag;

	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			num[i][j] = n[a++];
		}
	}

	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			flag = 1;
			if (num[i][j] == 's' || num[i][j] == c) {
				flag = 0;
				break;
			}
		}
		if (flag)return 1;
	}

	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			flag = 1;
			if (num[j][i] == 's' || num[j][i] == c) {
				flag = 0;
				break;
			}
		}
		if (flag)return 1;
	}

	flag = 1;
	for (i = 0; i < 3; i++) {
		if (num[i][i] == 's' || num[i][i] == c) {
			flag = 0;
			break;
		}
	}
	if (flag) return 1;

	flag = 1;
	for (i = 0; i < 3; i++) {
		if (num[i][2-i] == 's' || num[i][2-i] == c) {
			flag = 0;
			break;
		}
	}
	if (flag) return 1;
	return 0;
}

int main(void)
{
	char num[10];

	while (scanf("%s",num) != EOF) {
		
		if (search_line(num, 'x'))
			printf("o\n");
		else if (search_line(num, 'o'))
			printf("x\n");
		else
			printf("d\n");
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

int main(){
    ll N,S;
    cin >> N >> S;
    vector<ll> X(N),P(N),L,R,res;
    for(int i=0;i<N;i++){
        cin >> X[i] >> P[i];
        if(X[i]<S) L.emplace_back(i);
        else R.emplace_back(i);
    }
    if(L.empty()){
        cout << X[R.back()]-S << endl;
        return 0;
    }
    if(R.empty()){
        cout << S-X[L.front()] << endl;
        return 0;
    }
    int ls = L.size(),rs = R.size(),l = 0,r = 0;
    reverse(R.begin(),R.end());
    ll sum = P[R[0]]+P[L[0]];
    bool left = true;
    if(P[L[0]]>=P[R[0]]){
        res.emplace_back(X[R[0]]);
        r = 1;
    }else{
        res.emplace_back(X[L[0]]);
        l = 1;
        left = false;
    }
    while(l<ls && r<rs){
        if(left){
            if(sum>=P[R[r]]){
                res.emplace_back(X[R[r]]);
                sum += P[R[r]];
                r++;
            }else{
                res.emplace_back(X[L[l]]);
                sum += P[R[r]];
                l++;
                left = false;
            }
        }
        else{
            if(sum>P[L[l]]){
                res.emplace_back(X[L[l]]);
                sum += P[L[l]];
                l++;
            }else{
                res.emplace_back(X[R[r]]);
                sum += P[L[l]];
                r++;
                left = true;
            }
        }
    }
    if(left && l!=ls) res.emplace_back(X[L[l]]);
    else if(!left && r!=rs) res.emplace_back(X[R[r]]);
    res.emplace_back(S);
    ll ans = 0;
    reverse(res.begin(),res.end());
    for(int i=0;i<res.size();i++){
        if(i!=res.size()-1) ans += abs(res[i+1]-res[i]);
    }
    cout << ans << endl;
}

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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    map<ll,ll> cnt;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    
    ll q;
    std::cin >> q;
    for (int iii = 0; iii < q; iii++) {
        ll b,c;
        std::cin >> b>>c;
        sum = sum - cnt[b]*b + cnt[b]*c;
        cnt[c]+=cnt[b];
        cnt[b]=0;
        std::cout << sum << std::endl;
    }
}


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



int main(){
  int n,k;
  cin >> n >> k;
  long long ans = 0;
  int mod = pow(10,9)+7;
  vector<long long> small(n+2-k,0);
  vector<long long> large(n+2-k,0);
  for(int i=0; i<k; i++){
    small[0]+=i;
    large[0]+=n-i;
  }
  
  for (int i=1; i<n+2-k; i++){
    small[i] = small[i-1]+k+i-1;
    large[i] = large[i-1]+(n-i-k+1);
  }

  
  for(int i=0; i<n+2-k; i++){
    ans += large[i]-small[i]+1;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6352