akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  vector<ll>h(n);
  rep(i,n)cin>>h[i];
  ll d=a-b;
  auto judge=[&](ll mid){
    vector<ll>w=h;
    rep(i,n){
      w[i]-=b*mid;
    }
    ll cnt=0;
    rep(i,n){
      if(w[i]>0){
        cnt+=(w[i]+d-1)/d;
      }
    }
    if(cnt>mid)return 0;
    else return 1;
  };
  auto bs=[&](){
    ll l=-1,r=INF;
    while(r-l>1){
      ll mid=(l+r)/2;
      if(judge(mid)){
        r=mid;
      }
      else{
        l=mid;
      }
    }
    return r;
  };
  cout<<bs()<<endl;
  return(0);
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;



template <typename T>
class RMQ {
	T query(int l, int r, int a, int b, int k){
		if( l <= a && b <= r ){
			return seg[k];
		}else if( l < b && a < r ){
			int m = (b+a)/2;
			T vl = query(l,r, a, m, k*2);
			T vr = query(l,r, m, b, k*2+1);
			return min(vl, vr);	// merge
		}
		return INF;	// default value
	}
public:
	vector<T> seg;	// セグメントツリー (親:k/2  子:k*2,k*2+1)
	int N;
	RMQ(int size){
		N = 1;
		while( N < size ) N<<=1;
		seg.assign(N*2, INF);		// default value
	}
	void update(int pos, T v){
		for(int k=N+pos; k>0; k/=2){
			seg[k] = v;
			v = min(seg[k], seg[k^1]);	// merge
		}
	}
	// [l,r)
	T get(int l, int r){
		return query(l, r, 0, N, 1);
	}
	T get(int pos){		// =get(pos, pos+1)
		return seg[N+pos];
	}
};

int main(){
	//ios_base::sync_with_stdio(false);
	ll N, ans=0;
	ll x[200005], s[200005];

	cin >> N;
	rep(i,N) cin >> x[i] >> s[i];
	x[N] = x[N-1];

	rep(i,N) chmax(ans, s[i]);

//	set<ll> st;
//	map<ll,ll> mp;
//	rep(i,N) st.insert(x[i]);
//	for(auto t: st) mp[t] = mp.size();

	RMQ<ll> sg(200005);
	ll sum = 0;
	sg.update(0,0);
	rep(i,N){
		sum += s[i];
		ll mn  = sg.get(0,i+1);
		chmax(ans, sum - mn);
		ll d = x[i+1] - x[i];
		sum -= d;
		sg.update(i+1, sum);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7424
import java.util.Scanner;

/**
 * 0007: Debt Hell
 * @author ueuenonon
 */
public class Main {
    /** 最初の借金 */
    public static final double FIRST_DEBT = 100000.0;
    /** 利率 */
    public static final double INTEREST_RATE = 0.05;
    /** 切り上げの基準  */
    public static final double CEIL_BASE = 1000.0;

    /**
     * エントリポイント
     */
    public static void main(String args[]) {
        System.out.println(
            calcDebt(FIRST_DEBT, new Scanner(System.in).nextInt())
        );

    }

    /**
     * n週間後の借金額を計算する。（複利式）
     * 
     * @param firstDebt 最初の借金額
     * @param nWeeks 何週間後の借金額を求めるか
     * @return 指定した週間後の借金額
     */
    private static int calcDebt(double firstDebt, int nWeeks) {
        double debt = firstDebt;
        for(int i = 0; i< nWeeks; i++) {
            debt = Math.ceil(debt * (1 + INTEREST_RATE) / CEIL_BASE) * CEIL_BASE;
        }
        return (int)debt;
    }
} 

Measured memory_bytes: 17164
n,p=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
o=0
n.times do |i|
  o+=1 if a[i].odd?
end
oo=0
i=1
while i<=o
  k=1
  i.times do |j|
    k*=(o-j)
  end
  i.times do |j|
    k/=(j+1)
  end
  oo+=k
  i+=2
end
puts p>0 ? oo*2**(n-o) : 2**n-(oo*2**(n-o))

Measured memory_bytes: 1788
n=int(input())
h=list(map(int,input().split()))
l=[]
for i in range(n-1):
    if h[i+1]-h[i]<=0:
        l.append(1)
    else:
        l.append(0)
ans=0
mn=0
for j in range(len(l)):
    if l[j]==0:
        ans=0
    else:
        ans+=1
        mn=max(ans,mn)
print(max(mn,ans))

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

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

  if (a == b && b == c) {
    cout << 1 << endl;
  }
  
  else if (a == b || a == c || b == c) {
    cout << 2 << endl;
  }
  else {
    cout << 3 << endl;
  }
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;



ll F(ll N) {
    if((N+1)%2==1) {
        if(N%4==0) return N;
        else return N^1;
    }else {
        if((N+1)%4==0) return 0;
        else return 1;
    }
}

int main(void) {
    ll A, B;
    cin >> A >> B;
    
    pt((F(A-1)^F(B)));
    
}





Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) cout << s[i];
    }
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

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

int main(){
  int a=0,b=0,c=0;
  cin >> a >> b >> c;
  int X=0,count=0;
  cin >> X;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
      if((500*i+100*j+50*k) == X) count++;
      }
    }
  }
  cout << count << endl;
} 


Measured memory_bytes: 256
N = int(input())
S = input()
b = S.count(".")    # 黒に変えるべき石の数
w = 0               # 白に変えるべき石の数
ans = b

for i in range(N):
    if S[i] == "#":
        w += 1

    else:
        b -= 1
    t = w + b
    ans = min(ans, t)

print(ans)

Measured memory_bytes: 3500
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

ll gcd(ll x, ll y)
{
    while (y > 0)
    {
        ll tmp = y;
        y = x % y;
        x = tmp;
    }
    return x;
}

ll lcm(ll x, ll y)
{
    return x / gcd(x, y) * y;
}

ll facctorialMethod(ll k)
{
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum %= 1000000007;
    }
    return sum;
}

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    if (abs(n - m) > 1)
    {
        cout << 0 << endl;
    }
    else if (n == m)
    {
        cout << (facctorialMethod(n) * facctorialMethod(m) * 2) % 1000000007 << endl;
    }
    else
    {
        cout << facctorialMethod(n) * facctorialMethod(m) % 1000000007 << endl;
    }
}

Measured memory_bytes: 256
import sys
X, K, D = map(int, input().split())
X = abs(X)
num = X - K*D
if 0<num:
  print(num)
  sys.exit(0)

k2 = X//D
if (K-k2)%2==0:
  print(X - k2*D)
elif K<k2+1:
  print(X - (k2-1)*D)
else:
  print((k2+1)*D - X)



Measured memory_bytes: 9092
//C
#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 <cstdalign>
#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

//Hang in there!

using namespace std;


int main() {
	long N, M;
	cin >> N >> M;
	long sum = N * 2 + M;
	if (N * 2 <= M) {
		cout << sum / 4 << endl;
	}
	else {
		cout << M / 2 << endl;
	}
}



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

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

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

using pll = pair<ll, ll>;

const int N = 3001;
int a[N];
pll dp[N][N];

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

	int n; cin >> n;
	rep(i, 0, n) cin >> a[i];
	per(l, 0, n) {
		dp[l][l] = {a[l], 0};
		rep(r, l + 1, n) {
			auto tl = dp[l + 1][r]; swap(tl.ff, tl.ss);
			auto tr = dp[l][r - 1]; swap(tr.ff, tr.ss);
			tl.ff += a[l]; tr.ff += a[r];
			dp[l][r] = (tl.ff - tl.ss > tr.ff - tr.ss ? tl : tr);
		}
	}
	cout << dp[0][n - 1].ff - dp[0][n - 1].ss;
}

Measured memory_bytes: 139648
k=gets.to_i
rems=Array.new(k,false)
count=0
rem=0
if k==1
  puts 1
else
  loop do
    rem = (rem*10+7)%k
    count += 1
    if rems[rem]
      puts -1
      break
    elsif rem==0
      puts count
      break
    end
    rems[rem]=true
  end
end

Measured memory_bytes: 22004
#include <iostream>
#include <set>
#include <vector>
#include <iomanip>
typedef long long int ll;

using namespace std;

int main()
{

    ll N;

    cin >> N;

    vector<ll> A(N, 0);

    vector<ll> B(N,0);

    for (ll i = 0; i < N; i++)
    {

        cin >> A[i];

        B[A[i]-1]++;
    }

    vector<ll> num(B.size(), 0);


    ll defo = 0;

    for (ll i = 0; i < N; i++)
    {

        defo = defo + B[i] * (B[i] - 1) / 2;
    }

    for (ll i = 0; i < N; i++)
    {


        ll ans = defo-(B[A[i]-1]-1)*(B[A[i]-1])/2 +(B[A[i]-1]-2)*(B[A[i]-1]-1)/2;


        cout << ans << endl;


    }

    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
 int a,b,c;
  cin>>a>>b>>c;
  int d=abs(a)/c;
  int sum=0;
  if(d>=b){
    if(a<0){sum=a+b*c;}
    else{sum=a-b*c;}
  }
  else{
    if(a<0){
      if((b-d)%2==0){
        sum=a+d*c;
      }
      else{
       sum=a+(d+1)*c;
      }
    }
     else{
      if((b-d)%2==0){
        sum=a-d*c;
      }
      if((b-d)%2!=0){
       sum=a-(d+1)*c;
      }
     }
  }
       cout<<abs(sum);
}   

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

using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define MOD = 1000000007;
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> a(N), b(N), c(N);
    vector<vector<int>> happy(N, vector<int>(3,-1));

    rep(i, N) {
        cin >> a[i] >> b[i] >> c[i];
    }

    int ans = 0;

    happy[0][0] = a[0];
    happy[0][1] = b[0];
    happy[0][2] = c[0];

    rep1(i, N) {
        happy[i][0] = a[i] + max(happy[i-1][1], happy[i-1][2]);
        happy[i][1] = b[i] + max(happy[i-1][2], happy[i-1][0]);
        happy[i][2] = c[i] + max(happy[i-1][0], happy[i-1][1]);
    }

    ans = max({happy[N-1][0],happy[N-1][1],happy[N-1][2]});

    cout << ans << endl;
}


Measured memory_bytes: 6912
package main

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

func main() {
	X, N := nextInt(), nextInt()
	Ps := nextInts(N)

	exists := make([]bool, 101)
	for _, p := range Ps {
		exists[p] = true
	}

	if !exists[X] {
		fmt.Println(X)
		return
	}

	for i := 1; ; i++ {
		left := X - i
		if left <= 0 || !exists[left] {
			fmt.Println(left)
			return
		}
		right := X + i
		if right >= 101 || !exists[right] {
			fmt.Println(right)
			return
		}
	}
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 1760
N = int(input())
S_list = []

for i in range(N):
    s = list(input())
    s.sort()
    s1 = ''.join(s)
    S_list.append(s1)

S_list.sort()
s_compare = S_list[0]
ans = 0
count = 1

for i in range(1,N):
    if S_list[i] == s_compare:
        count += 1
    else:
        ans += count * (count - 1) / 2
        count = 1
        s_compare = S_list[i]

ans += count * (count - 1) / 2
print(int(ans))

Measured memory_bytes: 10616
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()

using namespace std;

typedef vector<int> vi;
typedef long long  ll;

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

int main()
{
    int n , a ,b;
    cin>>n>>a>>b;
    int ans = 0;
    for(int i=1;i<=n;++i){
        int tmp = i , sum = 0;
        while(tmp){
            sum += tmp%10;
            tmp /= 10;
        }
        if(sum >= a && sum <= b)
            ans += i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        if (n == 0) {
            System.out.println(2);
            return;
        }
        if (n == 1) {
            System.out.println(1);
            return;
        }

        long l0 = 2;
        long l1 = 1;
        long ln = 0;
        for (int i = 2; i <= n; i++) {
            ln = l0 + l1;
            l0 = l1;
            l1 = ln;
        }
        System.out.println(ln);
    }

}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;





int main(){
    int N;
    cin >> N;
    vector<P> a;
    LL ans[N];
    memset(ans,0,sizeof(ans));
    for(int i=0;i<N;i++){
        LL t;
        cin >> t;
        a.pb(mp(t,i));
    }
    sort(RALL(a));
    LL mini=N;
    for(int i=0;i<N;i++){
        mini=min(mini,a[i].sc);
        if(i+1<N&&a[i].fs==a[i+1].fs) continue;
        else if(i==N-1){
            ans[mini]+=a[i].fs*(i+1);
        }
        else{
            ans[mini]+=(a[i].fs-a[i+1].fs)*(i+1);
        }
    }
    for(int i=0;i<N;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 998244353


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int c[234567];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int a[n];

	zip(i, 0, n)
	{
		cin >> a[i];
		c[a[i]]++;
	}
	if (a[0] != 0)
	{
		cout << 0 << en;
		return 0;
	}
	if (c[0] != 1)
	{
		cout << 0 << en;
		return 0;
	}
	int ans = 1;
	for (int i = 1; i < n; i++)
	{
		ans = (ans * BE(c[i - 1], c[i], mod)) % mod;
	}

	cout << ans << en;
	return 0;
}



Measured memory_bytes: 5100
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
 
class DandA {
    static void Main(string[] args) {
        long[] abk = ReadLineLongArray();
        if (abk[0] > abk[2]) {
            abk[0] -= abk[2];
            abk[2] = 0;
        } else {
            abk[2] -= abk[0];
            abk[0] = 0;
        }
        if (abk[1] > abk[2]) {
            abk[1] -= abk[2];
        } else {
            abk[1] = 0;
        }
        Console.WriteLine(abk[0] + " " + abk[1]);
    }
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin >> N;
   vector <tuple<string, int, int>> res(N);
   for (int i=0; i<N; i++){
       string S;
       int P;
       cin >> S >> P;
       res.at(i)=make_tuple(S,-P, i);
   }
   sort(res.begin(),res.end());
   for(int i=0; i<N; i++){
        string S;
     	int P,j;
        tie(S,P,j)=res.at(i);
        cout << j+1 << endl;
    }
   return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        double gyaku = 0;
        for(int i = 0;i<n;i++){
            gyaku += 1 / (float)(a[i]);
        }
        gyaku = 1 / gyaku;
        System.out.println(gyaku);
        sc.close();
    }
}

Measured memory_bytes: 22868
using System;
using System.Collections.Generic;
public class ABC123B{
    public static void Main(){
        int a, b, c, d, e, k;
        a = int.Parse(System.Console.ReadLine());
        b = int.Parse(System.Console.ReadLine());
        c = int.Parse(System.Console.ReadLine());
        d = int.Parse(System.Console.ReadLine());
        e = int.Parse(System.Console.ReadLine());

        k = int.Parse(System.Console.ReadLine());
        
        if (e - a <= k) {
            System.Console.WriteLine("Yay!");
        } else {
            System.Console.WriteLine(":(");
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUM 100
int rep(char data[],int time);
int judge(char *data_b,char *data_a);
int main(){
  char moji[NUM+1];

  scanf("%s",moji);
  printf("%d",rep(moji,strlen(moji)));
  return 0;
}
int rep(char data[],int time){
  int ct=0;
  for(int i=0;i<time/2;i++)ct+=judge(&data[i],&data[time-i-1]);
  return ct;
}

int judge(char *data_b,char *data_a){
  if(strncmp(data_b,data_a,1)!=0)return 1;
  return 0;
}

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


int main(){
  long N;
  long ans = 1000000000000;
  long hold = 0;
  cin>>N;
  
  for(int i = 1;i<=sqrt(N);i++){
    if(N%i == 0){
      hold=i+N/i-2;
      ans = min(ans,hold);
    }
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <map>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

using namespace std;

int a[100000];

int main(){
  int n, s, w, q;
  while(scanf("%d%d%d%d", &n, &s, &w, &q), n + s + w + q){
    int g = s;
    for(int i = 0; i < n; i++){
      a[i] = (g / 7) % 10;
      if(g % 2 == 0){ g = (g / 2); }
      else          { g = (g / 2) ^ w; }
    }

    int ans  = 0;
    if(!(q == 2 || q == 5)){
      int mod  = 0;
      int mod2 = 1;
      map<int, int> memo;
      memo[0] = 1;
      for(int i = n - 1; i >= 0; i--){
	mod  = (mod + (mod2 * a[i])) % q;
	mod2 = (mod2 * 10) % q;
	if(a[i]) ans += memo[mod];
	memo[mod]++;
      }
    }else{
      int cnt = 0;
      REP(i,n){
	if(a[i]) cnt++;
	if(a[i] % q == 0) ans += cnt;
      }
    }

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

  return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

constexpr int D_MAX = 100;

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

  int x_max;
  int y_max;
  cin >> x_max >> y_max;

  auto d_matrix = Make2DVector(x_max + 1, y_max + 1, 0);
  for (int x = 1; x <= x_max; x++) {
    for (int y = 1; y <= y_max; y++) {
      cin >> d_matrix[x][y];
    }
  }

  auto c_matrix = Make2DVector(D_MAX + 1, D_MAX + 1, 0);
  for (int a = 0; a <= D_MAX; a++) {
    for (int b = 0; b <= D_MAX; b++) {
      for (int x = 1; x <= x_max; x++) {
        for (int y = 1; y <= y_max; y++) {
          UpdateMax(c_matrix[a][b], d_matrix[x][y] - a * x - b * y);
        }
      }
    }
  }

  auto check_fn = [&]() -> bool {
    for (int x = 1; x <= x_max; x++) {
      for (int y = 1; y <= y_max; y++) {
        int d = INT32_MAX;
        for (int a = 0; a <= D_MAX; a++) {
          for (int b = 0; b <= D_MAX; b++) {
            UpdateMin(d, a * x + b * y + c_matrix[a][b]);
          }
        }
        // cout << d << endl;
        if (d > d_matrix[x][y]) return false;
      }
    }
    return true;
  };

  if (!check_fn()) {
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;
  cout << 2 * D_MAX + 2 << " " << D_MAX + D_MAX + (D_MAX + 1) * (D_MAX + 1) << endl;
  for (int i = 0; i + 1 <= D_MAX; i++) {
    cout << 1 + i << " " << 1 + i + 1 << " " << "X" << endl;
  }
  for (int i = 0; i + 1 <= D_MAX; i++) {
    cout << D_MAX + 1 + 1 + i << " " << D_MAX + 1 + 1 + i + 1 << " " << "Y" << endl;
  }
  for (int a = 0; a <= D_MAX; a++) {
    for(int b = 0; b <= D_MAX; b++) {
      cout << 1 + a << " " << 2 * D_MAX + 2 - b << " " << c_matrix[a][b] << endl;
    }
  }
  cout << 1 << " " << 2 * D_MAX + 2 << endl;
}

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

int dp[30100][1010][5];

inline void update(int& num, int add) { num = min(1000, num + add); }

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

  for(int i = 0; i < N; ++i) {
    int n = S[i] - '0';
    dp[i + 1][n][1] = 1; // 1文字目として登録

    for(int m = 0; m < 10; ++m) { // 2文字目
      int d = dp[i][m][1];
      int next = m * 10 + n;
      update(dp[i + 1][next][2], d); // 追加した場合
      update(dp[i + 1][m][1], d);
    }
    for(int m = 0; m < 100; ++m) {
      int d = dp[i][m][2];
      int next = m * 10 + n;
      update(dp[i + 1][next][3], d); // 追加した場合
      update(dp[i + 1][m][2], d);
    }
    for(int m = 0; m < 1000; ++m) {
      update(dp[i + 1][m][3], dp[i][m][3]);
    }
  }
  int total = 0;
  for(int m = 0; m < 1000; ++m) {
    auto value = dp[N][m][3];
    if(value > 0) {
      // cout << m << endl;
      total++;
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 592128
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int x;
int k;
int r[100100];
int q;
int t[100100], a[100100];

int sl[100100], su[100100];
int il[100100], iu[100100];

void solve() {
    sl[0] = 0; su[0] = x;
    il[0] = 0; iu[0] = x;
    for (int i = 1; i <= k; i++) {
        int diff = r[i] - r[i-1];
        if (i % 2) {
            sl[i] = max(0, sl[i-1]-diff);
            su[i] = max(0, su[i-1]-diff);
            il[i] = il[i-1] + sl[i] - (sl[i-1]-diff);
            iu[i] = max(iu[i-1], il[i]);
        } else {
            sl[i] = min(x, sl[i-1]+diff);
            su[i] = min(x, su[i-1]+diff);
            iu[i] = iu[i-1] - (su[i-1] + diff - su[i]);
            il[i] = min(il[i-1], iu[i]);
        }
    }

    int idx = 0;
    for (int i = 0; i <= k && idx < q; i++) {
        while (idx < q && r[i] <= t[idx] && t[idx] < r[i+1]) {
            if (il[i] <= a[idx] && a[idx] <= iu[i]) {
                if (i % 2 == 0) {
                    cout << max(0, sl[i]+a[idx]-il[i]-(t[idx]-r[i])) << endl;
                } else {
                    cout << min(x, sl[i]+a[idx]-il[i]+(t[idx]-r[i])) << endl;
                }
            } else if (a[idx] < il[i]) {
                if (i % 2 == 0) {
                    cout << max(0, sl[i]-(t[idx]-r[i])) << endl;
                } else {
                    cout << min(x, sl[i]+(t[idx]-r[i])) << endl;
                }
            } else {
                if (i % 2 == 0) {
                    cout << max(0, su[i]-(t[idx]-r[i])) << endl;
                } else {
                    cout << min(x, su[i]+(t[idx]-r[i])) << endl;
                }
            }
            idx++;
        }
    }
}

void input() {
    cin >> x >> k;
    for (int i = 1; i <= k; i++) cin >> r[i];
    r[k+1] = (int)1e9+7;
    cin >> q;
    for (int i = 0; i < q; i++) cin >> t[i] >> a[i];
}

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

    input();
    solve();
}


Measured memory_bytes: 3968
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	ll n, m, ans = 0;
	cin >> n >> m;
	if (n == 1) {
		cout << m << endl;
	}
	else {
		if (n == m)cout << 1 << endl;
		else {
			ll i = 1;
			while (i <= sqrt(m)) {
				if (m%i == 0) {
					if (m >= n*i)ans = max(ans, i);
					if (m >= n*(m / i))ans = max(ans, m / i);
					i++;
				}
				else i++;
			}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin >> arr[i];
    vector<bool> visited(n,false);
    set<int> s;
    sort(arr,arr+n);
    for(int i=0;i<n;i++){
        if(i && arr[i] == arr[i-1]){
            visited[i] = true;
            visited[i-1] = true;
            
        }
        if(!i && arr[i] == arr[i+1]){
            visited[i] = true;
            visited[i+1] = true;
        }
        if(s.find(arr[i]) != s.end()){
            visited[i] = true;
            continue;
        }
        s.insert(arr[i]);
        for(int j=2*arr[i];j<=1000000;j+=arr[i]){
            s.insert(j);
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(!visited[i])
            ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 51228
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	string n;
	cin >> n;
	int len = (int)n.length();
	string x(len, n[0]);
	string ans(len, n[0] + (n > x));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, a[100], min_a, min, count = 0, x, i, j;

  scanf("%d" ,&n);
  for(i = 0; i < n; i++) scanf("%d" ,&a[i]);

  for(i = 0; i < n; i++){
    min_a = a[i];
    min = i;
    for(j = i; j < n; j++){
      if(min_a > a[j]){
	min_a = a[j];
	min = j;
      }
    }
    if(i != min){
    x = a[min];
    a[min] = a[i];
    a[i] = x;
    count++;
    }
  }
  for(i = 0; i < n - 1; i++) printf("%d " ,a[i]);
  printf("%d\n%d\n" ,a[n - 1] ,count);
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
ll dp[105][100005];
void solve(){
	int n,weight;
	cin>>n>>weight;
	for(int i=1;i<=n;i++){
		int a,w;
		cin>>w>>a;
		for(int j=weight;j>0;j--){
			if(j>=w){
				dp[i][j]=max(dp[i-1][j-w]+a,dp[i-1][j]);
				}
				else{
					dp[i][j]=dp[i-1][j];					}
		}
		
	}
	cout<<dp[n][weight];
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)solve();
}


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

long long n, k;
long long a[200004];

long long f(long long mid){
	long long ret = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == 0){
			if(mid >= 0)	ret += n-1;
			continue;
		}
		if(a[i] < 0){
			long long target = mid/a[i];
			if(target*a[i] > mid)	target++;
			int idx = lower_bound(a, a+n, target)-a;
			ret += n - idx;
			if(idx <= i)	ret -= 1;
		}
		else{
			long long target = mid/a[i];
			if(target*a[i] > mid)	target--;
			int idx = upper_bound(a, a+n, target)-a-1;
			if(idx < 0)	continue;
			ret += idx + 1;
			if(idx >= i)	ret -= 1;
		}
	}
	return ret/2;
}

int main() {
	cin>>n>>k;
	for(int i = 0; i < n; i++)	cin>>a[i];
	sort(a, a+n);
	long long lo = -1e18, hi = 1e18;
	while(lo < hi){
		long long mid = lo + (hi - lo)/2;
		if(f(mid) >= k)	hi = mid;
		else	lo = mid + 1;
	}
	cout<<lo<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1920
n=int(input())
a=list(map(int,input().split()))
dp=[0]*n
dp[0]=1000
for i in range(1,n):
    dp[i]=dp[i-1]
    for j in range(i):
        dp[i]=max(dp[i],(dp[j]//a[j])*a[i]+dp[j]%a[j])
print(dp[n-1])

Measured memory_bytes: 64168
#include <stdio.h>

static const int N = 100;

void trace(int A[], int n, int count){
  int i;
  for(i = 0; i < n; i++){
    if(i > 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n", count);
}

int main(){
  int i, j, n, mini, a;
  int count=0;
  int A[N];
  
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);
  
  for(i = 0; i < n; i++){
    mini = i;
    for(j = i; j < n; j++)
      if(A[j] < A[mini]) mini = j;
    if(A[i] == A[mini])continue;
    a = A[i];
    A[i] = A[mini];
    A[mini] = a;
    count++;
  } 
  trace(A, n, count);
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<string>
#include<algorithm>
#include <math.h>
#define PI 3.14159265

int main(){
    double n;
    while(std::cin>>n && n != 0.0)
    {
        double s[1000] ={};
        double sum=0.0;
        for(int i = 0; i < n; i++)
        {
            std::cin>>s[i];
            sum += s[i];
        }
        double ave = sum / n;
        double a = 0.0;
        for(int i = 0; i < n; i++)
        {
            a += (s[i]-ave)*(s[i]-ave);
        }
        double alpha = a/n;
        printf("%f\n", sqrt(alpha));

    }

    return 0;
}




Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    bool a = false;
    for(int i = A; i <= B; i++) {
        if(i % K == 0) {
            a = true;
        }
    }
    if(a == true) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n = ii()
A = iil()
cnt = 0
for i,item in enumerate(A):
    if (i+1)%2==1 and item%2==1:
        cnt+=1
print(cnt)

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

int main() {
    int n;
    cin >> n;
    vector<int> v1, v2;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (i % 2 == 0) v1.push_back(a);
        else v2.push_back(a);
    }

    if (n % 2 == 0) swap(v1, v2);
    reverse(v1.begin(), v1.end());
    v1.insert(v1.end(), v2.begin(), v2.end());

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

Measured memory_bytes: 3564
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let s:Vec<char> = read::<String>().chars().collect();

    let mut map = HashMap::new();
    for ch in s.iter() {
        let count = map.entry(ch).or_insert(0);
        *count += 1;
    }

    let mut cnt:u32 = 0;
    for (&k, &v) in &map {
        //debug!(k,v);
        if v==2 {cnt+=1}
    }

    println!("{}", if cnt==2 {"Yes"} else {"No"});

}


Measured memory_bytes: 4476
#include <stdio.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; scanf("%d", &N);
	int A,B; scanf("%d %d", &A, &B);

	int p;
	int count[3] = {0};
	REP(i,N){
		scanf("%d", &p);
		if(p <= A) count[0]++;
		else if(p > A && p <= B) count[1]++;
		else count[2]++;
}
	
	printf("%d\n",min(count[0],min(count[1],count[2])));

	return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

ll gcd(ll a,ll b){
  if(a%b==0) return b;
  else return gcd(a,a%b);
}
ll lcm(ll a,ll b){
  ll g = gcd(a,b);
  return a/g*b;
}

int r,p,s;

int point(char c){
  int add = 0;
  if(c=='r') add = p;
  if(c=='p') add = s;
  if(c=='s') add = r;
  if(c=='n') add = 0;

  return add;
}

int main(){
  int n,k;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;
  ll ans = 0;
  for(int i=k;i<n;i++){
    if(t.at(i-k)==t.at(i)) t.at(i) = 'n';
  }

  rep(i,n){
    ans+=point(t.at(i));
  }

  cout << ans << endl;
}


Measured memory_bytes: 3764
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] Args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine()), division;
        boolean petroPresidente = false;
        for(int i = 1; i < 10;i++){
            if(n % i == 0){
                division = n / i;
                if( division >= 1 && division <= 9) {
                    petroPresidente = true;
                    break;
                }
            }
        }
        if(petroPresidente) {
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


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

using namespace std;

deque<char> t;

char hoge,s[200];
int x,z;

int main() {
    cin >> s;
    for (x=0 ; x < strlen(s) ; x++) {
        cin >> hoge;
        t.push_back(hoge);
    }
    for (x=0 ; x < strlen(s) ; x++) {
        if (equal(t.begin(), t.end(),s)) {
            cout << "Yes\n";
            return 0;
        }
        t.push_front(t.back());
        t.pop_back();
    }
    cout << "No\n";

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }, K;

int main() {

	cin >> K;



	cout << N[K - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
ll n,h;
typedef pair<ll,pair<bool,ll> >P;
vector<P> Q;
map<ll,ll> m;
int main(){
    cin>>n>>h;
    ll sum=0;
    lol(i,n-1){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	Q.pb(mp(sum+1,mp(0,b)));
	Q.pb(mp(sum+h-b,mp(1,b)));
	sum+=a;
    }
    sort(Q.begin(),Q.end());
    ll pnt=h,ans=0,to=0,p=0;m[0]=1;
    while(pnt<=sum){
	for(;p<Q.size();p++){
	    ll t=Q[p].fi,k=Q[p].sc.sc;
	    if(t>pnt)break;
	    if(Q[p].sc.fi){
		m[k]--;if(!m[k])m.erase(k);
		to=max(to,t+k);
	    }
	    else m[k]++;
	}
	auto it=m.end();it--;ll k=it->fi;
	if(k>=to-pnt){
	    ll mov=(min(Q[p].first,sum+1)-pnt+k-1)/k;
	    ans+=mov,pnt+=mov*k;
	}
	else pnt=to,ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 9148
import math
N = int(input())

def make_prime_list(num):
    if num < 2:
        return []

    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]

def search_divisor_num(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num

re = 0
for i in range(1, N+1, 2):
    num = search_divisor_num(i)
    if num == 8:
        re += 1
        
print(re)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;

pair<double,double> v[55];

double dist(double x, double y, double p, double q) {
	double aux = (x-p)*(x-p);
	double aux2 = (y-q)*(y-q);

	return sqrt(aux + aux2);
}

pair<double, double> g(double bx, double by, double cx, double cy) {
	double B=bx*bx+by*by, C=cx*cx+cy*cy, D=bx*cy-by*cx;
	return mp((cy*B-by*C)/(2*D), (bx*C-cx*B)/(2*D));
}

pair<double,double> f(pair<double,double> A, pair<double,double> B, pair<double,double> C) {
	auto c = g(B.ff-A.ff, B.ss-A.ss, C.ff-A.ff, C.ss-A.ss);
	return {c.ff + A.ff, c.ss + A.ss};
}

double D(pair<double,double> A, pair<double,double> B, pair<double,double> C) {
	return A.ff*B.ss + A.ss*C.ff + B.ff*C.ss - (B.ss*C.ff + C.ss*A.ff + B.ff*A.ss); 
}

int main(){
	int n;

	scanf("%d", &n);

	double sx = 0, sy = 0;
	for(int i = 0; i < n; i++) {
		scanf("%lf%lf", &v[i].ff, &v[i].ss);
	}

	double ans = 1e50;

	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			sx = ((double)v[i].ff + v[j].ff)/2.0;
			sy = ((double)v[i].ss + v[j].ss)/2.0;

			double cur = 0;
			for(int k = 0; k < n; k++) {
				cur = max(cur, dist(sx, sy, v[k].ff, v[k].ss));
			}
			ans = min(cur, ans);
		}
	}

	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			for(int k = i+1; k < n; k++) {
				if(D(v[i], v[j], v[k]) == 0) continue;
				auto c = f(v[i], v[j], v[k]);

				double cur = 0;
				for(int l = 0; l < n; l++) {
					cur = max(cur, dist(c.ff, c.ss, v[l].ff, v[l].ss));
				}
				ans = min(cur, ans);
			}
		}
	}

	printf("%.15lf\n", ans);

	return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,d = inpm()
cnt = 0
for i in range(n):
    x,y = inpm()
    if math.sqrt(x*x + y*y) <= d:
        cnt += 1

print(cnt)

Measured memory_bytes: 31264
s = input()

N = len(s)

score = 0
j = 0
left_len = 0
right_len = 0
flag = 0

for i in range(N):
    flag = 0
    if i + j >= N:
        continue
    left = s[i]
    if left == "x":
        left_len += 1
    else:
        while flag == 0:
            right = s[N-1-j]
            if right == "x":
                right_len += 1
            else:
                if left != right:
                    print(-1)
                    exit()
                else:
                    score += max(left_len,right_len) - min(left_len,right_len)
                    left_len = 0
                    right_len = 0
                    flag = 1
            j += 1

print(score)

Measured memory_bytes: 3316