akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main(){
  map<string,int> mp;
  int q;
  cin >> q;
  REP(i,q){
    int b;
    cin >> b;
    string key;
    cin >> key;
    if(b==0){
      int x;
      cin >> x;
      mp[key] = x;
    }else if(b==1){
      cout << mp[key] << endl;
    }else if(b==2){
      mp.erase(key);
    }
  }
}



Measured memory_bytes: 27864
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long r, D, x; cin >> r >> D >> x;

	for (int i = 1; i <= 10; i++) {
		x = r * x - D;

		cout << x << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
    ll N;
    ll a, b;
    ll total = 0;
    ll ans = 0;
    ll x;
    vector<ll>A;
    vector<ll>B;

    cin >> N;
    for (ll i = 0; i < N; i++) {
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }

    for (ll i = N-1; i >= 0; i--) {
        x = (A[i]+total) % B[i];
        total += (B[i]-x) % B[i];
        ans += (B[i]-x) % B[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2036
// abc145_b
#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 <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int n;
  string s;
  cin>>n>>s;
  if (n%2==0  &&  s.substr(0, n/2) == s.substr(n/2,n/2)) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define All(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n);
  Cins(int, n, p);

  vector<int> sorted(n);
  iota(All(sorted), 1);

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (p[i] != sorted[i]) cnt++;
  }

  puts(cnt == 0 or cnt == 2 ? "YES" : "NO");
  return;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

int main(int argc, char *argv[])
{
  int N, i, j;
  int *A;
  int minj, tmp, ct = 0;

  scanf("%d", &N);

  A = (int *)malloc(sizeof(int) * N);

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

  for (i = 0; i < N; i++) {
    minj = i;
    for (j = i; j < N; j++) {
      if (A[j] < A[minj]) minj = j;
    }
    if (i != minj) {
      tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
      ct++;
    }
  }

  for (i = 0; i < N; i++) {
    if (i != N - 1) printf("%d ", A[i]);
    else printf("%d\n", A[i]);
  }
  printf("%d\n", ct);

  free(A);

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    string o,e;
    cin >> o >> e;
    string ans="";
    if(o.size() == e.size()){
        for(int i=0;i<o.size();i++){
            ans += o.at(i);
            ans += e.at(i);
        }
        cout << ans << endl;
    }
    else{
        for(int i=0;i<e.size();i++){
            ans += o.at(i);
            ans += e.at(i);
        }
        ans += o.at(o.size()-1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
int N, M;
int s[10], c[10];
string S;
int ans = 10000000;
void dfs(int num) {
  if(num == N) {
    int count = 1;
    for(int i = 0; i < M; i++) {
    
      if(S[s[i]] != (char)(c[i] + '0')) { count = 0; break; } 
    
    }
    if(S[0] == '0' && N > 1) { count = 0; }
    int t = 0;

    for(int i = 0; i < N; i++) {
      t += (S[i] - '0') * pow(10, N - i - 1);
    }
    if(ans > t && count == 1) { ans = t; }
   
    return;
  }

  for(int i = 0; i < 10; i++) {
    S[num] = (char)(i + '0');
    dfs(num + 1);
  }

}
int main() {
 
  cin >> N >> M;

  for(int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }

  dfs(0);
  if(ans == 10000000) cout << -1;
  else cout << ans;
 return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n, ans;
string s[4];
int ope (char a, char b, char c) {
	if (a == b && b == c)
		return 0;
	if (a == b || a == c || b == c)
		return 1;
	return 2;
}
int main() {
	cin >> n;
	for (int i = 1; i <= 3; i ++)
		cin >> s[i];
	for (int i = 0; i < n; i ++)
		ans += ope (s[1][i], s[2][i], s[3][i]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
S = input().strip()

n = len(S)
ans = [0] * n
r = 0
for i in range(n):
    if S[i] == 'R':
        r += 1
    else:
        if r > 0:
            ans[i] = 1 + r // 2
            ans[i - 1] = 1 + (r - 1) // 2
            r = 0

l = 0
for i in reversed(range(n)):
    if S[i] == 'L':
        l += 1
    else:
        if l > 0:
            ans[i] = ans[i] + l // 2
            ans[i + 1] = ans[i + 1] + (l - 1) // 2
            l = 0

print(' '.join(map(str, ans)))

Measured memory_bytes: 50800
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;

#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define R(i,n) for(int i=0;i<(n);++i)
#define fill(a,b) memset(a,b,sizeof(a))

const int maxn = 1e5 + 10;
LL a[maxn];
int n;

int main()
{
	//freopen("test.txt","r",stdin);
	scanf("%d",&n);
	R(i,n) scanf("%lld",a+i);
	a[n] = 0;
	LL ans = 0,cur = 0;
	R(i,n+1)
	{
		if(a[i] != 0)
		{
			cur += a[i];
		}
		else
		{
			ans += cur/2;
			cur = 0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		for (int i = 1; i < S.length(); i++) {
			int length = S.length() - i;
			if (length % 2 == 1) {
				continue;
			}

			debug(S.substring(0, length / 2), S.substring(length / 2, length));
			if (S.substring(0, length / 2).equals(S.substring(length / 2, length))) {
				System.out.println(length);
				return;
			}
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  string s; cin >> s;
  int n = s.size();
  int longest = 0;
  rep(i, n) {
    REP(j, i + 1, n + 1) {
      bool f = 1;
      REP(k, i, j) {
        f = f && (s[k] == 'A' || s[k] == 'C' || s[k] == 'G' || s[k] == 'T');
      }
      if (f) {
        longest = max(longest, j - i);
      }
    }
  }
  cout << longest << endl;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Fri Dec 28 15:05:23 2018
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	tmp := make([]int, N)
	copy(tmp, arr)
	sort.Ints(tmp)
	left := tmp[len(arr)/2-1]
	right := tmp[len(arr)/2]
	for i := range arr {
		if arr[i] <= left {
			fmt.Println(right)
		} else {
			fmt.Println(left)
		}
	}
}


Measured memory_bytes: 8576
N = int(input())
ans = 0
for candi in range(1, N + 1, 2):
    num_divisor = 0
    div = 1
    while div**2 <= candi:
        if candi % div == 0:
            num_divisor += 2
        div += 1
    if num_divisor == 8:
        ans += 1
print(ans)


Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))
# print(a)

ok = False
for i in a:
    if i == 0:
        ok = True
if(ok):
    print(0)
    exit()

ret = 1
for i in a:
    ret *= i
    if(ret > 10 ** 18):
        print(-1)
        exit()

print(ret)

Measured memory_bytes: 21640
#include<bits/stdc++.h>
using namespace std;
int h,w,n;
vector<pair<int,int> > blocks; 
bool compare(pair<int,int> p1,pair<int,int> p2){
	return p1.first + p1.second < p2.first + p2.second;
}

int mod = 1e9+7;
int maxn = 200005;
int fac[200005];
int invfac[200005];

int pow(int a,int b){
	if(b==0){
		return 1;
	}
	int tmp = pow(a,b/2);
	if(b%2==0){
		return (1LL * tmp * tmp) % mod;
	} else {
		return ((1LL * tmp * tmp) % mod * a) % mod;
	}
}

void init(){
    fac[0] = 1;
    invfac[0] = 1;
	
    fac[1] = 1;
	invfac[1] = 1;
	for(int i=2;i<maxn;++i){
		fac[i] = (1ll * fac[i-1] * i)% mod ;
		invfac[i] = pow(fac[i],mod-2);
	}
  	/*
	for(int i=1;i<10;++i){
      cout<<fac[i]<<" "<<invfac[i]<<endl;
    }
    */
}

int comb(int a,int b){
	// calculate C(a,b)
	if(a<0||b<0||a<b){
		return 0;
	}
	int res = ((1LL * fac[a] * invfac[b]) % mod * invfac[a-b]) % mod;

	//zcout<<a<<" "<<b<<" "<<res<<endl;
	return res;
}

int main(){
	init();
	cin >> h >> w >> n;
	for(int i=0;i<n;++i){
		int a,b;
		cin>>a>>b;
		blocks.push_back(make_pair(a,b));
	}
	blocks.push_back(make_pair(h,w));
	sort(blocks.begin(),blocks.end(),compare);

	vector<int> dp(n+1);
	// dp logic
	for(int i=0;i<=n;++i){
		pair<int,int> curr = blocks[i];
		int tmp =  comb(curr.first+curr.second-2 , curr.first-1);
		for(int j=0;j<i;++j){
			pair<int,int> past = blocks[j];
			if(past.first<=curr.first && past.second<=curr.second ){
				pair<int,int> route = make_pair(curr.first - past.first , curr.second - past.second);
				tmp = ( 1ll * tmp + mod - (((long long )dp[j] * comb(route.first+route.second , route.first)) % mod )) ;
				tmp %= mod;

			}
		}
		dp[i] = tmp;
	}
	cout<<dp[n]<<endl;
	return 0;

}


Measured memory_bytes: 1920
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 

inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=998244353; 
const int N=1e6 + 3 , M=5;
int OO=1e6; 
 
ll n,m,k,T,cnt,SU;
string str,ans;
vector<pair<char,int>> vec;

bool isPaland(int x,int y){
	bool flage=true;
	while(x<y)
		flage&=(str[x++] == str[y--]);
	
	return flage;
}

 
int main(){
	
	cin>>str;
	n = SZ(str);
	if(isPaland(0,n-1) && isPaland(0,n/2 -1 ) && isPaland(n/2+1,n-1))
		puts("Yes");
	else
		puts("No");
	


}









Measured memory_bytes: 256
M =  10**9 + 7 
n = int(input())
a = [int(i) for i in input().split()]  #; print(a)

counter = [0] * (n+1) ; counter[0] = 3
ans = 1
for i in range(n):
    ans *=  counter[a[i] - 1 +1] - counter[a[i] +1]
    ans = ans % M
    counter[a[i] +1] += 1
print(ans)

Measured memory_bytes: 20756
from decimal import Decimal,ROUND_HALF_UP,ROUND_HALF_EVEN
while True:
    try:
        a,b,c,d,e,f=map(int,input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(a*f-c*d)/(a*e-b*d)
        if x==-0:
            x=int(x)
        if y==-0:
            y=int(y)
        X=Decimal(x).quantize(Decimal('0.001'),rounding=ROUND_HALF_UP)
        Y=Decimal(y).quantize(Decimal('0.001'),rounding=ROUND_HALF_UP)
        print(f'{X:3f}',f'{Y:3f}')
    except EOFError:
        break


Measured memory_bytes: 6424
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  long double a;
  while (cin >> a) {
    long double sum = a;
    for (int i = 2; i <= 10; ++i) {
      if ((i % 2) == 0)
        a = a * 2;
      else
        a = a / 3;
      sum += a;
    }
    cout << fixed;
    cout << setprecision(8) << sum << endl;
  }
}


Measured memory_bytes: 3232
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a[101010]={};
	cin>>n;
	map<int,int> mp;
	LL c=0LL;
	REP(i,n){
		cin>>a[i];
	}
	FOR(i,1,n){
		if(a[i-1]%2&&a[i]){
			a[i]--;a[i-1]--;c++;
		}
	}
	FOR(i,0,n){
		c+=a[i]/2;a[i]=a[i]&1;
	}

	cout<<c;
    return 0;
}


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

using namespace std;

struct block{
    int w,s,v;
    block():s(0),w(0),v(0){}
    block(int w,int s,int v):s(s),w(w),v(v){}
    bool operator < (const block &other) const
    {
        return s+w < other.s+other.w;
    }
};

block arr[1005];
long long mem[1005][20004];
int n;

long long go(int ind,int w)
{
    //cout << ind << " " << w << endl;
    if(ind>=n) return 0;
    long long &ret=mem[ind][w];
    if(ret!=-1) return ret;
    if(w>=arr[ind].w)
        return mem[ind][w]=max(go(ind+1,w),arr[ind].v+go(ind+1,min(w-arr[ind].w,arr[ind].s)));
    return mem[ind][w]=go(ind+1,w);
}

int main()
{
    cin >> n;
    for(int i=0;i<n;i++)
    {
        int x,y,z;
        cin >> x >> y >> z;
        arr[i]={x,y,z};
    }
    sort(arr,arr+n); reverse(arr,arr+n);
    /*for(int i=0;i<n;i++)
        cout << "W: " << arr[i].w << " S: " << arr[i].s << " v: " << arr[i].v << endl;*/
    memset(mem,-1,sizeof mem);
    cout << go(0,2e4) << endl;
}


Measured memory_bytes: 157440
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define DEBUG

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<long,long> pr;

long N, K;
long t;
short c = 0;
short total = 0;

int main(){
    cin >> N >> K;
    VI data(N, 0);
    REP(i, N){
        cin >> t;
        data[t - 1]++;
    }
    SORT(data);
    reverse(data.begin(),data.end());
    REP(i,K){
        N -= data[i];  
    }
    cout << N;
    // cout << K;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define INF 1e9

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,n; cin>>h>>n;
    vi a(n),b(n);
    vi dp(h+1, INF);
    dp[0] = 0;
    rep(i,n){
        cin>>a[i]>>b[i];
    }

    rep(i,n){
        rep(j,h+1){
            if (j>=a[i]){
                dp[j] = min(dp[j],dp[j-a[i]]+b[i]);
            }
        }
    }
    int ans = dp[h];
    rep(j,h){
        rep(i,n){
            if (j+a[i]>=h){
                ans = min(ans, dp[j]+b[i]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(r io.Reader, w io.Writer) {
	scanner := initScanner(r)
	s := scanString(scanner)
	rainyDays := 0
	for _, v := range s {
		if v == 'R' {
			rainyDays += 1
			continue
		}
		if rainyDays > 0 {
			break
		}
	}
	fmt.Fprintln(w, rainyDays)
}

// utilityメソッド群

const maxCapacity = 512 * 1024 // デフォルト値は64*1024

func initScanner(r io.Reader) *bufio.Scanner {
	scanner := bufio.NewScanner(r)
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
	scanner.Split(bufio.ScanWords) // スペースごとに読み込む
	return scanner
}

func scanString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}


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

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

    int a,b,c,k,sum=0;
    cin>>a>>b>>c>>k;
    if(k>a){
        k=k-a;
        sum= sum+a;
    }
    else{
        sum=sum+k;
        k=0;
    }
    if(k>b){
        k=k-b;
    }
    else{
        k=0;
    }
    if(k>c){
        k=k-c;
        sum= sum-c;
    }else{
        sum=sum-k;
        k=0;
    }
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int dr[] = {1, 0, -1, 0};
const int dc[] = {0, 1, 0, -1};

const int MaxN = 1024;

string board[MaxN];
int H, W;

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  cin >> H >> W;
  for (int i = 0; i < H; ++i) { cin >> board[i]; }

  queue<PII> Q;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (board[i][j] == '#') {
        Q.push(MP(i, j));
      }
    }
  }

  vector<VI> dists(H, VI(W));
  int ans = 0;

  while (!Q.empty()) {
    auto elem = Q.front(); Q.pop();
    debug(elem);
    maxi(ans, dists[elem.st][elem.nd]);

    for (int d = 0; d < 4; ++d) {
      int nr = elem.st + dr[d];
      int nc = elem.nd + dc[d];
      if (nr<0||nc<0||nr>=H||nc>=W){continue; }
      if (board[nr][nc] == '.') {
        dists[nr][nc] = dists[elem.st][elem.nd] + 1;
        board[nr][nc] = '#';
        Q.push(MP(nr, nc));
      }

    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 25524
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	ll mod = 1e9+7;

	void solve(){
		

		ins(s);
		ins(t);
		int i   = 0;
		int tmp = 0;
		FOR(i,0,s.size()-t.size()+1){
			int i2 = 0;
			FOR(i1,0,t.size()){
				if(s[i+i1] == t[i1]){
					i2++;
				}
			}
			tmp = max(tmp,i2);
 
		}
		out(t.size()-tmp);
		
			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

int gc(int a,int b){
    if(b>a){
        swap(a,b);
    }
    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(void){
    // Your code here!
    int n,x;
    cin>>n>>x;
    int a[n+1];
    for(int i=0;i<n;i++) cin>>a[i];
    a[n]=x;
    sort(a,a+n+1);
    int z=a[1]-a[0];
    for(int i=1;i<n+1;i++){
        z=gc(z,a[i]-a[i-1]);
    }
    cout<<z;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    h_li = list(map(int, input().split()))
    bad_li = []

    for i in range(m):
        a, b = map(int, input().split())

        if h_li[a-1] > h_li[b-1]:
            bad_li.append(b)
        elif h_li[a-1] < h_li[b-1]:
            bad_li.append(a)
        else:
            bad_li.append(a)
            bad_li.append(b)

    print(n - len(set(bad_li)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20332
#include<bits/stdc++.h>
using namespace std;
int mod;
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=1ll*res*b%mod;
		b=1ll*b*b%mod; n>>=1;
	}
	return res;
}
int f[2][105][105],pw[105][10005],C[105][105];
void init(int n){
	for(int i=0;i<=n;++i){
		pw[i][0]=1;
		for(int j=1;j<=n*n;++j)
			pw[i][j]=1ll*pw[i][j-1]*i%mod;
	}
	C[0][0]=1;
	for(int i=1;i<=n;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
}
void add(int &x,int y){
	x=(x+y)%mod;
}
signed main(){
	int m,d;
	cin>>m>>d;
	int ans=0;
	for(int i=10;i<=d;++i){
		if(i%10<2 || i/10<2) continue;
		int tmp=(i%10)*(i/10);
		if(1<=tmp&&tmp<=m) ++ans;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3584
n,k = map(int,input().split())

h = [int(input()) for i in range(n)]

h.sort()

ans = 10**100

k -= 1

for i in range(n):
    if i+k > n - 1:
        break
    ans = min(ans, h[i+k] - h[i])
    
print(ans)

Measured memory_bytes: 7384
/**
 *    author:  tourist
 *    created: 15.01.2020 16:02:44       
**/
#include <bits/stdc++.h>

using namespace std;

template <typename T>
class fenwick {
 public:
  vector<T> fenw;
  int n;

  fenwick(int _n) : n(_n) {
    fenw.resize(n);
  }

  void modify(int x, T v) {
    while (x < n) {
      fenw[x] += v;
      x |= (x + 1);
    }
  }

  T get(int x) {
    T v{};
    while (x >= 0) {
      v += fenw[x];
      x = (x & (x + 1)) - 1;
    }
    return v;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> at(m + 2);
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    at[l].push_back(r);
    at[r + 1].push_back(~l);
  }
  vector<vector<int>> divs(m + 1);
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i) {
      divs[j].push_back(i);
    }
  }
  vector<int> ans(m + 1);
  fenwick<int> fenw(m + 1);
  for (int i = 1; i <= m; i++) {
    for (int j : at[i]) {
      if (j >= 0) {
        fenw.modify(i, 1);
      } else {
        fenw.modify(~j, -1);
      }
    }
    for (int j : divs[i]) {
      ans[j] += fenw.get(i) - fenw.get(i - j);
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}


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

vector<long long>adj[200005];
long long vis[200005],cnt;

void dfs(long long src)
{
    vis[src]=1; cnt++;

    long long sz=adj[src].size();

    for(long long lp=0;lp<sz;lp++)
    {
        long long pp=adj[src][lp];

        if(vis[pp]==0)
        {
            dfs(pp);
        }

    }


}

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld %lld",&n,&m);


        for(i=1;i<=m;i++)
        {
            scanf("%lld %lld",&a,&b);
            adj[a].push_back(b);  adj[b].push_back(a);

        }


        for(i=1;i<=n;i++)
        {
            if(vis[i]==0)
            {
                cnt=0; dfs(i); if(cnt>mx)mx=cnt;
            }
        }



        printf("%lld\n",mx);








    return 0;
}




Measured memory_bytes: 25580
#include <iostream>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>

using namespace std;

typedef long long ll;

ll n;
ll a[1005], b[1005];
ll d[1005];
vector<ll> ve[1005];
bitset<5005> bs;

int main()
{
    scanf("%lld", &n);
    for(ll i = 2; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        ve[a[i]].push_back(i);
    }
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &b[i]);
    }
    for(ll i = n; i >= 1; i--)
    {
        ll t = b[i];
        bs = 1;
        ll sum = 0;
        ll now = 0;
        for(ll j = 0; j < ve[i].size(); j++)
        {
            t -= min(b[ve[i][j]], d[ve[i][j]]);
            sum += max(b[ve[i][j]], d[ve[i][j]]);
            bs |= (bs << abs(b[ve[i][j]] - d[ve[i][j]]));
        }
        if(t < 0)
        {
            printf("IMPOSSIBLE\n");
            return 0;
        }
        for(ll i = t; i >= 0; i--)
        {
            if(bs[i]) {now = i; break;}
        }
        d[i] = sum - now;
    }
    printf("POSSIBLE\n");
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(s) for s in input().split()]

s = sum(A)
result = 0

MOD = 10**9 + 7

for i in range(N - 1):
    s = s - A[i]
    result = result + (A[i] * s % MOD)
print(result % MOD)

Measured memory_bytes: 104916
import java.util.*;

class Main {
  	static final int INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int n = Integer.parseInt(sc.next());
      	int max = -1;
      	int min = INF;

      	for (int i = 0; i < n; i++) {
          	int a = Integer.parseInt(sc.next());
          	max = Math.max(max, a);
          	min = Math.min(min, a);
        }
      	System.out.println(max - min);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


int main(){
    // #ifndef ONLINE_JUDGE
	// 	freopen("test", "r", stdin);
	// #endif
    fastio;
    
    int R;
    cin >> R;

    double ans = 2 * PI * R;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3804
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

ld dist(pair<ld,ld> x,pair<ld,ld> y)
{
	ld distance = sqrt((x.ff-y.ff)*(x.ff-y.ff) + (x.ss-y.ss)*(x.ss-y.ss));
	return distance;
}


int main()
{
    fast
    pre
/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

    int n;
    cin>>n;


    vector<pair<ld,ld>> v(n);

    forn(i,0,n)
    {
    	cin>>v[i].ff>>v[i].ss;
    }

    vector<int > pos(n);

    forn(i,0,n)
    {
    	pos[i] = i;
    }

    vector<ld> total;

    do
    {
    	ld sum = 0;
    	forn(i,0,n-1)
    	{
    		sum += dist(v[pos[i]],v[pos[i+1]]);
    	}

    	total.pb(sum);

    }
    while(next_permutation(all(pos)));

   ld sumAll = 0;
   
   forn(i,0,total.sze)
   {
		sumAll += total[i];   	
   } 	

   ld ans = sumAll/(ld)total.sze;

   cout<<ans;






    return 0;
}

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

int sumdigits(int n){
    int ans=0;
    while(n>0){
        ans+=n%10;
        n/=10;
    }
    return ans;
}

int main(){
    int n;
    cin>>n;
    int actsum,minsum=1000000;
    for(int i=1;i<n;i++){
        actsum=sumdigits(i)+sumdigits(n-i);
        if(actsum<minsum){
            minsum=actsum;
        }
    }
    cout<<minsum;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	Scanner scan = new Scanner(System.in);
	
	void compute() {
		int n = scan.nextInt();
		int d = scan.nextInt();
		
		System.out.println(n % (d * 2 + 1) == 0 ? n / (d * 2 + 1) : n / (d * 2 + 1) + 1);
	}
	
	
	public static void main(String...arg) {
		new Main().compute();
	}
}


Measured memory_bytes: 21844
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long[] sum = new long[n];
        sum[0] = a[0];
        for (int i = 1; i < n; i++)
        {
            sum[i] = sum[i - 1] + a[i];
        }

        var ans = long.MaxValue;

        //+-+=
        var flag = true;
        long count = 0;
        long tmp = 0;
        for (int i = 0; i < n; i++)
        {
            //前処理
            sum[i] += tmp;

            if (flag)
            {
                //0より大きい数字であることを確認
                if (sum[i] <= 0)
                {
                    tmp += sum[i] * (-1) + 1;
                    count += Math.Abs(sum[i] * (-1) + 1);
                    sum[i] += sum[i] * (-1) + 1;
                }
            }
            else
            {
                //0より小さい数字であることを確認
                if (sum[i] >= 0)
                {
                    tmp += sum[i] * (-1) - 1;
                    count += Math.Abs(sum[i] * (-1) - 1);
                    sum[i] += sum[i] * (-1) - 1;
                }
            }
            flag = !flag;
        }

        ans = Math.Min(ans, count);

        //-+-+
        sum[0] = a[0];
        for (int i = 1; i < n; i++)
        {
            sum[i] = sum[i - 1] + a[i];
        }

        flag = false;
        count = 0;
        tmp = 0;
        for (int i = 0; i < n; i++)
        {
            //前処理
            sum[i] += tmp;

            if (flag)
            {
                //0より大きい数字であることを確認
                if (sum[i] <= 0)
                {
                    tmp += sum[i] * (-1) + 1;
                    count += Math.Abs(sum[i] * (-1) + 1);
                    sum[i] += sum[i] * (-1) + 1;
                }
            }
            else
            {
                //0より小さい数字であることを確認
                if (sum[i] >= 0)
                {
                    tmp += sum[i] * (-1) - 1;
                    count += Math.Abs(sum[i] * (-1) - 1);
                    sum[i] += sum[i] * (-1) - 1;
                }

            }
            flag = !flag;
        }

        ans = Math.Min(ans, count);

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 31836
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		double x=0.0;
		double y=0.0;
		double sumangle = 0.0;
		String[] str = new String[2];
		while(true){
			str = br.readLine().split(",");
			int walk = Integer.parseInt(str[0]);
			int angle = Integer.parseInt(str[1]);
			if(walk == 0 && angle == 0){
				System.out.println((int)x);
				System.out.println((int)y);
				break;
			}
			y += (double)walk*Math.cos(Math.toRadians(sumangle));
			x += (double)walk*Math.sin(Math.toRadians(sumangle));
			sumangle += (double)angle;
		}
	}

}

Measured memory_bytes: 16912
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  
  cin >> n;
  for(int i = n;i <= 999;i++){
    if(i % 111 == 0){
      cout << i << endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
A = A[:x]
B.sort(reverse=True)
B = B[:y]

AB = A + B
AB.sort(reverse=True)
total = sum(AB)
C.sort()

while AB and C:
    point = AB.pop()
    candidate = C.pop()
    if candidate > point:
        total += candidate - point
    else:
        break

print(total)


Measured memory_bytes: 105444
n, m = [int(i) for i in input().split()]
# n, m = 100000, 100000

G = [[] for i in range(n + 1)]
C = [m for i in range(n + 1)]
for i in range(n - 1):
    x, y = [int(i) for i in input().split()]
    # x, y = i + 1, i + 2
    G[x].append(y)
    G[y].append(x)

ans = 1
def dfs(s):
    global ans, C, G
    stack = [s]
    while len(stack):
        u = stack[len(stack) - 1]
        stack.pop()
        ans *= C[u]
        ans %= 1000000007
        # print(u, C[u], ans)
        tot = 1
        if u != 1:
            tot += 1
        for v in G[u]:
            C[v] -= tot
            G[v].remove(u)
            stack.append(v)
            tot += 1

dfs(1)
print(ans)

Measured memory_bytes: 24240
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<pair<ll, ll>> X(N);
    rep(i, N) {
        ll tmp;
        cin >> tmp;
        X[i] = make_pair(tmp, i);
    }

    sort(X.begin(), X.end());
    // rep(i, N) { cout << X[i].first << "," << X[i].second << endl; }

    vector<ll> ans(N);
    rep(i, N) {
        if (i < N / 2)
            ans[X[i].second] = X[N / 2].first;
        else
            ans[X[i].second] = X[N / 2 - 1].first;
    }

    repv(ans) { cout << *it << endl; }
    return 0;
}

Measured memory_bytes: 6912
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6) #for deep recursion

N, Q = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(N-1)]
operations = [list(map(int, input().split())) for _ in range(Q)]

counts = [0] * N
for op in operations:
    p, x = op
    counts[p-1] += x
    
all_connected_vertices = {i: [] for i in range(1, 1+N)}
for a, b in edges:
    all_connected_vertices[a].append(b)
    all_connected_vertices[b].append(a)
    
def dfs(point, pre):
    connected_vertices = all_connected_vertices[point]
    for c in connected_vertices:
        if c == pre:
            continue
        counts[c-1] += counts[point-1]
        dfs(c, point)
    
dfs(1, -1)
    
print(*counts)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
#define INF 1152921504606846976
i64 N;
i64 A[MAX_N];
i64 dp[2 * MAX_N][2];

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];

    dp[0][0] = 0;
    dp[0][1] = -1 * INF;
    REP(i, N) {
        dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i]);
        dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i]);
    }

    cout << dp[N][0] << endl;

    return 0;
}

Measured memory_bytes: 2560
S,N,A,K,i,T;
main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d",&A,&K);
		while(T=A/K+1,A%K%T)A=(T-1)*K-T+A%K%T;
		S^=T-1;
	}
	puts(S?"Takahashi":"Aoki");
}

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

#define mod 1000000007
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

/*long C(long n, long r){
    if(n < r) return 0;
    long p[n+1][n+1];
    p[0][0] = 1;
    for(int i = 1; i <= n; i++){
        p[i][0] = 1;
        p[i][i] = 1;
        for(int j = 1; j <= i-1; j++){
            p[i][j] = p[i-1][j] + p[i-1][j-1];
        }
    }
    return p[n][r];
}*/

void solve()
{
    int sum = 0;
    REP(i, 3) {
        int a;
        cin >> a;
        sum += a;
    }
    if(sum >= 22){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
    return;
}

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


Measured memory_bytes: 256