akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
}

int solve(){
    cout << N/3 << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    int students[n][2];
    int points[m][2];

    rep(i, n)
        cin >> students[i][0] >> students[i][1];
    rep(j, m)
        cin >> points[j][0] >> points[j][1];
    
    rep(i, n)
    {
        int p;
        int best_d = 1000000000;
        rep(j,m)
        {
            int d = abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1]);
            if (d < best_d)
            {
                p = j;
                best_d = d;
            }
        }
        p++;
        cout << p << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int dp[10][101];
void solve() {
  int i0, i1, i2, i3, i4, i5, i6, i7, i8;
  for (i0 = 0; i0 < 10; i0 ++) for (i1 = 0; i1 < 101; i1 ++) dp[i0][i1] = 0;
  for (i0 = 0; i0 < 10; i0 ++) {
    dp[1][i0] ++;
    for (i1 = i0 + 1; i1 < 10; i1 ++) {
      dp[2][i0 + i1] ++;
      for (i2 = i1 + 1; i2 < 10; i2 ++) {
	dp[3][i0 + i1 + i2] ++;
	for (i3 = i2 + 1; i3 < 10; i3 ++) {
	  dp[4][i0 + i1 + i2 + i3] ++;
	  for (i4 = i3 + 1; i4 < 10; i4 ++) {
	    dp[5][i0 + i1 + i2 + i3 + i4] ++;
	    for (i5 = i4 + 1; i5 < 10; i5 ++) {
	      dp[6][i0 + i1 + i2 + i3 + i4 + i5] ++;
	      for (i6 = i5 + 1; i6 < 10; i6 ++) {
		dp[7][i0 + i1 + i2 + i3 + i4 + i5 + i6] ++;
		for  (i7 = i6 + 1; i7 < 10; i7 ++) {
		  dp[8][i0 + i1 + i2 + i3 + i4 + i5 + i6 + i7] ++;
		  for (i8 = i7 + 1; i8 < 10; i8 ++) {
		    dp[9][i0 + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8] ++;
		  }
		}
	      }
	    }
	  }
	}
      }
    }
  }
}
int main() {
  int n, s;
  solve();
  while(1) {
    scanf("%d %d", &n, &s);
    if (!(n||s)) break;
    printf("%d\n", dp[n][s]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<int> cnt(n, 0);
    for (int i = 0; i + 1 < n; i++) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            cnt[i + 1]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cnt[i] += cnt[i - 1];
    }
    while (q--) {
        int l, r; cin >> l >> r;
        l--, r--;
        cout << cnt[r] - cnt[l] << "\n";
    }
}


Measured memory_bytes: 1488
#include <cstdio>
#include <cmath>

int main()
{
	int W, H, x, y, r;

	scanf(" %d %d %d %d %d", &W, &H, &x, &y, &r);

	if((x + r) > W || (x - r) < 0 || (y + r) > H || (y + r) < 0){
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 1012
#include <iostream>

using namespace std;



int minimum(int a, int b, int c){
    if(a<=b && a<=c) {
        return a;
    }else if(b<=c && b<=a) {
        return b;
    }else if(c<=a && c<=b) {
        return c;
    }
}



int main(){
    int A, B, C;

    cin >> A >> B >> C;

    cout << minimum(A+B, B+C, C+A) << endl;

    return 0;
}

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

one_count=0
one_max=0
i=0

for i in range(len(A)):
    if A[i]==1:
        one_count=one_count+1
    else:
        if one_count>one_max:
            one_max=one_count
        one_count=0
if one_count>one_max:
    one_max=one_count

print(one_max+1)



Measured memory_bytes: 5596
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int m[20][20];

int main() {
	int i,j;
	int x,y;
	while(cin>>x>>y,x){
		memset(m,0,sizeof(m));
		int n=in();
		for(i=0;i<n;i++){
			int xx,yy;
			cin>>xx>>yy;
			m[yy][xx]=-1;
		}
		for(j=1;j<=y;j++){
			for(i=1;i<=x;i++){
				if(m[j][i]==-1)m[j][i]=0;
				else if(i==1&&j==1)m[j][i]=1;
				else if(i==1)m[j][i]=m[j-1][i];
				else if(j==1)m[j][i]=m[j][i-1];
				else m[j][i]=m[j-1][i]+m[j][i-1];
			}
		}
		cout<<m[y][x]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        int M = 0;
        int Sum = 0;
        for (M = 0; M <= N; M++) { Sum += M; if (Sum >= N) break; }
        int R = Sum - N;
        for (int i = 1; i <= M; i++) {
            if (i == R) continue;
            Console.WriteLine(i);
        }
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    long n,a,b,c,d,e;
    cin >> n;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;

    char cc = 'e';
    if (a <= b && a <= c && a <= d && a <= e) {
        cc = 'a';
    } else if (b <= a && b <= c && b <= d && b <= e) {
        cc = 'b';
    } else if (c <= b && c <= a && c <= d && c <= e) {
        cc = 'c';
    } else if (d <= b && d <= c && d <= a && d <= e) {
        cc = 'd';
    } else if (e <= b && e <= c && e <= d && e <= a) {
        cc = 'e';
    }

    long p[7];
    // p[0] = ;
    p[1] = n; // a
    p[2] = 0; // b
    p[3] = 0; // c
    p[4] = 0; // d
    p[5] = 0; // e
    p[6] = 0;

    long time = 0;
    p[1] = 0;
    switch (cc)
    {
        case 'a':
            time = n / a;
            if (n % a > 0) time++;
            p[2] = a;
            break;
        case 'b':
            time = 1 + n / b;
            if (n % b > 0) time++;
            p[3] = b;
            break;
        case 'c':
            time = 2 + n / c;
            if (n % c > 0) time++;
            p[4] = c;
            break;
        case 'd':
            time = 3 + n / d;
            if (n % d > 0) time++;
            p[5] = d;
            break;
        case 'e':
            time = 4 + n / e;
            if (n % e > 0) time++;
            cout << time << endl;
            return 0;
    }

    while (true) {
        if (p[5] < e) {
            p[5] = 0;
        } else {
            p[5] -= e;
        }
        if (p[4] < d) {
            p[5] += p[4];
            p[4] = 0;
        } else {
            p[5] += d;
            p[4] -= d;
        }
        if (p[3] < c) {
            p[4] += p[3];
            p[3] = 0;
        } else {
            p[4] += c;
            p[3] -= c;
        }
        if (p[2] < b) {
            p[3] += p[2];
            p[2] = 0;
        } else {
            p[3] += b;
            p[2] -= b;
        }
        if (p[1] < a) {
            p[2] += p[1];
            p[1] = 0;
        } else {
            p[2] += a;
            p[1] -= a;
        }

        time++;
        if (p[1] == 0 && p[2] == 0 && p[3] == 0 && p[4] == 0 && p[5] == 0) break;
    }
    
    cout << time << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

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

int main() {
    int t; cin >> t;
    rep(i,t) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        bool ans;
        if (a < b || d < b) {cout << "No" << endl; continue;}
        if (b-1 <= c) {cout << "Yes" << endl; continue;}
        ll g = gcd(b,d);
        if (c < a - ((a-b)/g+1)*g) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3624
import math
x = int(input())

def eratosthenes(x):
  X = int(math.sqrt(x))
  prime = [i for i in range(2,x+1)]
  for _ in range(2,X+1):
    prime = [i for i in prime if i%_!=0 or i==_]
  return prime
prime = eratosthenes(2*10**5)

for i in prime:
  if x<=i:
    print(i)
    exit()

Measured memory_bytes: 11800
module module_sort
    use iso_fortran_env
    implicit none

    interface quicksort
        module procedure :: int32_qsort
        module procedure :: int64_qsort
    end interface quicksort
contains

    recursive function int32_qsort(m) result(res)
        integer(int32), intent(in) :: m(:)
        integer(int32) :: res(size(m)) 

        if (size(m) <= 1) then; res = m
        else; res = [int32_qsort( pack(m(2:), m(2:) >= m(1)) ), m(1), int32_qsort( pack(m(2:), m(2:) < m(1)) )]
        end if

    end function int32_qsort

    recursive function int64_qsort(m) result(res)
        integer(int64), intent(in) :: m(:)
        integer(int64) :: res(size(m)) 

        if (size(m) <= 1) then; res = m
        else; res = [int64_qsort( pack(m(2:), m(2:) >= m(1)) ), m(1), int64_qsort( pack(m(2:), m(2:) < m(1)) )]
        end if

    end function int64_qsort

end module module_sort

program main
    use module_sort
    use iso_fortran_env
    implicit none
    integer(int64) :: n
    integer(int64), allocatable :: ai(:)
    integer(int64) :: i, ie
    integer(int64) :: ans

    read *, n
    allocate( ai(n) )
    read *, ai( 1:n )
!    ai = quicksort( ai )
    call qsort( ai )
    ai(n:1:-1) = ai(1:n)


    if ( mod((n-1), 2) == 0 ) then
        ie = (n-1) / 2
        ans = ai(1) + ai(ie + 1)
    else
        ie = n / 2
        ans = ai(1)
    endif

    do i = 2, ie
        ans = ans + ai(i) * 2
    enddo

    print *, ans

contains

recursive subroutine qsort(a)
  implicit none
  integer(8),intent(inout) :: a(:)
  integer(8)::i,j,toobig,toosmall,pv,n

  n = size(a)
i = 1
j = n
pv = a((i+j)/2)
do
   do
     if (a(i) < pv) then
       i = i+1
     else
       exit
     end if
   end do
   do
     if(a(j) > pv) then
       j = j-1
     else
       exit
     end if
   end do
   if (i>=j) then
     exit
   else
     toobig = a(j)
     toosmall = a(i)
     a(i) = toobig
     a(j) = toosmall
     i = i+1
     j = j-1
   end if
 end do
 if (i > 2) then
   call qsort(a(1:i-1))
 end if
 if (j < n-1) then
   call qsort(a(j+1:n))
 end if
end subroutine qsort


end program main


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

for i in range(1,10**6):
    if i * 2019 >= L and i*2019 <= R:
        print(0)
        exit()

ans = 10**20

for i in range(L,min(L+2019,R+1)):
    for j in range(L,min(L+2019,R+1)):
        if i >= j:
            continue
        ans = min(ans,(i*j)%2019)
for i in range(max(L,R-2019),R+1):
    for j in range(max(L,R-2019),R+1):
        if i >= j:
            continue
        ans = min(ans,(i*j)%2019)
print(ans)


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

using namespace std;

using ll = long long;

int main(void){
    ll n,x;

    ll tax = 108, base=100;

    cin >> n;

    x = n*base/tax;

    if((n*base)%tax != 0ll){
        x+=1ll;
    }

    if(x*tax/base==n){
        cout << x << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
    int n, m;
    
    while (scanf("%d %d", &n, &m) && n){
        int ctr = 0;
        char tmp[64];
        sprintf(tmp, "%d", m);
        string s = tmp;
        
        for (int x = m; x; x /= 10) ctr++;
        
        vector<pair<int, int> > v;
        for (int i = 0; i < 1 << (ctr - 1); i++){
            int p = 0;
            int sum = 0;
            for (int j = 0; j < ctr - 1; j++){
                if (i >> j & 1){
                    string s2 = s.substr(p, j + 1 - p);
                    sum += atoi(s2.c_str());
                    p = j + 1;
                }
            }
            
            sum += atoi(s.substr(p, ctr - p).c_str());
            v.push_back(make_pair(sum, i));
        }
        
        sort(v.begin(), v.end());
        
        if (v[0].first > n){
            printf("error\n");
        }
        else {
            int minp = 0, ct = 1;
            for (int i = 1; i < v.size(); i++){
                if (v[i].first <= n && v[minp].first <= v[i].first){
                    if (v[minp].first == v[i].first){
                        ct++;
                    }
                    else {
                        minp = i;
                        ct = 1;
                    }
                }
            }
            if (ct > 1){
                printf("rejected\n");
            }
            else {
                printf("%d ", v[minp].first);
                int p = 0;
                for (int j = 0; j < ctr - 1; j++){
                    if (v[minp].second >> j & 1){
                        string s2 = s.substr(p, j + 1 - p);
                        printf("%s ", s2.c_str());
                        p = j + 1;
                    }
                }
                
                printf("%s\n", s.substr(p, ctr - p).c_str());
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 1236
n = int(input())
i = 1
while i <= n:
    if i%3 == 0:
        print(' ' + str(i), end="")
    else:
        num = i
        while 0 < num:
            if num % 10 == 3:
                print(' ' + str(i), end="")
                break
            num //= 10
    i += 1
print()

Measured memory_bytes: 7868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
//#define SIZE 200105
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
typedef pair<pair<ll, ll>,int> PP;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 998244353;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};

int N;
string str;
int beki2[214514];
ll dp[414514]={0};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>N>>str;
	beki2[0]=1;
	for(int i=1;i<=N;i++){
		beki2[i]=2ll*beki2[i-1]%MOD;
	}
	//周期は奇数*2^ord2(N)*2のみがある。
	//N/奇数*2^ord2(N) が奇数　これを動かす。
	//周期がLで割り切れるものの個数をdp[L]に計算する。
	for(int k=1;k<=N;k+=2){
		if(N%k==0){
			ll L=N/k;//これの2倍が周期
			bool flag=1;
			for(int i=0;i<N;i++){
				if(str[i]=='1'&&(i<L||str[i-L]=='1')){
					if(i<L)dp[L]+=beki2[L-i-1];
					else dp[L]+=1;
					dp[L]%=MOD;
				}
				if(i>=L&&str[i]==str[i-L]){
					flag=0;
					break;
				}
			}
			if(flag)dp[L]=(dp[L]+1)%MOD;//
		}
		
	}
	ll ans=0;
	//包徐で整理。
	for(int i=1;i<=N;i++)if(N%i==0&&N/i%2==1&&dp[i]!=0){
		ans=(ans+(ll)2*dp[i]*i);//周期2iをその個数足す。
		ans%=MOD;
		for(int k=2;k<=N/i;k++){
			dp[k*i]=(dp[k*i]-dp[i]+MOD)%MOD;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2964
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]

# hをソートして、K本の木を含む区間をスライドさせていく。区間の両端の差が最も小さくなる区間が最適
h.sort()
h_diff = []

for i in range(N-K+1):
    h_diff.append(abs(h[i] - h[i+K-1]))

print(min(h_diff))

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<char> s(n);
  rep(i,n){
    cin >> s[i];
    if(i == k-1) s[i] += 32;
  }
  rep(i,n) cout << s[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	std::string s; cin >> s;
	int K; scanf("%d", &K);
	
	const int MOD = 1e9 + 7;
	
	auto dp = make_v<i64>(s.size() + 1, K, 2); dp[0][0][1] = 1;
	for(int i = 0; i < s.size(); i++) {
		int D = s[i] - '0';
		
		for(int k = 0; k < K; k++) {
			for(int j = 0; j < 2; j++) {
				int lim = (j ? D + 1 : 10);
				for(int d = 0; d < lim; d++) {
					(dp[i + 1][(k + d) % K][j && (d == D)] += dp[i][k][j]) %= MOD;
				}
			}
		}
	}
	
	printf("%lld\n", ((dp[s.size()][0][0] + dp[s.size()][0][1]) % MOD + MOD - 1) % MOD);
	return 0;
}


Measured memory_bytes: 55296
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009
int main(void){
	double x1, x2, y1, y2, ans;
	ans = 0;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	ans = ((x2 - x1)*(x2 - x1)) + ((y2 - y1)*(y2 - y1));
	ans = sqrt(ans);
	printf("%f\n", ans);
	return 0;
}

Measured memory_bytes: 2740
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    string s;
    cin>>s;
    ll tt = 700;
    for(char c:s)if(c=='o')tt += 100;
    cout<<tt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int x, y, z, k;
int a[1010], b[1010], c[1010];
vector<int>ta, ans;

signed main() {
	cin >> x >> y >> z >> k;
	rep(i, x)cin >> a[i];
	rep(i, y)cin >> b[i];
	rep(i, z)cin >> c[i];
	rep(i, x) {
		rep(j, y) {
			ta.push_back(a[i] + b[j]);
		}
	}
	sort(all(ta));
	reverse(all(ta));
	int n = min((int)ta.size(), k);
	rep(i, n) {
		rep(j, z) {
			ans.push_back(ta[i] + c[j]);
		}
	}
	sort(all(ans));
	reverse(all(ans));
	rep(i, k)cout << ans[i] << endl;
}

Measured memory_bytes: 43364
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int L,R;
    cin >> L >> R;
    int ans = 2018;
    int r = min(R,L+2019);
    for(int i = L; i <= r; i++) {
        for(int j = i+1; j <= r; j++) {
        ans = min(ans , (i*j)%2019);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	vector<int> vec;
	int a, b, c;
	cin >> a >> b >> c;
	vec.push_back(a);
	vec.push_back(b);
	vec.push_back(c);
	sort(vec.begin(), vec.end());
	cout << vec[2]*10 + vec[1] + vec[0] << endl;
	return 0;
}

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

a=0
start=0
end=0

for i in range(1,N+2):
    start=start+i-1
    end=end+N-i+1

    if i >= K:
        a = (a + (end - start)+1) % (10**9+7)

print(a % (10**9+7))


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		if(ans>k)
		{
			ans+=k;
		}
		else
		{
			ans+=ans;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define GIO ios_base::sync_with_stdio(0);cin.tie(0);
 
int main()
{ GIO;
 int a;
 cin>>a;
 if(a%2==0) cout<<a<<endl;
 else cout<<2*a<<endl;
 
 
return 0;
}

Measured memory_bytes: 256
def prime(n):
    p = []
    flag = [True] * (n - 1)
    for i in range(n - 1):
        if flag[i] == True:
            p.append(i + 2)
            num = i
            while num <= n - 2:
                flag[num] = False
                num += i + 2
    return set(p)

p1 = prime(10 ** 5)
p2 = [0]
for i in range(10 ** 5):
    if i % 2 == 1:
        p2.append(p2[-1])
        continue
    else:
        if i + 1 in p1 and (i + 2) // 2 in p1:
            p2.append(p2[-1] + 1)
        else:
            p2.append(p2[-1])
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(p2[r] - p2[l -1])

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

int main(void)
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  

  int sum1,sum2,sum3,sum4;

  sum1=a+c;
  sum2=a+d;
  sum3=b+c;
  sum4=b+d;

  int mins=min(min(sum1,sum2),min(sum3,sum4));

  cout<<mins<<endl;
  
}

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

int main(void){
  int N;
  string S;
  cin >> N >> S;
  int x=0, max_x=0;
  for(int i=0;i<N;++i){
    if(S[i] == 'I'){
      ++x;
    }
    else{
      --x;
    }
    if(max_x < x){
      max_x = x;
    }
  }
  cout << max_x << endl;
}


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

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    int A[2020];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    int ans=INT_MAX;
    for(int i=0; i<N; i++){
        //A[i]未満のリストを作る
        vector<int> list(0);
        list.push_back(-1);
        for(int j=0; j<N; j++){
            if(A[j]<A[i]) list.push_back(j);
        }
        list.push_back(N);

        vector<int> glo(0);
        //
        for(int j=0; j<list.size()-1; j++){
            vector<int> now(0);
            for(int k=list.at(j)+1; k<list.at(j+1); k++){
                now.push_back(A[k]);
            }
            if(now.size() < K) continue;
            sort(now.begin(),now.end());
            for(int k=0; k<now.size()-K+1; k++){
                glo.push_back(now.at(k));
            }
        }

        //
        sort(glo.begin(),glo.end());
        if(glo.size()<Q) continue;
        ans=min(ans,glo.at(Q-1)-glo.at(0));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// 未解決

#include <bits/stdc++.h>
#include <iostream>
using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
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 in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  bool ans = true;
  if (n % 2 == 1) {
    ans = false;
  } else {
    REP(i, n / 2) {
      if (s[i] != s[i + n / 2]) {
        ans = false;
        break;
      }
    }
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
};


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int br1, br2;
int main(){
    string S,St;
    cin >> S;
    St = S;
    int n = S.size();
    for(int i = 0; i < n-1; i++){
        if(S[i]==S[i+1])
        {br1++;
        if(S[i]=='0')
        S[i+1] = '1';
        else
        S[i+1] = '0';
        }       
    }
    br2++;
    if(St[0]=='0')
        St[0] = '1';
        else
        St[0] = '0';
    for(int i = 0; i < n-1; i++){
    if(St[i]==St[i+1])
    {br2++;
    if(St[i]=='0')
        St[i+1] = '1';
        else
        St[i+1] = '0';
        }
    }
    cout << min(br1,br2);
}

Measured memory_bytes: 512
/**
stirling number
*/

#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define sd second
#define ll long long
 
using namespace std;
 
const int maxn = 3010;
const ll oo = 1e18;
 
int n,base;
ll p1[maxn*maxn],p2[maxn],C[maxn][maxn],f[maxn][maxn],pp[maxn];
 
ll sum(ll a, ll b) {
    return (a+b)%base;
}
 
ll sub(ll a, ll b) {
    return (a-b+base)%base;
}
 
ll mul(ll a, ll b) {
    return (a*b)%base;
}
 
ll pw(ll a, ll b) {
    if (b == 0) return 1ll;
    if (b == 1) return a;
    ll tg = pw(a,b/2);
    tg = mul(tg,tg);
    if (b%2) return mul(tg,a);
    else return tg;
 
}
 
void init() {
    for (int i=0;i<maxn;i++) {
        C[0][i]=1;
        for (int k=1;k<=i;k++) C[k][i] = sum(C[k-1][i-1],C[k][i-1]);
    }
    p2[0]=1; p1[0] = 1;
    for (int i=1;i<maxn;i++) p2[i] = (p2[i-1] * 2) % (base-1);
    for (int i=0;i<=n;i++) pp[i] = pw(2ll,p2[n-i]);
    for (int i=1;i<maxn*maxn;i++) p1[i] = (p1[i-1] * 2) % base;
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
  //  freopen("in.txt","r",stdin);
    cin>>n>>base;
    init();
    f[0][0] = 1;
    for (int i=0;i<=n;i++) {
        for (int j=1;j<=i;j++) f[i][j] = sum(f[i-1][j-1], mul(f[i-1][j],1ll*j));
    }
    ll ans = 0;
    for (int i=0;i<=n;i++) {
       // cout<<dp[i]<<" "<<C[i][n]<<endl;
        ll dp =0;
        for (int j=0;j<=i;j++) {
            dp = sum(dp, mul(f[i][j], mul(p1[(n-i)*j] , pp[i])));
            if (j) dp = sum(dp,mul(mul(f[i][j],j), mul(p1[(n-i)*(j-1)] , pp[i])));
        }
        if (i%2==0) ans = sum(ans,mul(dp,C[i][n]));
        else ans = sub(ans,mul(dp,C[i][n]));
    }
    cout<<ans;
}

Measured memory_bytes: 211072
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rnk=[0]*(n+1)

    def Find_Root(self,x):
        if self.root[x]<0:
            return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)
        if x==y:
            return
        elif self.rnk[x]>self.rnk[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if self.rnk[x]==self.rnk[y]:
                self.rnk[y]+=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def Count(self,x):
        return -self.root[self.Find_Root(x)]

h,w=map(int,input().split())
g=[list(input()) for _ in range(h)]
uf=UnionFind(h*w)
dyx=[(1,0),(-1,0),(0,1),(0,-1)]
for i in range(h):
    for j in range(w):
        if g[i][j]==".":
            continue
        p=i*w+j
        for dy,dx in dyx:
            y=i+dy
            x=j+dx
            if 0<=y<h and 0<=x<w:
                if g[y][x]==".":
                    np=y*w+x
                    uf.Unite(p,np)

rt=[0]*(h*w)
for i in range(h*w):
    rt[i]=uf.Find_Root(i)

m=min(rt)
rt=list(map(lambda x:x-m, rt))
m=max(rt)
a=[[0,0] for _ in range(m+1)]
for i in range(h*w):
    y=i//w
    x=i%w
    if g[y][x]=="#":
        a[rt[i]][0]+=1
    else:
        a[rt[i]][1]+=1
ans=0
for i,j in a:
    ans+=i*j

print(ans)


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

using namespace std;

const int maxn = 100010;
typedef long long ll;

int T, n;
ll a[maxn];
char s[maxn];

ll b[61];

void add(ll x) {
	for (int i = 60; i >= 0; i--) {
		if ((x >> i) & 1) {
			if (!b[i]) {
				b[i] = x;
				break;
			} else x ^= b[i];
		}
	}
}

int check(ll x) {
	for (int i = 60; i >= 0; i--) {
		if ((x >> i) & 1) {
			if (!b[i]) return 0;
			else x ^= b[i];
		}
	}
	return 1;
}

int main() {
	scanf("%d", &T);
	while (T--) {
		scanf("%d", &n);
		for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
		scanf("%s", s+1);
		for (int i = 0; i <= 60; i++) b[i] = 0;
		int ok = 1;
		for (int i = n; i >= 1; i--) {
			if (s[i] == '0') {
				add(a[i]);
			} else if (!check(a[i])) {
				ok = 0;
				break;
			}
		}
		printf("%d\n", 1-ok);
	}
	return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M,A,T;
  cin >> N >> M;
  T=0;
  for (int i=0;i<M;i++) {cin >> A;T+=A;}
  if (T>N) {cout << -1 << endl;} else {cout << N-T << endl;}
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}


const int N = 1e5 + 100;

vector<int> G[N];
bool vis[N];
int val[N];
vector<int> vec[N];
vector<pii> con;

void DFS(int u, int fa, vector<int> &ve) {
    vis[u] = true;
    ve.push_back(val[u]);
    for(int v : G[u]) {
        if(v == fa || vis[v]) continue;
        DFS(v, u, ve);
    }
}

multiset<int> st;
int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i ++) {
        scanf("%d", &val[i]);
    }
    for(int i = 1; i <= m; i ++) {
        int u, v;
        scanf("%d %d", &u, &v);
        u ++, v ++;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    int tot = 0;
    LL ans = 0;
    for(int u = 1; u <= n; u ++) {
        if(! vis[u]) {
            DFS(u, u, vec[++ tot]);
            con.push_back(pii(SZ(vec[tot]), tot));
            sort(ALL(vec[tot]));
            ans += vec[tot][0];
        }
    }

    if(SZ(con) == 1) return puts("0"), 0;
    int sz = SZ(con);
    for(int i = 1; i <= tot; i ++) {
        for(int j = 1; j < SZ(vec[i]); j ++) {
            st.insert(-vec[i][j]);
            if(SZ(st) > sz - 2) st.erase(st.begin());
        }
    } 
    if(SZ(st) < sz - 2) return puts("Impossible"), 0;

    for(auto it : st) ans -= it;
    cout << ans << endl;
} 


Measured memory_bytes: 11896
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!
    val b = readLine()!!
    val c = readLine()!!
    var count = 0
    for (i in 0..n - 1) {
        val ac = a[i]
        val bc = b[i]
        val cc = c[i]
        if (ac == bc && bc == cc) continue
        if (ac == bc || bc == cc || cc == ac) {
            count++
        } else {
            count += 2
        }
    }
    println(count)
}


Measured memory_bytes: 33728
#!/usr/bin/env python3


def solv(s):
    sum0 = 0
    sum1 = 0
    b = 0
    for a in s:
        if b == a:
            sum0 += 1
        else:
            sum1 += 1
        b = 1 - b

    ans = min(sum0, sum1)
    return ans


if __name__ == '__main__':

    s = map(int, input())
    ans = solv(s)
    print(ans)


Measured memory_bytes: 3188
import java.util.*;

class Main
{

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

        int a = scan.nextInt();
        int n = scan.nextInt();
        int m = scan.nextInt();
        int count = 0;
        for (int i = 1; i <= m; i++) {
            int total = 0;
            int d = i;
            while(d > 0) {
                total += d % 10;
                d = d / 10;
            }
            
            int zyo = 1;
            int g = total + a;
            for (int o = 0; o < n; o++) {
                zyo *= g;
            }
            
            if (zyo == i) {
                count += 1;
            }
        }
        System.out.println(count);
    }
}



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

main(){
  int l[3], cnt[4];
  for ( int i = 0; i < 4; i++ ) cnt[i] = 0;

  while(cin >> l[0] >> l[1] >> l[2]){

    sort(l, l+3);
    if ( l[0] + l[1] <= l[2] ) {
      for ( int i = 0; i < 4; i++ ){
	if ( i ) cout << " ";
	cout << cnt[i];
      }
      cout << endl;
      return 0;
    }

    cnt[0]++;
    if ( l[0]*l[0] + l[1]*l[1] == l[2]*l[2] ) cnt[1]++;
    else if  ( l[0]*l[0] + l[1]*l[1] < l[2]*l[2] ) cnt[3]++;
    else cnt[2]++;

  }
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <memory.h>

int bubble_sort(int lst[], int n);

int main(void) {
	int i, n;
	int lst[100];
	int count;
	memset((char*)lst, 0x00, sizeof(lst));

	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &lst[i]);
	}
	
	count = selection_sort(lst, n);
	
	for(i=0;i<n;i++) {
		printf("%d", lst[i]);
		if(i<n-1) {
			printf(" ");
		} else {
			printf("\n");
		}
	}
	printf("%d\n", count);
	
	return 0;
}

int selection_sort(int lst[], int n) {
	int i, j, tmp, count, index;
	for(i=0,count=0;i<n-1;i++) {
		index = i;
		for(j=i+1;j<n;j++) {
			if(lst[j] < lst[index]) {
				index = j;
			}
		}
		
		if(index != i) {
			tmp = lst[i];
			lst[i] = lst[index];
			lst[index] = tmp;
			count++;
		}
	}
	
	return count;
}

Measured memory_bytes: 604
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

cnt = [0]*3

for pp in p:
    if pp <= a: cnt[0] += 1
    elif pp <= b: cnt[1] += 1
    else: cnt[2] += 1
print(min(cnt))


Measured memory_bytes: 9180
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

ll dd;
//桁DP
ll digit_dp(string s){
  ll dp[s.size()+1][2][105];//上からi桁までjはNのi桁未満かそうでないか、kは問題の条件に応じて変化するboolean
  memset(dp,0,sizeof(dp));
  dp[0][0][0]=1;
  rep(i,s.size()) {//桁数が大きいのでstringで読み取り、各位ごとに数字に変換する
		int D = s[i] - '0';
		rep(j,2) {
			rep(k,dd) {
				for (int d = 0; d <= (j ? 9 : D); ++d){//i桁目がNのi桁目より小さければ9まではいる。そうでなければNのi桁目の数字以下が入る
					dp[i + 1][j || d < (j ? 9 : D)][(k+d)%dd] += dp[i][j][k];
          dp[i + 1][j || d < (j ? 9 : D)][(k+d)%dd]%=mod;
					}
			}
		}
	}
  //N未満ならdp[s.size()][1][条件]だけでよい
  return (dp[s.size()][0][0]+dp[s.size()][1][0]-1LL+mod)%mod;//0の場合を引いておく,modを足すのを忘れない
}

void solve(){
  string s;
  cin>>s>>dd;
  cout<<digit_dp(s)<<"\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int n,l,x,y,s;

int main(){
	cin>>n>>l;
	x=l,y=n+l-1;
	for(int i=x;i<=y;i++) s+=i;
	if(x>0) s-=x;
	if(y<0) s-=y;
	cout<<s;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;


int a[100005];

int main(){
  int n;cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  a[n] = 1000000001;
  int cnt = 0;
  int odd = 1;
  for(int i=1;i<=n;i++){
    if(a[i] != a[i-1]){
      if(odd%2) cnt++;
      odd = 1;
    } else {
      odd++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 640
io = STDIN
N=io.gets.to_i
a=io.gets.split.map(&:to_i)
def calc(a)
  lim=10**18
  return 0 if a.include?(0)
  a.inject(1) do |s,i|
    s=s*i
    return -1 if s>lim
    s
  end
end
puts calc(a)


Measured memory_bytes: 21656
import collections
N = int(input())
A = []
B = []
YHASHNUM = 1000000000
for i in range(N):
    A.append(list(map(int, input().split())))
#print(N, A)
if N == 1:
    print(1)
else:
    for i in A:
        #print(i[0], i[1])
        for j in A:
            if i == j:
                continue
            B.append(i[0] - j[0] + (i[1] - j[1]) * YHASHNUM)
    #print(B)
    C = collections.Counter(B)
    print(N - C.most_common()[0][1])




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

int main() {
        int N = 0, K = 0;
        cin >> N;
        while (N != 0) {
                vector<string> s(N);
                vector<string> u;
                cin >> K;
                rep(n, N) {
                        cin >> s.at(n);
                }
                switch (K) {
                        case 4:
                                rep(n1, N) {
                                        rep(n2, N) {
                                                if(n1 == n2) continue;
                                                rep(n3, N) {
                                                        if (n1 == n3 || n2 == n3) continue;
                                                        rep(n4, N) {
                                                                if (n1 == n4 || n2 == n4 || n3 == n4) continue;
                                                                u.push_back(s.at(n1) + s.at(n2) + s.at(n3) + s.at(n4));
                                                        }
                                                }
                                        }
                                }
                                break;
                        case 3:
                                rep(n1, N) {
                                        rep(n2, N) {
                                                if(n1 == n2) continue;
                                                rep(n3, N) {
                                                        if (n1 == n3 || n2 == n3) continue;
                                                        u.push_back(s.at(n1) + s.at(n2) + s.at(n3));
                                                }
                                        }
                                }
                                break;
                        case 2:
                                rep(n1, N) {
                                        rep(n2, N) {
                                                if(n1 == n2) continue;
                                                u.push_back(s.at(n1) + s.at(n2));
                                        }
                                }
                                break;
                }
                sort(u.begin(), u.end());
                u.erase(unique(u.begin(), u.end()), u.end());
                cout << u.size() << endl;
                cin >> N;
        }
        return 0;
}



Measured memory_bytes: 3284
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b==c+d){
        cout << "Balanced" << endl;
    }else if(a+b>c+d){
        cout << "Left" << endl;
    }else{
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256