akhauriyash/Code-Regression huggingface dataset:
// LUL
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "parade"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

string s;
int n;
long long eval(string ex)
{
    long long cur = 0, res = 0;
    for(int i = 0; i < ex.size(); i++)
    {
        if(ex[i] == '+')
            res += cur, cur = 0;
        else
            cur = cur * 10 + (ex[i] - '0');
    }
    res += cur;
    return res;
}

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    n = s.size();
    long long ans = 0;
    for(int mask = 0; mask < (1 << (n - 1)); mask++)
    {
        string ex = "";
        for(int i = 0; i < n - 1; i++)
        {
            ex += s[i];
            if(mask & (1 << i))
                ex += '+';
        }
        ex += s[n - 1];
        ans += eval(ex);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <set>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
//_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
//_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	set<int> A;
	for (int i = in(); i; i--)
		switch(in()) {
		case 0:
			A.insert(in());
			outl(A.size());
			break;
		case 1:
			outl(A.count(in()));
			break;
		case 2:
			A.erase(in());
			break;
		default:
			auto i = A.lower_bound(in()), e = A.upper_bound(in());
			for (; i != e; i++)
				outl(*i);
		}
}


Measured memory_bytes: 11792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,d;
    cin>>n>>d;
    if(n%(d*2+1)==0) cout<<n/(d*2+1);
    else cout<<n/(d*2+1)+1;
}

Measured memory_bytes: 3604
#include <iostream>
#include <map>

using namespace std;

int main()
{
    int n, q;
    while( cin >> n >> q ) {
        if ( n == 0 && q == 0 )
            break;

        map<int, int> ca;
        for( int i=0; i<n; ++i ) {
            int m;
            cin >> m;

            for( int j=0; j<m; ++j ) {
                int d;
                cin >> d;

                ++ca[d];
            }
        }

        int result = 0, l = 0;
        for( map<int, int>::iterator it = ca.begin(); it != ca.end(); ++it ) {
            if ( it->second >= q && it->second > l ) {
                result = it->first;
                l = it->second;
            }
        }

        cout << result << endl;
    }
}

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

int main()
{
 long long n,x,y,i;
 cin>>n>>x>>y;
 for(i=x;i<=y;i++)
 {
     if(i%n==0)
     {cout<<"OK"<<endl;
       return 0;
      }
}
cout<<"NG"<<endl;
return 0;
}


Measured memory_bytes: 3608
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var Aarray = retreiveLongArray();

			checked {
				var total = Aarray.Sum();
				long sum = 0;
				for (int i = 0; i < N; i++) {

					var a = Aarray[i];
					var kakeru = (total - a) % (_mod * 2);
					sum += a * kakeru;
					sum %= (_mod * 2);

				}
				//答えの出力
				var ans = sum / 2;
				Console.WriteLine(ans);

			}



		}
		private static long _mod = 1000000000 + 7;

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}

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

#define what_is(x) cout << #x << " is " << x << endl;
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 9223372036854775805
#define ninf -9223372036854775802
#define M 1000000007
#define eps 1e-9
#define MAX 10
#define N 500001
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX];
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a,ll b,ll p){
    if(b==0)
        return 1;
    if(b==1)
            return a;
    ll temp=vpow(a,b/2,p);
    temp*=temp;
    temp%=p;
    if(b%2==0)
        return temp;
    temp=temp*a;
    temp%=p;
    return temp;
}

ll gcd(ll a,ll b){
     if(a==0)
         return b;
     return gcd(b%a,a);
 }


ll inverseMod(ll a,ll b,ll p){
    if(b==0)
        return 1;
    ll temp=vpow(b,p-2,p);
    ll ans=temp*a;
    ans%=p;
    return ans;
}
void sieve()
{
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}
ll max(ll a, ll b)
{
    return a>b?a:b;
}

void factorial(){
    fact[0]=1;
    fact[1]=1;
    rep(i,2,MAX){
        fact[i]=(fact[i-1]*i);
        // fact[i]%=M;
    }
}
ll rand(ll a,ll b){
    return a+rand()%(b-a+1);
}

void solve(ll ttt)
{
    string s;
    cin>>s;
    int i,n=s.size();
    if(s[n-1]=='s')
    {
        s+="es";
    }
    else{
        s+="s";
    }
    cout<<s<<endl;
}

int main(){
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    //
    //freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
#endif
    ll t=1;
     //cin>>t;
    fix(12);
    rep(q,1,t+1){
         //cout<<"Case #"<<q<<": ";
         //cout<<"Test Case : "<<q<<endl;
         solve(q);
    }
    return 0;

}




Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define maxn 100100
using namespace std;
typedef long long ll;
ll f[maxn],s[maxn],t[maxn],mx=0;
int a[maxn],n;
char c[10];
int main(){
	scanf("%d",&n);
	for(int i=1,fu;i<=n;++i){
		if(i>1){
			scanf("%s",c);
			fu=(c[0]=='-'?-1:1);
		} else fu=1;
		scanf("%d",&a[i]);
		a[i]*=fu;
	}
	for(int i=n,lst=0;i>=1;--i){
		s[i]=s[i+1]+a[i];
		t[i]=t[i+1]+abs(a[i]);
		f[i]=-1ll<<60;
		if(a[i]<0){
			if(lst)f[i]=-(s[i+1]-s[lst])+t[lst]+a[i];
			lst=i;
		}
		f[i]=max(f[i],f[i+1]+a[i]);
	}
	printf("%lld",f[1]);
}

Measured memory_bytes: 2944
import math
import sys
isPrime=[False, False]
for i in range(2,1000000):
    isPrime.append(True)
for i in range(2,int(math.sqrt(1000000))):
    if isPrime[i]:
        for j in range(i*i, 1000000, i):
            isPrime[j]=False
for l in sys.stdin:
    f=int(l)
    ans=[]
    while True:
        if isPrime[f-1]:
            ans.append(int(f-1))
            break
        else:
            f=f-1
    f=int(l)
    while True:
        if isPrime[f+1]:
            ans.append(int(f+1))
            break
        else: 
            f=f+1
    print("%d %d"%(ans[0],ans[1]))


Measured memory_bytes: 13428
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n;
    cin >> n;
    string s;
    cin >> s;
    LL ans = 1;
    for(LL i = 1; i < s.size(); ++i){
        if(s[i-1] != s[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
def main():
  N = int(input())
  A = list(map(int, input().split()))
  if 0 in A:
    print(0)
    return
  prd = 1
  for a in A:
    prd *= a
    if prd > 1000000000000000000:
      print(-1)
      return
  print(prd)

main()

Measured memory_bytes: 87880
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

S = SI().strip()

N = len(S)

zero_start = 0
zero_start_counter = 0
for i in range(N):
    if not zero_start == int(S[i]):
        zero_start_counter += 1
    zero_start = (zero_start+1)%2

one_start_counter = N - zero_start_counter

print(min(zero_start_counter, one_start_counter))


Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[200005], n;
long long ans;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", a + i), a[i] -= i;
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; ++i)ans += abs(a[i] - a[(n + 1) / 2]);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
def counter(x):
    #count = 0と書こうとしたが、再帰呼び出しと相性が悪かった…
    if x%2 == 0:
        return 1 + counter(x/2)
    else:
        return 0

n = int(input()) #4
a = [int(i) for i in input().split()] #[4,8,8,16]
b = [counter(i) for i in a]
print(min(b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

const int m=2000;

bool ch(char a, char b){ return (a==b || a=='?' || b=='?'); }

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  int az = a.size();
  int bz = b.size();
  int cz = c.size();
  vector<bool> ab(mx,true),ac(mx,true),bc(mx,true);
  rep(i,az)rep(j,bz)if(!ch(a[i],b[j])) ab[i-j+50000] = false;
  rep(i,az)rep(j,cz)if(!ch(a[i],c[j])) ac[i-j+50000] = false;
  rep(i,bz)rep(j,cz)if(!ch(b[i],c[j])) bc[i-j+50000] = false;

  int ans = 3*m;
  for(int i=-2*m; i<=2*m; i++) for(int j=-2*m; j<=2*m; j++){
    if(ab[i+50000] && ac[j+50000] && bc[j-i+50000]){
      int l = min(0,min(i,j));
      int r = max(az,max(bz+i,cz+j));
      ans = min(ans, r-l);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> as(n);
  for (auto &a : as) {
    cin >> a;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool f = true;
    for (int j = 0; j < i; j++) {
      f &= as[j] <= as[i];
    }
    if (f) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N, S, K := ReadInt(), ReadString(), ReadInt()
	c := S[K-1]
	v := make([]byte, N)
	for i := 0; i < N; i++ {
		v[i] = S[i]
		if v[i] != c {
			v[i] = '*'
		}
	}
	fmt.Println(string(v))
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
D, G = map(int,input().split())
pc = [0]+ [tuple(map(int,input().split())) for _ in range(D)]

def f(G, i):
  if i == 0:
    return float('inf')
  n = min(G//(i*100), pc[i][0])
  s = n*i*100
  if n == pc[i][0]:
    s += pc[i][1]
  if s < G:
    n += f(G-s, i-1)
  return min(n, f(G,i-1))
 
print(f(G, D))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int k,n;
    
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    } 

    sort(a.begin(),a.end());
    vector<int> rec(n);
    rec[0] = a[n-1]-a[0];
    rep1(i,1,n){
        rec[i] = k-a[i] + a[i-1];
    }
    int min_ = rec[0];
    rep(i,n){
        min_ = min(min_,rec[i]);
    }
    cout << min_;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k,a,b; cin >> k >> a >> b;
  ll ans;
  if(b-a<=2){
      ans = 1+k;
  }else{
      if(k-1<a){
          ans = 1+k;
      }else{
          ans = a+ (k-(a-1)) / 2 * (b-a);
          if((k-(a-1)) % 2 == 1) ans++;
      }
  }
  cout << ans << endl;

}



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

int main(void){
   string O,E;
   cin>>O>>E;
   vector<char> ans(O.size()+E.size());
   for(int i=0;i<O.size()+E.size();i++){
      if(i%2==0){
         ans[i]+=O[i/2];
      }else{
         ans[i]+=E[(i-1)/2];
      }
   }
   for(int i=0;i<ans.size();i++){
      cout<<ans[i];
   }
   return 0;
}



Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	h := sc.NextInt()
	n := sc.NextInt()
	sum := 0
	for i := 0; i < n; i++ {
		sum += sc.NextInt()
	}
	if h > sum {
		fmt.Printf("No\n") // output for debug
	} else {
		fmt.Printf("Yes\n") // output for debug
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> S(N);
	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			S[a - 1]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) ans += (S[i] == 0);
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
    int n;
    int a;
    scanf("%d",&n);
    if(10<=n && n<100){
        a=n%10;
        if(a==2 ||a==4 ||a==5 ||a==7 ||a==9){
            printf("hon\n");
        }else if(a==3){
            printf("bon\n");
        }else{
            printf("pon\n");
        }
    }else{
        a=n%100;
        a=a%10;
        if(a==2 ||a==4 ||a==5 ||a==7 ||a==9){
            printf("hon\n");
        }else if(a==3){
            printf("bon\n");
        }else{
            printf("pon\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,n;
  cin>>a>>b>>n;
  int mn=min(n,b-1);
  cout<<a*mn/b<<endl;

  return 0;
}


Measured memory_bytes: 3624
/*
 * Solution by : yuma00
 * 25 August 2019
 *
 */


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

int N,L;

int main()
{
	cin >> N >> L;

	int left = L;
	int right = L + N - 1;

	int eat;
	if(right <= 0){
		eat = right;
	}else{
		if(left >= 0){
			eat = left;
		}else{
			eat = 0;
		}
	}

	// jumlahkan seluruh flavour menggunakan rumus deret arimatika
	// kurangkan dengan kue yang memiliki taste paling minimum
	int answer = (N * (left + right)) / 2 - eat ;

	cout << answer << '\n';

	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;
using P = pair<int,int>;
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; }
const ll INF = 1LL << 60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

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

    if(A==B && A != C){
        printf("Yes\n");
        return 0;
    }
    if(C==B && A != C){
        printf("Yes\n");
        return 0;
    }
    if(A==C && A != B){
        printf("Yes\n");
        return 0;
    }

    printf("No\n");
    return 0;
    
}

Measured memory_bytes: 256
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++){
		 int64_t n,a,b;
		 cin >> n >> a >> b;
		 for(int64_t i = n;;i += n){
			 if(i > a and i > b){
				 break;
			 }
			 if(i >= a and i <= b){
				 cout << "OK\n";
				 return 0;
			 }
		 }
		 cout << "NG\n";
	 }
}



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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

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

    ll a,b,c,k;
    cin >> a >> b>>c>>k;

    if(k<=a)
    {
        cout << k << endl;
    }
    else if(a<k&&k<=a+b)
    {
        cout << a << endl;
    }
    else if(a+b<k&&k<=a+b+c)
    {
        cout << a-(k-a-b) <<endl;
    }
    else
    {
        cout <<a-c << endl;
    }
    

 

 

    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
// 300
int main(){
  string s, str;
  int k;
  cin >> s >> k;
  vector<string> v;
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < s.size(); j++) {
      str = s.substr(j, i);
      if (str.size() >= i){
        v.push_back(str);
      }
    }
  }

  set<string> setvec(v.begin(), v.end());
  vector<string> v2(setvec.begin(), setvec.end());
  cout << v2.at(k - 1) << endl;
}

Measured memory_bytes: 2428
fun main(args: Array<String>) {
  val N = readInt()
  val PN = readInts().toMutableList()

  val F = PN.mapIndexed { index, i -> index + 1 == i }.toMutableList()


  var cnt = 0
  for (i in 0 until F.size - 1) {
    if (F[i] && F[i + 1]) {
      cnt++
      F[i] = false
      F[i + 1] = false
    }
  }
  for (i in 0 until F.size) {
    if (F[i]) {
      cnt++
      F[i] = false
    }
  }
  println(cnt)
}

fun MutableList<Int>.swap(index1: Int, index2: Int) {
  val tmp = this[index1] // 'this' がリストに対応する
  this[index1] = this[index2]
  this[index2] = tmp
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 53944
#include <iostream>

using namespace std;

int main()
{int N,K;
cin>>N>>K;
string S;
cin>>S;
if(S[K-1]=='A')
  {S[K-1]='a';
  }
if(S[K-1]=='B')
  {S[K-1]='b';
  }
if(S[K-1]=='C')
  {S[K-1]='c';
  }  
cout<<S;
}


Measured memory_bytes: 256
# ARC071E

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))


s = input()
t = input()

sa = [0] * (len(s)+1)
sb = [0] * (len(s)+1)
ta = [0] * (len(t)+1)
tb = [0] * (len(t)+1)

ca = 0
cb = 0
for i,c in enumerate(s):
    if c=="A":
        ca += 1
    else:
        cb += 1
    sa[i+1] = ca
    sb[i+1] = cb
ca = 0
cb = 0
for i,c in enumerate(t):
    if c=="A":
        ca += 1
    else:
        cb += 1
    ta[i+1] = ca
    tb[i+1] = cb


q = int(input())
for i in range(q):
    a,b,c,d = map(lambda x: int(x)-1, input().split())
    if (((sa[b+1]-sa[a]) - (sb[b+1]-sb[a])) - ((ta[d+1]-ta[c]) - (tb[d+1]-tb[c])))%3==0:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 57560
#include <iostream>
#define ll long long int
using namespace std;

int main(){
    ll n;
    cin >> n;
    ll sum = 0;
    for(ll i = 1; i <= n; ++i){
        if(i%3!=0 && i%5!=0){
            sum += i;
        }
    }
    cout << sum ;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void) {
	unsigned int n,count;

	while (1) {
		scanf("%lu",&n);
		if (n == 0)break;
		count = 0;
		while (n != 1) {
			if (n % 2 == 0) {
				n /= 2;
				count++;
			}
			else {
				n = n * 3 + 1;
				count++;
			}
		}
		printf("%lu\n",count);
	}
	return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vii vector<pair<int, int> >
#define fi first
#define se second
#define int long long
int a[5][205], dp[5][105];
signed main()
{
	int n;
	cin>>n;
	for(int i=1; i<=2; i++) for(int j=1; j<=n; j++) cin>>a[i][j];
	for(int i=1; i<=2; i++)
	{
		for(int j=1; j<=n; j++)
		{
			dp[i][j]=max(dp[i][j-1], dp[i-1][j])+a[i][j];
		}
	}
	cout<<dp[2][n];
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    ll b = 0;
    REP(i, N)
    {
        if (S[i] == '#')
            b++;
    }
    ll w = 0;
    ll min = b;
    for (int i = N - 1; i >= 0; --i)
    {
        if (S[i] == '.')
            w++;
        else if (S[i] == '#')
            b--;
        min = std::min(min, w + b);
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int digitsum(int num) {
    int digit = num;
    int d_sum = 0;
    while (digit > 0) {
        d_sum += digit % 10;
        digit /= 10;
    }
    return d_sum;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    int ans = INF;
    FOR(A, 1, N) {
        ans = min(ans, digitsum(A) + digitsum(N - A));
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    int n;cin>>n;
    vector<string> w(n);
    rep(i,n)cin>>w[i];
    rep(i,n-1){
        int a=w[i].size()-1;
        if(w[i][a]!=w[i+1][0]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(i,n){
        for(int j=i+1;j<n;++j){
            if(w[i]==w[j]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if A[i] < 0:
        cnt += 1
A = [abs(a) for a in A]
if cnt % 2 == 0:
    print(sum(A))
else:
    print(sum(A)-2*min(A))

Measured memory_bytes: 19988
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.13 20:15:54
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        puts("Yes");
    }
    else {
        puts("No");
    }
    return 0;
}

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


int main() {  
  vector<int> x(5);
  
  int flag;
  
  for(int i=0; i<5; i++){
    cin >> x.at(i);
    
    if(x.at(i) == 0)
      flag = i;
  }
  
  cout << flag+1;
  
  
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    int n;
    cin>>n;
    ll ans = 0;
    for(int i = 1; i < n; i++){
        if(n % i == 0){
            ans += (n/i)-1;
        }
        else{
            ans += (n/i);
        }
    } 
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int N = 2000 + 5;
ll a[N],b[N];

int main(){
	int n;
	ll x;
	cin >> n >> x;
	for(int i = 0; i < n; i++){
		scanf("%lld",&a[i]);
		b[i] = a[i];
	}
	ll sum = INF;
	for(int i = 0; i < n; i++){
		ll ans = 0;
		for(int j = 0; j < n; j++){
			b[j] = min(b[j],a[(j-i+n)%n]);
			ans += b[j];
		}
		sum = min(sum,ans + i*x);
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)


n=l()[0]
A=l()
X=sum(A)
x=0
ans=10**10
for i in range(n):
    x+=A[i]
    if i+1<n:
        ans=min(ans,abs(X-2*x))
print(ans)

Measured memory_bytes: 26084
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) {
    string x, y;
    cin >> x >> y;
    int m = x.length();
    int n = y.length();
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= n; j++) {
        if (x[i - 1] == y[j - 1]) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
          dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
      }
    }
    int ret = dp[m][n];
    cout << ret << '\n';
  }
  return 0;
}


Measured memory_bytes: 6772
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		int n=Integer.parseInt(br.readLine());
		int[] in=new int[n];
		int count=0;
StringTokenizer st=new StringTokenizer(br.readLine());
		for(int i=0;i<n;i++) in[i]=Integer.parseInt(st.nextToken());
		
		for(int i=n;i>0;i--){
			for(int j=1;j<i;j++){
				if(in[j-1]>in[j]){count++;
					int tmp=in[j-1];
					in[j-1]=in[j];
					in[j]=tmp;
				}
			}
		}
StringBuilder stb=new StringBuilder(Integer.toString(in[0]));
for(int i=1;i<n;i++)stb.append(" "+in[i]);
System.out.println(stb);
		System.out.println(count);




	}

}

Measured memory_bytes: 16884
n = int(input())
a = list(map(int,input().split()))

res = "No"
a_set = list(set(a))

if len(a_set) == 3:
    if a_set[0] ^ a_set[1] == a_set[2]:
        if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
            res = "Yes"

if len(a_set) == 1:
    if a_set[0] == 0:
        res = "Yes"
if len(a_set) == 2:
    if 0 in a_set:
        if n%3 == 0 and a.count(0) == n/3:
            res = "Yes"
print(res)



Measured memory_bytes: 14212
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

#define MAX_V 10000

using namespace std;

typedef pair<int, int> P;

vector<int> G[MAX_V];
int C[MAX_V];

int assign[MAX_V];

void dfsCalcEdgeCost( int v, int parent, int &cidx )
{
    assign[v] = C[cidx++];

    for ( auto to : G[v] )
    {
        if ( to == parent ) continue;

        dfsCalcEdgeCost( to, v, cidx );
    }
}

long long calcCost( int v, int parent )
{
    long long cost = 0;
    for ( auto to : G[v] )
    {
        if ( to == parent ) continue;

        cost += min( assign[to], assign[v] );
        cost += calcCost( to, v );
    }
    return cost;
}

int main( int argc, char **argv )
{
    int N;
    cin >> N;

    for ( int i = 0; i < N - 1; i++ )
    {
        int a, b;
        cin >> a >> b;

        G[a - 1].push_back( b - 1 );
        G[b - 1].push_back( a - 1 );
    }

    for ( int i = 0; i < N; i++ ) cin >> C[i];
    sort( C, C + N, [&]( int a, int b ) { return a > b; } );

    // priority_queue<P, vector<P>, greater<P>> que;
    // for ( int i = 0; i < N; i++ ) que.push( P( G[i].size(), i ) );

    // int index = 0;
    // while ( !que.empty() )
    // {
    //     P p = que.top();
    //     que.pop();

    //     int cost = C[index++];
    //     int node = p.second;

    //     assign[node] = cost;
    // }

    int cidx = 0;
    dfsCalcEdgeCost( 0, -1, cidx );

    long long cost = calcCost( 0, -1 );
    cout << cost << endl;

    for ( int i = 0; i < N - 1; i++ ) cout << assign[i] << " ";
    cout << assign[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1536
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    ans = 1

    if 0 in a:
        print(0)
    else:
        for i in range(n):
            ans *= a[i]
            if ans > 10 ** 18:
                print(-1)
                return
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40308
#include <bits/stdc++.h>  
#include <memory>
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  200005;  
#define FI first
#define SE second
typedef pair<int, int>pii;
int mod = 1000000007;
 
ll sum[N];
int main()  
{  
   // ios::sync_with_stdio(0);
   int n;
   while (cin >> n)
   {
      for (int i = 0; i < n; i++)
      {
         cin >> sum[i];
         if (i)
            sum[i] += sum[i-1];
      }
      ll ans = 1LL<<60;
      for (int i = 0; i < n - 1; i++)
         ans = min(ans, abs(sum[n-1] - sum[i] - sum[i]));
      cout<<ans<<endl;
   }

   return 0;
}  

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long n,m,a,ans;
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		cin>>a;
		ans+=a;
	}
	if(n<=ans) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main() {
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;

    const int X = (A + D - 1) / D;
    const int Y = (C + B - 1) / B;

    if (X >= Y) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3660
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  string ans;
  
  if(N%10==3) ans="bon";
  else if(N%10==0 || N%10==1 || N%10==6 || N%10==8) ans="pon";
  else ans="hon";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int x;
    cin >> x;
    int max = x;
    int min = x;
    for (int i = 1; i < n;++i){
        cin >> x;
        if(x > max){
            max = x;
        }
        if(x < min){
            min = x;
        }
    }
    cout << abs(max - min) << endl;
    return 0;
}

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

int main(){
  int n,k;cin >> n >> k; 
  vector<int> a(n);
  int cnt = 1;
  for(int i=0;i<n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  for(int i=1;i<n;i++){
    if(a[i]!=a[i-1])cnt++;
  }
  vector<int> b(cnt,0);
  int j=0;
  b[0]++;
  for(int i=1;i<n;i++){
    if(a[i]!=a[i-1]){
      j++;
    }
    b[j]++;
  }
  bool ans = false;
  int anscnt = 0;
  sort(b.begin(),b.end());
  if(k>=cnt){
    ans = true;
  }else{
    for(int i=0;i<cnt-k;i++){
      anscnt += b[i];
    }
  }
  if(ans){
    cout << 0 << endl;
  }else{
    cout << anscnt << endl;
  } 
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,K,A,count=0,ans=0;
    cin >> N >> K;
    vector<int> v(N,0);//　種類のバケツ 位置が種類、中身が数
    for(int i=0;i<N;i++){
        cin >> A;
        v.at(A-1)++;
    }

    sort(v.begin(),v.end(),greater<int>());

    //greater<int>()←忘れない

    for(int i=K;i<N;i++){
            ans += v.at(i);
        }
        cout << ans << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
A, B = map(int, input().split())

if B == 1:
    print(0)
elif A >= B:
    print(1)
else:
    if (B - A) % (A - 1) > 0:
        print(int((B - A) // (A - 1)) + 2)
    else:
        print(int((B - A) // (A - 1)) + 1)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

def solve(N: int, A: "List[int]"):
    X = []
    x1 = sum(A) - sum(A[1::2]) * 2
    X.append(x1)
    for i in range(1, N):
        X.append(2 * A[i-1] - X[i-1])
    s = ' '.join([str(x) for x in X])
    print(s)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N = 0;
  cin >> N;
  int* A = new int[N];
  for(int i=0; i < N; i++)
    cin >> A[i];
  
  int l = 0;
  int r = N - 1;
  int diff = 0; // total L - total R
  while(1){
    while(l <= r && diff <= 0) diff += A[l++];
    if(l>r){
      l--;
      break;
    }
    while(l <= r && diff >= 0) diff -= A[r--];
    if(l>r){
      r++;
      break;
    }
  }
  
  cout << abs(diff) << endl;
  delete[] A;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		int a;
		cin >> a;
		ans += a & i & 1;
	}
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    vector<int> P(N);
    REP(i,N)cin >> P[i];
    int mini = 500000;
    int answer = 0;
    REP(i,N){
        if(mini>P[i])answer++;
        mini = min(mini,P[i]);
    }
    cout <<answer<< "\n";
}

Measured memory_bytes: 1024
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

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; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;

int main() {
	int n, m;
	cin >> n >> n >> m;
	if ((n + m) % 2 == 1) {
		cout << "Borys\n";
	} else {
		cout << "Alice\n";
	}
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std ;
    #define endl '\n'
    #define lld long long int 
    #define ull unsigned long long int 
    ull power(ull x, ull y){ull temp;if( y == 0)return 1;temp = power(x, y/2); if (y%2 == 0) return temp*temp;else return x*temp*temp; } 
    ull gcdFactor(ull n){ ull tmp=n,res=0;for(ull i=1 ; i*i <=tmp ; i++){if(tmp%i==0){res++;if(tmp/i!=i)res++;}}return res;}
    #define ullmax ULLONG_MAX
    void solution(void);
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        solution();
        return 0;
    }
    
    
    // The difference between the novice and the master is that the master has failed more than the novice has tried  
    // It is not over when you lose it is over when you quit
    // If you have time to think for a beautiful end, then live beautifully until the end
    map<int,vector<int>>mp;
    vector<int>v;
    void dfs(int u)
    {
        for(int it = 0 ; it < mp[u].size() ; it++){
            v[mp[u][it]] += v[u];
            dfs(mp[u][it]);
        }
    }
    
    void solution(){
        int n,q,u,v1,inc;
        cin>>n>>q;
        for(int i=0 ; i<n-1 ; i++){
            cin>>u>>v1;
            v.push_back(0);
            mp[u-1].push_back(v1-1);
        }
        for(int i=0 ; i<q ; i++){
            cin>>u>>inc;
            v[u-1] += inc;
            // dfs(u-1,inc);
        }
        dfs(0);
        for(int i=0 ; i<n ; i++){
            cout<<v[i]<<" ";
        }
    }

Measured memory_bytes: 43764