akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  int n;
  cin >> n;
  vi s(n);
  bool flg=false;
  int ans=0;
  REP(i,n) {
    cin >> s[i];
    ans+=s[i];
    if(s[i]%10!=0) flg=true;
  }
  int mi=INF;
  sort(ALL(s));
  REP(i,n) {
    if(s[i]%10!=0) {
      mi=s[i];
      break;
    }
  }
  if(flg) {
    if(ans%10!=0) cout << ans << endl;
    else cout << ans - mi << endl;
  } else {
    cout << "0" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long[] Di;
        long E = 998244353;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            Di = new long[N];
            for (int i = 0; i < Di.length; i++) {
                Di[i] = sc.nextLong();
            }
        }
        if (N == 1) {
            System.out.println(1);
            return;
        }
        if (Di[0] != 0) {
            System.out.println(0);
            return;
        }
        long[] Num = new long[N];
        long maxDis = 0;
        for (long l : Di) {
            Num[(int) l]++;
            if (l >= maxDis) {
                maxDis = l;
            }
        }
        //System.out.println(Arrays.toString(Num));
        //System.out.println(maxDis);
        for (int i = 0; i <= maxDis; i++) {
            if (Num[i] == 0) {
                System.out.println(0);
                return;
            }
        }
        if (Num[0] != 1) {
            System.out.println(0);
            return;
        }
        long result = 1;
        for (int i = 1; i <= maxDis; i++) {
            long up = Num[i - 1];
            long down = Num[i];
            long temp = 1;
            up = up % E;
            while (down > 0) {
                temp = temp * up;
                temp = temp % E;
                down--;
            }
            result = result * temp;
            result = result % E;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 62572
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

ll a[100100],b[100100],c[100100];

ll gcd(ll x, ll y){
	return ((y)?gcd(y,x%y):x);
}

int main(void){
	int n,i;
	ll ans;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	b[i] = 0ll;
	for(i=0; i<n; ++i){
		b[i+1] = gcd(b[i],a[i]);
	}
	c[n-1] = 0ll;
	for(i=(n-1); i>0; --i){
		c[i-1] = gcd(c[i],a[i]);
	}
	ans = b[n];
	for(i=0; i<n; ++i){
		ans = max(ans,gcd(b[i],c[i]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
bool rever(int a,int b) { return a>b; }
int fpow(int b,int p,int m)
{
	if(p==0) return 1;
	int t=fpow(b,p/2,m);
	if(p%2) return t*t%m*b%m;
	return t*t%m;
}
int fpow(int b,int p)
{
	if(p==0) return 1;
	int t=fpow(b,p/2);
	if(p%2) return t*t*b;
	return t*t;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int ans=0,a=0,b=0;
	bool fr=false,ba=false;
	string s;
	For(i,1,n)
	{
		cin>>s;
		For(j,0,sz(s)-2) if(s[j]=='A' && s[j+1]=='B') ans++;
		if(s[0]=='B' && s[sz(s)-1]=='A') a++,b++;
		else if(s[0]=='B') b++,ba=true;
		else if(s[sz(s)-1]=='A') a++,fr=true;
	}
	if(fr && ba) ans+=min(a,b);
	else if(fr) ans+=min(max(0ll,a-1),b);
	else if(ba) ans+=min(a,max(0ll,b-1));
	else ans+=min(max(0ll,a-1),max(0ll,b-1));
	cout<<ans<<"\n";
	return 0;
}










Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
    
    int A[3];
    for(int i = 0; i < 3; i++){
        cin >> A[i];
    }
    
    sort(A, A+3);
    int ans = abs(A[0] - A[2]);
    cout << ans << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int n,m;
    int p;
    string s;
    ll seikai=0,pena=0;
    cin >> n >> m;
    vector<int> ques(n,0);
    for(int i=0;i<m;i++){
        cin >> p >> s;
        if(s=="AC"){
            if(ques[p]==-1){

            }else{
                seikai++;
                pena = pena + ques[p];
                ques[p] = -1;
            }
        }else{
            if(ques[p]==-1){

            }else{
                ques[p]++;
            }
        }
    }
    cout << seikai << " " << pena << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int A,B;
  cin >> A >> B;
  cout << max(0,A - 2 * B) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char s[10];
  
  scanf("%3s", s);
  
  if(s[0]=='M'){
  	printf("6");
  }else if(s[0]=='T'&&s[1]=='U'){
    printf("5");
  }else if(s[0]=='W'){
    printf("4");
  }else if(s[0]=='T' && s[1]=='H'){
    printf("3");
  }else if(s[0]=='F'){
  	printf("2");
  }else if(s[0]=='S' && s[1]=='A'){
    printf("1");
  }else{
    printf("7");
  }
  return 0;
  
}


Measured memory_bytes: 128
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
int main()
{
    IO
    ll n, m;
    cin >> n >> m;
    vector<pll>v(m);
    REP(i, 0, m)    cin >> v[i].F >> v[i].S;
    sort(v.begin(), v.end());
    ll a = v[0].F, b = v[0].S;
    REP(i, 1, m)
    {
        a = max(v[i].F, a);
        b = min(v[i].S, b);
    }
    cout << max(b - a + 1, 0ll);
    return 0;
}


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

int main() {
  int H, N; cin >> H >> N;
  int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  int sum = 0; for (int i = 0; i < N; i++) sum += A[i];
  if (H - sum <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;

int main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<long long int> s(a+2);
  vector<long long int> t(b+2);
  s[0] = -1e15;
  t[0] = -1e15;
  s[a+1] = 1e15;
  t[b+1] = 1e15;
  for(int i=1; i<=a; i++) cin >> s[i];
  for(int i=1; i<=b; i++) cin >> t[i];

  long long int x;
  for(int i=0; i<q; i++) {
    cin >> x;
    auto sp = lower_bound(s.begin(), s.end(), x) - s.begin();
    auto tp = lower_bound(t.begin(), t.end(), x) - t.begin();
    long long int ls = x-s[sp-1];
    long long int rs = s[sp]-x;
    long long int lt = x-t[tp-1];
    long long int rt = t[tp]-x;
    long long int ans = min({
      max(ls, lt),
      max(rs, rt),
      2*min(ls, rt)+max(ls, rt),
      2*min(lt, rs)+max(lt, rs)
    });

    cout << ans << endl;

  }

  return 0;
}


//EOF


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	map<int, int> mp;
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += mp[i - a[i]];
		++mp[i + a[i]];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 21032
# 3.4.3

import re
from collections import deque
from functools import reduce
from itertools import permutations
from math import pi
from operator import itemgetter
from operator import mul
from operator import xor
from os import linesep
from queue import PriorityQueue
from sys import stdin


def rline() -> str:
    return stdin.readline().strip()


def rlines(hint: int = 1):
    ret = ['' for i in range(hint)]
    for i in range(hint):
        ret[i] = rline()
    return ret


def htokens(hint: int = 1):
    lns = rlines(hint)
    ret = list(map(lambda ln: ln.split(), lns))
    # if return value has one and only one element(list),
    if hint == 1:
        # then add an empty list.
        ret.append([])
    return ret


def vtokens(hint: int = 1):
    m, _ = htokens()
    wint = len(m)
    ret = [[None] * hint for i in range(wint)]
    for y in range(hint):
        if y != 0:
            m, _ = htokens()
        # convert horizontal to vertical
        x = 0
        for v in m:
            ret[x][y] = v
            x += 1
    # if return value has one and only one element(list),
    if wint == 1:
        # then add an empty list.
        ret.append([])
    return ret


def rint(radix: int = 10) -> int:
    return int(rline(), radix)


def hints(hint: int = 1, radix: int = 10):
    ret = htokens(hint)
    for i in range(len(ret)):
        ret[i] = list(map(lambda v: int(v, radix), ret[i]))
    return ret


def vints(hint: int = 1, radix: int = 10):
    ret = vtokens(hint)
    for i in range(len(ret)):
        ret[i] = list(map(lambda v: int(v, radix), ret[i]))
    return ret


def mat(hint: int, wint: int):
    return [[None]*wint for i in range(hint)]


def filllist(lst, value: int) -> None:
    # destructive.
    for i in range(len(lst)):
        lst[i] = value


def isprime(n: int) -> bool:
    if n <= 1:
        return False
    if n in (2, 3, 5):
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    lst = int(n**0.5)
    f = 5
    while f <= lst:
        if n % f == 0:
            return False
        if n % (f + 2) == 0:
            return False
        f += 6
    return True


def strmat(matrix, lnsep: str = linesep, fieldsep: str = ' ') -> str:
    return lnsep.join(map(lambda row: fieldsep.join(map(str, row)), matrix))


def strbool(boolval: int) -> str:
    return ['No', 'Yes'][boolval]


def solve() -> None:
    # read here
    (k, x), _ = hints()

    # solve here
    arr = [i for i in range(x-k+1, x+k)]
    ans = [arr]

    # print here
    print(strmat(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 4196
#https://atcoder.jp/contests/abc089/tasks/abc089_b
S_list = [input() for i in range(2)]
N = map(int,S_list[0].split())    
A_list = set(S_list[1].split())
four = {"P","W","G","Y"}
if len(A_list & four) == 3:
    result ="Three"
else:
    result ="Four"
print(result)

Measured memory_bytes: 9044
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 1_000_000_007

A = np.array(read().split(), np.int64)[1:]

x = A.sum() % MOD
y = (A * A % MOD).sum() % MOD
x = (x * x - y) % MOD
if x & 1:
    x += MOD
print(x // 2)

Measured memory_bytes: 40252
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    string s; cin >> s;
    bool p = true;
    rep(i, s.length()){
        if(s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;
    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, M; cin >> N >> M;
    ll res = min(N, M/2);
    if(M - 2*N > 0){
        res += (M-2*N)/4;
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  in(string, s);
  s += ' ';
  int ans = 0;
  for (int i = 0; i < s.size() - 1; ++i) {
    if (s[i + 1] != s[i]) ++ans;
  }
  out(ans);
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>

using namespace std;

bool prime[1000001];
bool dp[1000001];
int menu[31];
void seive(int s){
	for(int i=0;i<=s;i++)prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i<=s;i++){
		if(prime[2]==true){
			for(int j=i*2;j<=s;j+=i){
				prime[j]=false;
			}
		}
	}
}

int main(void){
	seive(1000000);
	int n,x;
	while(1){
		int max=0;
		memset(dp,false,sizeof(dp));
		scanf("%d%d",&n,&x);
		if(n==0 && x==0)break;
		for(int i=0;i<n;i++){
			scanf("%d",&menu[i]);
		}
		dp[0]=true;
		for(int i=0;i<n;i++){
			for(int j=menu[i];j<=x;j++){
				if(dp[j-menu[i]]==true)dp[j]=true;
			}
		}
		for(int i=0;i<=x;i++){
			if(dp[i]==true && prime[i]==true)max=i;
		}
		if(max>0)printf("%d\n",max);
		else printf("NA\n");
	}
    return 0;
}

Measured memory_bytes: 2832
#include <stdio.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(void)
{
    ll ans = 0;

    char s[201];
    scanf("%s", s);

    ll k;
    scanf("%lld", &k);

    int n = strlen(s);
    char tmp[201];
    strcpy(tmp, s);
    strcat(tmp, s);

    int flag = 1;
    rep(i, n - 1) if (s[i] != s[i + 1])
    {
        flag = 0;
        //puts("flag=0");
    }

    int first = 0;
    rep(i, n) if (s[i] == s[i + 1])
    {
        s[i + 1] = 'A';
        first++;
    }

    int second = 0;
    rep(i, n * 2) if (tmp[i] == tmp[i + 1])
    {
        tmp[i + 1] = 'A';
        second++;
    }

    if (flag)
        ans = n * k / 2;
    else
        ans = (ll)first + (ll)(second - first) * (k - 1);

    //printf("%s\n", s);
    printf("%lld\n", ans);

    return 0;
}

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

int main(){
    int n;
            cin>>n;
            string s;
            cin>>s;
            int countr = 0;
            for(int i = 0; i < n; i++){
                if(s[i] == 'R') countr++;
            }
            int ans = 0;
            for(int i = 0; i < countr; i++){
                if(s[i] != 'R') ans++;
            }
            cout<<ans;
}

Measured memory_bytes: 3744
def main():
    N = int(input())
    A_list = list(map(int, input().split()))

    step = [0] * (N + 1)
    i = 0
    a_old = 0
    for a in A_list :
        if i == 0 :
            step[i] = 0
            a_old = a
        else :
            #print(step[i] + a_old)
            #print(a)
            if a >= (step[i] + a_old) :
                step[i+1] = 0
            else :
                step[i+1] = step[i] + a_old - a
            a_old = a
        i += 1
        #print(step)


    ans = sum(step)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32240
import math
A, B, C, D, E, F = map(int,input().split())
w_max = 30

def reduce(x): #約分
  #print(x)
  d = math.gcd(x[0], x[1])
  return (x[0] // d, x[1] // d)

def is_valid(s, w): #砂糖s、水100w
  return s <= w * E and s + 100*w <= F

ratios = set()
recipe = {}

Waters = [] 
for a in range(0, w_max+1, A):
  for b in range(0, w_max+1, B):
    if (a == 0 and b == 0) or a + b > F:
      continue
    Waters.append(a+b)
Waters.sort()

s_max = 0
for x in Waters:
  s_max = max(s_max, min(x*E,F-100*x))

Sugars = [] 
for c in range(0, s_max+1, C):
  for d in range(0, s_max+1, D):
    Sugars.append(c+d)
Sugars.sort()

i = 0
ascend = True
for w in Waters:
  while i >= 0 and not is_valid(Sugars[i], w):
    i -= 1
  while 0 <= i < len(Sugars) and is_valid(Sugars[i], w):
    i += 1
  i -= 1
  if i >= 0:
    ratios.add(reduce((Sugars[i], w)))
    recipe[reduce((Sugars[i], w))] = (Sugars[i], w)

ans = recipe[max(ratios, key = lambda x: float(x[0]/x[1]))]
print(ans[1]*100 + ans[0], ans[0])
  
  
  
  
  

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
	vector<int> v[200005];
	int vis[200005],c;
void dfs(int r){
	vis[r]=1;
	c++;
	for(int x: v[r]){
		if(vis[x]!=1)
			dfs(x);
	}
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n,m;
	cin>>n>>m;
	set<pair<int,int>> st;
	while(m--){
		int a,b;
		cin>>a>>b;
		if(st.count({a,b})==0 && st.count({b,a})==0){
			st.insert({a,b});
			v[a].push_back(b);
			v[b].push_back(a);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			c=0;
			dfs(i);
			ans=max(ans,c);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int N, M;
vector<vector<int>> graph(100000);
vector<bool> searched(100000, false);

void search(int v) {
    if (searched[v]) return;
    searched[v] = true;
    for (int i : graph[v]) {
        search(i);
    }
    return;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        graph[X-1].push_back(Y-1);
        graph[Y-1].push_back(X-1);
    }
    
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (!searched[i]) {
            search(i);
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 8832
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main {
  def isParallel(x1:Double, y1:Double, x2:Double, y2:Double, x3:Double, y3:Double, x4:Double, y4:Double) = {
    val p = (x2-x1)*(y4-y3)-(x4-x3)*(y2-y1)
    if(p < (1e-10) && p > -(1e-10)) true else false
  }

  def isOrthogonal(x1:Double, y1:Double, x2:Double, y2:Double, x3:Double, y3:Double, x4:Double, y4:Double) = {
    val p =  (x2-x1)*(x4-x3)+(y2-y1)*(y4-y3)
    if(p < (1e-10) && p > -(1e-10)) true else false
  }

  def main(args:Array[String]) = {
   val n = readInt
   val b = new ArrayBuffer[Int]

   for(i<-1 to n) {
     val p = readLine.split(" ").map(_.toDouble)
     if(isParallel(p(0),p(1),p(2),p(3),p(4),p(5),p(6),p(7))) b += 2
     else if(isOrthogonal(p(0),p(1),p(2),p(3),p(4),p(5),p(6),p(7))) b += 1
     else b += 0
   }
   println(b.mkString("\n"))
  }
}

Measured memory_bytes: 48496
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	int n, l;
	cin >> n >> l;
	vector<string> v(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	sort(v.begin(), v.end());
	for (auto s : v)cout << s;
	cout << endl;
}

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

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int fo=0,t=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='c')cout<<"No"<<endl;
		else if(s[i]=='a'){
			if(t<a+b){
				cout<<"Yes"<<endl;
				t++;
				}
			else cout<<"No"<<endl;	
			}
		else{fo++;
			if(t<a+b&&fo<=b){cout<<"Yes"<<endl;t++;}
			else cout<<"No"<<endl;
			}	
		}
	}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int v[13], x, y;
	v[0] = 0;
	v[1] = v[3] = v[5] = v[7] = v[8] = v[10] = v[12] = 1;
	v[2] = 2;
	v[4] = v[6] = v[9] = v[11] = 3;

	cin >> x >> y;
	if (v[x] == v[y]) cout << "Yes\n";
	else cout << "No\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;

int main() {
    int N, K, A;
    cin >> N >> K;
    rep(i, N) cin >> A;
    cout << (N - 1 + K - 2) / (K - 1) << "\n";
}

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

int main(){
  int N;
  string S;
  int P;
  pair<pair<string,int>,int> p[100];

  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S >> P;
    p[i] = make_pair(make_pair(S, -P), i+1);
  }
  sort(p, p+N);

  for(int i = 0; i < N; i++){
    cout << p[i].second << endl;
  }
}

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

using namespace std;

int main () {
    
    string s;
    cin >> s;

    cout << ((s.size() >= 4 && 
            s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
k = int(input())

l = [1,2,3,4,5,6,7,8,9]

c = 0
while k>len(l):
    f = str(l[c])

    if int(f[-1])!=0:
        l.append(int(f)*10 + int(f[-1])-1)

    l.append(int(f)*10 + int(f[-1]))

    if int(f[-1])!=9:
        l.append(int(f)*10 + int(f[-1])+1)

    c += 1

print(l[k-1])

Measured memory_bytes: 7192
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll ar[n];
    ll dp[n][n];
    memset(dp,0,sizeof(dp));
    ll sum=0;
    for(int x=0;x<n;x++){
        cin>>ar[x];
        sum+=ar[x];
        dp[x][x]=ar[x];
    }
    for(ll len=2;len<=n;len++){
        for(ll x=0;x<n;x++){
            ll y=x+len-1;
            if(y>=n)break;
            ll sum1=0,sum2=0,sum3=0;
            if(x+2<=y)sum1=dp[x+2][y];
            if(x+1<=y-1)sum2=dp[x+1][y-1];
            if(x<=y-2)sum3=dp[x][y-2];
            ll ans1=ar[x]+min(sum1,sum2);
            ll ans2=ar[y]+min(sum2,sum3);
            dp[x][y]=max(ans1,ans2);
        }
    }
    ll X=dp[0][n-1];
    ll Y=sum-X;
    cout<<X-Y<<endl;
    return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

struct UnionFind{
    vector<int> parent, rank;
    UnionFind(int n){ parent = vector<int>(n, -1); rank = vector<int>(n, 0); }
    int find(int x){
        if(parent[x] == -1) return x;
        else return (parent[x] = find(parent[x]));
    }
    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(rank[x] < rank[y])
            parent[x] = y;
        else
            parent[y] = x;
        if(rank[x] == rank[y])
            ++rank[x];
        return true;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

typedef int Weight;
struct Edge{
    int from, to;
    Weight weight;
    int rev;     // ネットワークフロー時の逆辺
    Edge(int from, int to, Weight weight) :
        from(from), to(to), weight(weight) { }
    Edge(int from, int to, Weight weight, int rev) :
        from(from), to(to), weight(weight), rev(rev){ }
};
bool operator < (const Edge &a, const Edge &b){
    if(a.weight != b.weight) return a.weight > b.weight;
    if(a.from != b.from) return a.from > b.from;
    return  a.to > b.to;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void addFlowEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, 0, g[a].size() - 1));
}
void addUndirectedEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, c, g[a].size() - 1));
}

void dfs(Graph &g, int v, int weight, vector<int> &vst, vector<int> &c) {
	vst[v] = 1;
	for(auto e: g[v]) {
		if(e.weight > weight) continue;
		c[e.rev] = 2;
		if(!vst[e.to]) {
			dfs(g, e.to, weight, vst, c);
		}
	}
}

signed main(){
	int N, M;
	cin >> N >> M;
	vector<int> X(N + 1), A(M), B(M), Y(M);
	for(int i = 1; i <= N; ++i) {
		cin >> X[i];
	}
	Edges es;
	for(int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i] >> Y[i];
		es.push_back(Edge(A[i], B[i], Y[i]));
	}
	sort(ALL(es));
	reverse(ALL(es));
	vector<int> sum = X;
	vector<int> c(M);
	UnionFind uf(N + 1);

	for(int i = 0; i < es.size(); ++i){
		es[i].rev = i;
		Edge e = es[i];
		int a = sum[uf.find(e.from)], b = sum[uf.find(e.to)];
		bool t = uf.unite(e.from, e.to);
		int u = uf.find(e.from);
		if(t) {
			sum[u] = a + b;
		}
		if(sum[u] >= e.weight) {
			c[i] = 1;
		}
	}

	Graph g(N + 1);
	vector<int> vst(N);
	for(int i = 0; i < es.size(); ++i) {
		Edge e = es[i];
		g[e.from].push_back(Edge(e.from, e.to, e.weight, i));
		g[e.to].push_back(Edge(e.to, e.from, e.weight, i));
	}

	for(int i = es.size() - 1; i >= 0; --i) {
		if(c[i] == 1) {
			dfs(g, es[i].from, es[i].weight, vst, c);
		}
	}
	int res = 0;
	for(int i = 0; i < c.size(); ++i) {
		if(c[i] == 0){
			res++;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 27500
L=[]
for _ in range(5):
   L.append(int(input())) 
   
ans=0
Lamari=[]
   
for i in L:
    if i%10!=0:
        Lamari.append(10-i%10)
    ans+=i

Lamari.sort(reverse=True)

print(ans+sum(Lamari[1:]))

Measured memory_bytes: 3060
#include <stdio.h>

int main  (void)
{
  int a,b,c,d,e;
  scanf("%d",&a);
  b=a/500;
  e=a%500;
  c=e/5;
  d=1000*b+5*c;
  printf("%d\n",d);
}
  
  
   

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
using namespace std;
using ll = long long;
vector<ll> a;
int main(){
    ll n,m,b,c,x;
    map<ll,ll> mp;
    vector<ll> a;
    cin >> n >> m;
    for(ll i=0;i<n;i++){
        cin >> x;
        mp[x]++;
        a.push_back(x);
    }
    for(ll i=0;i<m;i++){
        cin >> b >> c;
        mp[c]+=b;
        a.push_back(c);
    }
    sort(a.begin(),a.end());
    ll sum=n,ans=0;
    for(ll i=a.size()-1;sum>0;i--){
        if(mp[a[i]]>=0){
            ans+=a[i]*min(sum,mp[a[i]]);
            sum-=mp[a[i]];
            mp[a[i]]=0;
        }
    }
    cout << ans;
}

Measured memory_bytes: 14320
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
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;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class SCC{//cmp(0 - kk-1) is scc's return. Same number is group. The number is no relatoin.
	public:
	int n;
	vvi G,rG,tG;
	vector<bool>used;
	vi vs,cmp;
	SCC(int size){
		n=size;
		G=rG=vvi(n);
		used=vector<bool>(n);
		cmp=vi(n);
		vs=vi(0);
	}
	void add_edge(int s,int t){
		G[s].pb(t);
		rG[t].pb(s);
	}
	void rdfs(int v,int k){
		used[v]=true;
		cmp[v]=k;
		rep(i,rG[v].size())if(!used[rG[v][i]])rdfs(rG[v][i],k);
	}
	void dfs(int v){
		used[v]=true;
		rep(i,G[v].size())if(!used[G[v][i]])dfs(G[v][i]);
		vs.pb(v);
	}
	int scc(){
		rep(i,n)used[i]=false;
		rep(v,n)if(!used[v])dfs(v);
		rep(i,n)used[i]=false;
		int kk=0;
		for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]])rdfs(vs[i],kk++);
		return kk;  
	}
	void make(int size){
		int N=size;
		tG=vvi(N);
		rep(i,n)rep(j,G[i].size())if(cmp[i]!=cmp[G[i][j]]){
//			tG[cmp[i]].pb(cmp[G[i][j]]);
			tG[cmp[G[i][j]]].pb(cmp[i]);
		}
	}
};
int main(){
	int n;
	while(cin>>n,n){
		vd d(n);
//		vvi G(n);
		SCC scc(n);
		rep(i,n){
			cin>>d[i];
			int a;cin>>a;
			rep(j,a){
				int b;cin>>b;
				b--;
				scc.add_edge(i,b);
			}
		}
		int N=scc.scc();
		scc.make(N);
		vvi rG=scc.tG;
		vi c=scc.cmp;
		vd nd(N);
		rep(i,N){
			double t=1;
			rep(j,n)if(c[j]==i)t*=d[j];
			nd[i]=t;
		}
		double out=1;
		rep(i,N)if(!rG[i].size())
			out*=(1-nd[i]);
		
		cout<<shosu(9)<<out<<endl;
	}
}







Measured memory_bytes: 3368
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int a, b;

int main() {
  cin >> a >> b;
  int ans = max(a - b*2, 0);
  cout << ans;
}

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

int generate_open(int n, int open[10]) {
	int i;
	int j;
	if(n < 1 || n > 1023) {
		for(i = 0; i < 10; i += 1) {
			open[i] = 0;
		}
		return 0;
	}
	j = 512;
	for(i = 0; i < 10; i += 1) {
		open[i] = n / j;
		n -= open[i] * j;
		j /= 2;
	}
	return 0;
}

int eval_bene(int N, int F[128][10], int P[128][11], int open[10]) {
	int i, j;
	int tot_bene;
	int cnt;

	tot_bene = 0;
	for(i = 0; i < N; i += 1) {
		cnt = 0;
		for(j = 0; j < 10; j += 1) {
			cnt += F[i][j] * open[j];
		}
		tot_bene += P[i][cnt];
	}

	return tot_bene;
}

int main(void) {
	int i, j;
	int N;
	int bene, bene_ol;
	int F[128][10];
	int P[128][11];
	int open[10] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);

	for(i = 0; i < N; i += 1) {
		fgets(buf, sizeof(buf), stdin);
		ch = strtok(buf, " ");
		F[i][0] = atoi(ch);
		for(j = 1; j < 10 ; j += 1) {
			ch = strtok(NULL, " ");
			F[i][j] = atoi(ch);
		}
	}
	for(i = 0; i < N; i += 1) {
		fgets(buf, sizeof(buf), stdin);
		ch = strtok(buf, " ");
		P[i][0] = atoi(ch);
		for(j = 1; j < 11 ; j += 1) {
			ch = strtok(NULL, " ");
			P[i][j] = atoi(ch);
		}
	}

	bene_ol = eval_bene(N, F, P, open);
	for(i = 1; i < 1024; i += 1) {
		generate_open(i, open);
		bene = eval_bene(N, F, P, open);
		if(bene_ol < bene) {
			bene_ol = bene;
			//printf("%d:%d\n", i, bene_ol);
		}
	}

	printf("%d\n", bene_ol);

	return 0;
}


Measured memory_bytes: 2112
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
a~>(f,x) = [a] ++ (null x)?([],f x)
half = flip div 2
aliq = ((0==).).mod

main = do
 getLine
 inputs <- readLnInt
 print $ solve inputs

solve s = sum $ solve2 s

solve2 s@(a:b) = (solve3 s)~>(solve2,b)

solve3 s@(a:b:c) = a*b + (null c)?(0,solve3 (a:c))
solve3 [a] = 0


Measured memory_bytes: 508
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if (10000*i) + (5000*j) + (1000*(n-i-j)) == y:
            print(i, j, n-i-j)
            exit()

print("-1 -1 -1")

Measured memory_bytes: 40684
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		int x;
		cin>>x;
		x=x%1000;
		if(x)
		cout<<1000-x%1000;
		else cout<<0;
    }
    return 0;
} 


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,k;
    scanf("%d %d",&a,&b);
    if(a>b)
    {
        for(i=0;i<a;i++)
        {
            printf("%d",b);
        }
    }
    else
    {
        for(i=0;i<b;i++)
        {
            printf("%d",a);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3724
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
using namespace std;
using namespace __gnu_cxx;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;

int a[3];
const int n=3;

int main()
{
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	printf("%d\n",a[0]+a[1]);
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	//奇数と偶数の数を数えたい(配列それぞれについて数えるから、n回)
	int ki = 0;
	int gu = 0;
	for (int i = 0; i < n; i++) {
		//a.at(i)が奇数か偶数かを決めたい
		if (a.at(i) % 2 == 0) gu++;
		else ki++;
	}
	if (ki%2==0||(ki==1&&gu==0)) cout << "YES" << endl;
	else cout << "NO" << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#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 REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
             
#define pb push_back  
#define PII pair<int,int>   
             
#define VS vector<string>   
#define VI vector<int>
#define ll long long int    
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {
    int n;   
    cin >> n;
    vector<int> s;    
    int tmp; 
    REP(i,n) {  
        cin >> tmp;   
        s.pb(tmp);    
    }        
    int ans = 0;
    REP(i,n) {  
        ans += s[i];  
    }        
    sort(s.begin(), s.end());   
    if(ans % 10 == 0) {     
        REP(i,n) {    
            if(s[i] % 10 != 0) {
                ans -= s[i];
                break;
            }                                                                                                             
        }    
    }        
    if(ans % 10 == 0) cout << 0 << endl;
    else cout << ans << endl;   
}  

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#define rep(i,l,n) for(i=l;i<n;i++)

int main(void){
	int n,ans,a,b,c,d;

	while(scanf("%d",&n)!=EOF){
		ans=0;
		rep(a,0,10){
			rep(b,0,10){
				rep(c,0,10){
					rep(d,0,10){
						if(a+b+c+d==n) ans++;
					}
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#include<unordered_map>
unordered_map<int,vector<int> >v;
//vector<int> v[1<<26];
int mark[200010];
int dp[200010];
int main(){
	string s;
	cin>>s;
	int r=1;
	lol(i,26)r*=2;
	lol(i,s.size()+1)dp[i]=mod;
	dp[0]=0;
	mark[0]=0;
	int cnt[26]={0};
	for(int i=0;i<s.size();i++){
		cnt[s[i]-'a']++;
		cnt[s[i]-'a']%=2;
		int tmp=0;
		int a=1;
		lol(j,26){
			tmp+=a*cnt[j];
			a*=2;
		}
		v[tmp].push_back(i+1);
		mark[i+1]=tmp;
	}

	for(int i=0;i<s.size();i++){
		int k=mark[i];
		
		if(upper_bound(v[k].begin(),v[k].end(),i)!=v[k].end()){
			int it=*upper_bound(v[k].begin(),v[k].end(),i);
			dp[it]=min(dp[it],dp[i]);
		}
		int a=1;
		for(int j=0;j<26;j++){
			int tmp=mark[i];
			if(mark[i]%(a*2)<a){
				tmp+=a;
			}
			else tmp-=a;
			//tmpが,mark[i]から1bitだけ変化したもの
			a*=2;
			k=tmp;
			if(upper_bound(v[k].begin(),v[k].end(),i)!=v[k].end()){
				int it=*upper_bound(v[k].begin(),v[k].end(),i);
				dp[it]=min(dp[it],dp[i]+1);
			}
		}
		//cout<<dp[i]<<" ";
	}
	cout<<max(1,dp[s.size()])<<endl;
	return 0;
}


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

int main() {
  
  string a, b, c;
  cin >> a >> b >> c;
  
  if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main ()
{
    long long  a, b, k;
    cin >> a >> b >> k;
    if(a >= k)
        cout << a - k << ' ' << b << endl;
    else
    {
        if(k - a >= b)
            cout << 0 << ' ' << 0 << endl;
        else
            cout << 0 << ' ' << b -(k - a) << endl;
    }
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	x := nextInt()
	a := nextInt()
	b := nextInt()
	x -= a
	fmt.Println(x % b)
}

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

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  vector<int> vec(n);
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int countali = 0;
  int countbob = 0;
  for(i=0;i<n;i+=2){
    countali += vec.at(i);
  }
  for(i=1;i<n;i+=2){
    countbob += vec.at(i);
  }
  int ans = countali - countbob;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  constexpr int xmax = 46297;
  int N;
  cin >> N;
  for (int x = 1; x <= xmax; x++) {
    const int tmp = x * 108 / 100;
    if (tmp == N) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pr> t(n, {0,0});

    int p;
    string s;
    rep(i, m) {
        cin >> p >> s;
        p--;
        if (s == "AC") {
            t[p].first++;
        }
        else {
            if (t[p].first < 1) {
                t[p].second++;
            }
        }
    }

    int ac = 0;
    int wa = 0;
    rep(i, n) {
        if (t[i].first > 0) {
            ac++;
            wa += t[i].second;
        }
    }

    cout << ac << " " << wa << endl;
    return 0;
}

Measured memory_bytes: 4040