akhauriyash/Code-Regression huggingface dataset:
#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a .30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld long double

using namespace std;

// mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int k; cin >> k;
    string s; cin >> s;
    int n = (int) s.size();
    k = min(k, n);
    for (int i = 0; i < k; ++i) {
        cout << s[i];
    }
    if (n != k) {
        cout << "...";
    }
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif

    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3168
#define ll long long int
#define pb push_back
#define mp make_pair
#include <bits/stdc++.h>
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	ll t=1,r,n,a,b,c,x,y,sum,cnt,i,j,k,m,l,q,maxx,minn,temp,ans,flag,z,h,w,p,ts;
	
	string str,ttr;
	long double dans;
	
	
	
//	cin >> t;

	
	for(ts=1;ts<=t;ts++)
	{
	    flag=0;sum=0;cnt=0;ans=0;maxx=0,minn=99999999999; x=0;y=0;temp=0;
	    
	    cin >> n; 
	    
	   
	    a=n/500;
	    n=n-(a*500);
	    ans=ans+(a*1000);
	    b=n/5;
	    ans=ans+(b*5);
	    
	    
	    
	   cout << ans <<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete



main = getInt >>= flip replicateM getInts . (subtract 1) >>= mapM_ print . map (foldl (\t [c,s,f] -> c + max s (f * (div (t + f - 1) f))) 0) . tails

Measured memory_bytes: 1404
#include <iostream>
using namespace std;
int j,sum;

int dig(int l);

int main(){

int n;
cin >>n;
if (n%dig(n)==0){cout << "Yes" << endl;}
else {cout << "No" << endl;}


return 0;
}

int dig(int l){

while (l>0){

    j=l%10;
    sum+=j;
    l = l/10;
}
return sum;
}


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

int main() {
    ll n, m;
    cin >> n >> m;
    vector<int> a(n);
    bool flag = true;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<pair<int,int>> p(m);
    for (int i = 0; i < m; i++) {
        int b, c;
        cin >> b >> c;
        p.push_back({c,b});
    }
    sort(p.rbegin(), p.rend());
    for (int i = 0; i < p.size(); i++) {
        int c = p[i].first, b = p[i].second;
        for (int j = 0; j < b; j++) {
            if (a[0] >= c) {
                break;
                flag = false;
            }
            a.erase(a.begin());
            a.push_back(c);
        }
        if (flag == false) break;
    }
    ll ans = 0;
    for (int i = 0; i < a.size(); i++) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

template <unsigned m> struct Mint {
    Mint():val(0){}
    Mint(int raw):val((raw%m+m)%m){}
    Mint(long long raw):val((raw%m+m)%m){}
    Mint(unsigned raw):val(raw%m){}
    Mint(unsigned long long raw):val(raw%m){}
    friend Mint operator+(Mint a, Mint b) { return a.val + b.val; }
    friend Mint operator-(Mint a, Mint b) { return m + a.val - b.val; }
    friend Mint operator*(Mint a, Mint b) { return 1ll * a.val * b.val; }
    friend Mint operator/(Mint a, Mint b) { return a * qpow(b, m-2); }
    friend Mint& operator+=(Mint& a, Mint b) { return a = a + b; }
    friend Mint& operator-=(Mint& a, Mint b) { return a = a - b; }
    friend Mint& operator*=(Mint& a, Mint b) { return a = a * b; }
    friend Mint& operator/=(Mint& a, Mint b) { return a = a / b; }
    friend bool operator==(Mint a, Mint b) { return a.val == b.val; }
    friend bool operator!=(Mint a, Mint b) { return a.val != b.val; }
    friend ostream& operator<<(ostream& out, Mint x) { return out << x.val; }
    unsigned val;
};

using M = Mint<1'000'000'000 + 7>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto k = load<string>();
    auto d = load<int>();
    
    auto dyn = vector<vector<M>>(k.size()+1, vector<M>(d, 0));
    dyn[0][0] = 1;
    for (auto i=0; i<(int)k.size(); ++i)
        for (auto r=0; r<d; ++r)
            for (auto c=0; c<10; ++c)
                dyn[i+1][(r+c)%d] += dyn[i][r];

    auto prefr = 0;
    auto total = M(0);
    for (auto i=(int)k.size()-1; i>=0; --i) {
        auto c = k[((int)k.size()-1)-i] - '0';
        for (auto ci = i == (int)k.size()-1 ? 1 : 0; ci<c; ++ci) {
            auto prefir = (prefr + ci) % d;
            total += dyn[i][(d - prefir)%d];
            clog << "A i=" << i << " ci=" << ci << " -> " << dyn[i][(d - prefir)%d] << endl;
        }
        if (i != (int)k.size()-1) {
            for (auto c0=1; c0<10; ++c0) {
                total += dyn[i][(d - c0%d)%d];
                clog << "B i=" << i << " c0=" << c0 << " -> " << dyn[i][(d - c0%d)%d] << endl;
            }
        }
        prefr = (prefr + c) % d;
    }
    if (prefr == 0)
        total += 1;
    cout << total << '\n';
}


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

int main() {
    int n, m, i, ans1 = 0;
    cin >> n >> m;
    bool ans[n];
    int h[n];
    for(i = 0; i < n; i++){
        cin >> h[i];
        ans[i] = true;
    }
    for(i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        if(h[a-1] < h[b-1]) ans[a-1] = false;
        else if(h[a-1] > h[b-1]) ans[b-1] = false;
        else{
            ans[a-1] = false;
            ans[b-1] = false;
        }
    }
    for(i = 0; i < n; i++){
        if(ans[i]) {
            ans1++;
            //cout << i << endl;
        }
    }
    cout << ans1 << endl;
}

Measured memory_bytes: 4112
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

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

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) ans += i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 n, a, b;
    cin >> n >> a >> b;
    i64 rep = n / (a + b);
    i64 res = n % (a + b);
    cout << rep * a + min(res, a) << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll INF = 1e18;
vector<vector<ll>> nxt;
// a->bの最短経路復元
// REP(i, n) REP(j, n) { nxt[i][j] = j; }
// warshall_floyd(to);
// for (ll cur = a; cur != b; cur = nxt[cur][b]) {
//
// }
void warshall_floyd(vector<vector<ll>>& d) {
  ll n = SZ(d);
  REP(i, n) REP(j, n) REP(k, n) if (d[j][k] > d[j][i] + d[i][k]) {
    d[j][k] = d[j][i] + d[i][k];
    nxt[j][k] = nxt[j][i];
  }
}

int main() {
  ll n;
  cin >> n;
  nxt = vector<vector<ll>>(n, vector<ll>(n));
  vector<vector<ll>> to(n, vector<ll>(n));
  REP(i, n) REP(j, n) { cin >> to[i][j]; }

  REP(i, n) REP(j, n) REP(k, n) {
    if (to[i][j] > to[i][k] + to[k][j]) {
      cout << -1 << endl;
      return 0;
    }
  }

  ll ans = 0;
  REP(i, n) REP(j, n) if (i < j) {
    bool need = true;
    REP(k, n) if (k != i && k != j) {
      if (to[i][k] + to[k][j] == to[i][j]) {
        need = false;
      }
    }
    if (need) {
      ans += to[i][j];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N;
  scanf("%d",&N);
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  bool ok = true;
  for (int i=0; i<N; i++){
    if (A[i]%2==0){
      if (A[i]%3!=0 && A[i]%5!=0){
        ok = false;
      }
    }
  }
  printf("%s\n",ok?"APPROVED":"DENIED");
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

int main(int argc, char **argv) {
    i64 a,b,c,k;
    cin >> a >> b >> c >> k;
    i64 ans = 0;
    if (k > a) {
        ans += a;
        k -= a;
    } else {
        ans = k;
        k=0;
    }
    if (k > b) {
        k -= b;
    } else {
        k=0;
    }

    if (k > 0) {
        ans -= k;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
void solve()
{
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll cnt=0;
  if(k<=a)
  {
    cout<<k;
    return;
  }
  else if(k<=a+b)
  {
    cnt=a;
    cout<<cnt;
    return;
  }
  else if(k<=a+b+c)
  {
    cnt=a;
    ll val=k-a-b;
    cnt=cnt-val;
    cout<<cnt;
    return;
  }
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3524
X = int(input())

for i in range(2,10**5):
    if i ** 5 - (i-1)**5 == X:
        print(i,i-1);exit()

for x in range(-200,200):
    for y in range(-200,200):
        if x** 5 - y ** 5 == X:
            print(x,y);exit()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;


int main() {
    ll N, D, A;
    cin >> N >> D >> A;
    ll X[N], H[N];
    pair<ll, ll> c[N];
    rep(i, N) {
        cin >> X[i];
        cin >> H[i];
        c[i] = make_pair(X[i], H[i]);

    }
    sort(c, c+N);

    ll ans = 0;
    ll ref[N];
    rep(i, N){
        ref[i] = 0;
    }
    rep(i, N) {
        int lb = 0, rb = i;
        while(rb - lb > 1) {
            int mid = (lb + rb) / 2;
            if (c[mid].first + 2*D >= c[i].first) {
                rb = mid;
            } else {
                lb = mid;
            }
        }
        if (c[lb].first + 2*D >= c[i].first) rb = lb;
//        cout << rb << " " << lb << endl;
        c[i].second -= (ref[i] - ref[rb]) * A;
        if (c[i].second % A == 0 && c[i].second > 0) {
            ans += c[i].second / A;
            ref[i+1] = ref[i] + (c[i].second / A);
        } else if (c[i].second > 0) {
            ans += c[i].second / A + 1;
            ref[i+1] = ref[i] + (c[i].second / A) + 1;
        } else  {
            ref[i+1] = ref[i];
        }
    }

    cout << ans << endl;




}

Measured memory_bytes: 8064
import sys

input = sys.stdin.readline
n = int(input())
r_list = []
for i in range(1, n+1):
    r = input().split()
    city, point = r[0], int(r[1])
    r_list.append([city, -point, i])
r_list.sort()
for r in r_list:
    print(r[2])


Measured memory_bytes: 3060
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,x,y) for(int i=x;i<y;i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    vector<char>ans(n+m);
    for(int i=0,p=1;i<s.size();i++,p+=2){
        ans[p]=t[i];
    }
    for(int i=0,p=0;i<s.size();i++,p+=2){
        ans[p]=s[i];
    }
    for(char c:ans)cout<<c;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const ll maxn=404;
ll n,a[maxn],memo[maxn][maxn],pref[maxn],suff[maxn];

ll go(ll i,ll j){
    if(i==j) return 0;
    if(memo[i][j]!=-1) return memo[i][j];
    ll ans=1e16;
    for(ll k=i;k<j;k++){
        ans=min(ans,go(i,k)+go(k+1,j)+pref[k]-pref[i-1]+suff[k+1]-suff[j+1]);
    }
    return memo[i][j]=ans;
}

int main(){
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    memset(memo,-1,sizeof(memo));
    pref[1]=a[1];
    suff[n]=a[n];
    suff[n+1]=pref[0]=0;
    for(ll i=2;i<=n;i++) pref[i]=pref[i-1]+a[i];
    for(ll i=n-1;i>0;i--) suff[i]=suff[i+1]+a[i];
    cout<<go(1,n);
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{

    vector<int> vec(3);

    for(auto &x:vec){
        cin>>x;
    }

    sort(vec.begin(),vec.end());

    long long ans=vec[0]*vec[1]/2;


    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 256
import sys
alphabet='abcdefghijklmnopqrstuvwxyz'
dic={}
for i in alphabet:
  dic[i]=0


s=''
for i in sys.stdin.read():
  s+=i
s=s.lower()

for i in s:
  if i in alphabet:
    dic[i]+=1

for i in dic:
  print(f'{i} : {dic[i]}')


Measured memory_bytes: 5576
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
typedef pair<int, int> ii;
void solve();
int main(int argc, char const *argv[]){
 	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  solve();
}
void solve(){
  string s;
  cin>>s;
  if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
    cout<<"Yes"<<Endl;
  }else{
    cout<<"No"<<Endl;
  }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0){
      break;
    }
    vector<vector<int>> E(N);
    for (int i = 0; i < M; i++){
      int u, v;
      cin >> u >> v;
      u--;
      v--;
      E[u].push_back(v);
      E[v].push_back(u);
    }
    vector<int> c(N, -1);
    bool ok = true;
    vector<vector<int>> vc;
    for (int i = 0; i < N; i++){
      if (c[i] == -1){
        c[i] = 0;
        vc.push_back(vector<int>(2, 0));
        vc.back()[0]++;
        queue<int> Q;
        Q.push(i);
        while (!Q.empty()){
          int v = Q.front();
          Q.pop();
          for (int w : E[v]){
            if (c[w] == -1){
              c[w] = 1 - c[v];
              vc.back()[c[w]]++;
              Q.push(w);
            } else if (c[v] == c[w]){
              ok = false;
              break;
            }
          }
        }
      }
    }
    if (!ok){
      cout << 0 << endl;
    } else {
      int cnt = vc.size();
      vector<vector<bool>> dp(cnt + 1, vector<bool>(N + 1, false));
      dp[0][0] = true;
      for (int i = 0; i < cnt; i++){
        for (int j = 0; j < 2; j++){
          for (int k = vc[i][j]; k <= N; k++){
            if (dp[i][k - vc[i][j]]){
              dp[i + 1][k] = true;
            }
          }
        }
      }
      vector<int> ans;
      for (int i = 0; i <= N; i += 2){
        if (dp[cnt][i]){
          ans.push_back(i / 2);
        }
      }
      int K = ans.size();
      cout << K << endl;
      for (int i = 0; i < K; i++){
        cout << ans[i] << endl;
      }
    }
  }
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 200005;
ll seg[maxn]={0};
ll b[maxn]={0};
struct node{
    ll h,x;
    bool operator<(const node &t)const {
        return x<t.x;
    }
};
node a[maxn]={0};
int main()
{
    ll n,d,aa;
    cin >> n >> d >> aa;
    for(int i=0;i<n;i++){
        cin >> a[i].x >> a[i].h;
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
        b[i]=a[i].x;
    ll cnt=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        if(a[i].h-cnt<=0);
        else{
            ll num=a[i].h-cnt;
            ll dd=num/aa*aa;
            ans+=num/aa;
            if(num%aa){
                ans++;
                dd+=aa;
            }
            int index=upper_bound(b,b+n,a[i].x+2*d)-b;
            seg[index-1]-=dd;
            cnt+=dd;
        }
        cnt+=seg[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
<?php
$n = trim(fgets(STDIN));
$a = array_count_values(str_split(trim(fgets(STDIN))));
if($n != 1){
    while($n > 1){
        $b = array_count_values(str_split(trim(fgets(STDIN))));
        foreach($a as $k => $v){
            if(isset($b[$k])){
                $a[$k] = min($v,$b[$k]);
            }else{
                unset($a[$k]);
            }
        }
        unset($b);
        --$n;
    }
}

ksort($a);
foreach($a as $key => $val){
    echo str_repeat($key,$val);
}

Measured memory_bytes: 3828
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

int i,n,m,block=0,ans=0;
int c[500010],b[500010],pos[500010];
int h[1000010]={0};
struct zht{
	int l,r,id;
}a[500010];

bool cmp(zht a,zht b){if (pos[a.l]==pos[b.l]) return a.r<b.r;
	return a.l<b.l;
}

inline int read(){
	char x;	int p=0;
	x=getchar();
	while (x<48||x>57) x=getchar();
	while (x>=48&&x<=57)	p=p*10+x-48,x=getchar();
	return p;
}

inline void update(int x,int add){
	if (add==1)	{
		if (!h[c[x]])	ans++;
		h[c[x]]++;	}
	if (add==0)	{
		if (h[c[x]]==1)	ans--;
		h[c[x]]--;	}
	return;
}

inline void Solve(){
	int i=0,l=1,r=0;
		for(i=1;i<=m;i++){
		for(;r<a[i].r;r++)	update(r+1,1);
		for(;r>a[i].r;r--)	update(r,0);
		for(;l<a[i].l;l++)	update(l,0);
		for(;l>a[i].l;l--)	update(l-1,1);
		if(a[i].l==a[i].r){
			b[a[i].id]=1;
			continue;
		}
		b[a[i].id]=ans;
	}
	return;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	scanf("%d",&n);	scanf("%d",&m);
	for (i=1;i<=n;i++)	c[i]=read();
	for (i=1;i<=m;i++){
		a[i].l=read();	a[i].r=read();	a[i].id=i;
	}
	block=int(sqrt(n));
	for(i=1;i<=n;i++)	pos[i]=(i-1)/block+1;
	sort(a+1,a+1+m,cmp);
	Solve();
	for (i=1;i<=m;i++)	printf("%d\n",b[i]);
	return 0;
}

Measured memory_bytes: 17276
main(a,b,c,n,r){
for(;scanf("%d%d%d%d",&a,&b,&c,&n),a;){
if(a>c)r=a,a=c,c=r;
if(b>c)r=b,b=c,c=r;
for(;n--;puts(r*2>hypot(a,b)?"OK":"NA"))scanf("%d",&r);
}exit(0);}

Measured memory_bytes: 0
N = int(input())
a = list(map(int,input().split()))
b = [-1] * N
nfi = N // 2
for i in range(nfi,N):
    b[i] = a[i]
for j in range(nfi-1,-1,-1):
    bn = b[j::j+1][1:]
    bnsum = sum(bn)
    if a[j] == 1:
        if bnsum%2==1:b[j] = 0
        else:b[j] = 1
    else:
        if bnsum%2==0:b[j] = 0
        else:b[j] = 1        
dl = []
for k in range(N):
    if b[k] == 1:
        dl.append(k+1)
if sum(b) == 0:
    print(0)
else:
    print(sum(b))
    print(*dl)

Measured memory_bytes: 15672
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll number = arr[0];
    for(ll i=1;i<n;i++)
        number = number^arr[i];
    for(int i=0;i<n;i++)
    {
        ll num = number^arr[i];
        cout<<num<<" ";
    }
    return 0;
}

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] tmpArray = br.readLine().split(" ");
			
			int r0 = Integer.parseInt(tmpArray[0]);
			int w = Integer.parseInt(tmpArray[1]);
			int c = Integer.parseInt(tmpArray[2]);
			int r = Integer.parseInt(tmpArray[3]);
			
			if(r0 == 0 && w == 0 && c == 0 && r == 0){
				break;
			}
			
			int newR = 0;
			for(int i = 0; i < Integer.MAX_VALUE ; i++){
				double currentDensity = (double)(r0 + i*r)/w;
//				System.out.println("dens "+currentDensity);
				if(currentDensity >= c){
					newR = i;
					break;
				}
			}
			
			System.out.println(newR);
		}
	}

}

Measured memory_bytes: 24240
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

template <typename T>

void testVector(T& v) {
  REP(i, SZ(v)) {
    cout << i << ":" << v << endl;
  }
}


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */

ll A, B, C, X, Y;
ll ans = 0;

/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

  cin >> A >> B >> C >> X >> Y;
  if (2 * C >= A + B) {
    cout << A * X + B * Y << endl;
    return 0;
  }

  ll min_XY = min(X, Y);
  ans += 2 * min_XY * C;
  X -= min_XY;
  Y -= min_XY;

  if (X > 0) {
    if (C * 2 >= A) {
      ans += A * X;
    } else {
      ans += C * 2 * X;
    }
  } else {
    if (C * 2 >= B) {
      ans += B * Y;
    } else {
      ans += C * 2 * Y;
    }
  }

  cout << ans << endl;
  return 0;
}

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

int compare(const void *a, const void *b) {
    return *(int*)a-*(int*)b;
}

int main(void) {
    int n, i, r=1, t;
    int array[999];
    scanf("%d", &n);
    for (i=0;i<n;i++)scanf("%d", &array[i]);
    qsort(array, n, 4, compare);
    t = array[0];

    for (i=0;i<n;i++) {
        if(t!=array[i]){
            t=array[i];
            r++;        }
    }
    printf("%d\n", r);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	int ans = 0;
	rep(i, n - 1) {
		repl(j, i + 1, n) { ans += a[i] * a[j]; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[100000];
	int cnt[100001] = { 0 };
	for(int i = 0; i < n; i++){
		cin >> a[i];
		cnt[a[i]]++;
	}
	int c = 0;
	
	int last;
	for(int i = 1; i <= 100000; i++){
		if(cnt[i] >= 3){
			if(cnt[i] % 2 == 1){
				cnt[i] = 1;
			} else {
				cnt[i] = 2;
			}
		}
		if(cnt[i] >= 1) last = i;
	}
	bool flag = false;
	for(int i = 1; i <= last; i++){
		if(flag) break;
		if(cnt[i] == 2){
			for(int j = i+1; j <= last; j++){
				if(cnt[j] == 2){
					cnt[i] = 1;
					cnt[j] = 1;
					break;
				}
				if(j == last){
					cnt[i]--;
					cnt[j]--;
					flag = true;
				}
			}
		}
	}
	for(int i = 1; i <= last; i++){
		if(cnt[i] == 1) c++;
	}
	cout << c << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
const int N=1e5+5;
using namespace std;
int a[N];
int main(){
	int n;
	cin >> n;
	while(n--){
		int b;
		cin >> b;
		a[b]++;
		a[b-1]++;
		a[b+1]++;
	}
	int max=0;
	for(int i=0;i<N;i++){
		if (a[i]>max){
			max=a[i];
		}
	}
	cout << max;
}

Measured memory_bytes: 3536
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
  int r;
  cin >> r;
  
  cout << r*r;
  return 0;
}


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



typedef long long ll;
#define MOD 1000000007
int N, M;
//-----------------------------------------------------------------
ll dp[303][303][303];
int main() {
	cin >> N >> M;

	dp[0][1][1] = 1;
	rep(i, 0, M) rep(j, 0, N + 1) rep(k, 0, N + 1) {
		dp[i + 1][j + 1][k] = (dp[i + 1][j + 1][k] + dp[i][j][k] * (ll)(N - j)) % MOD;
		if(0 < j - k) dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k] * (ll)(j - k)) % MOD;
		dp[i + 1][j][j] = (dp[i + 1][j][j] + dp[i][j][k] * (ll)k) % MOD;
	}

	cout << dp[M][N][N] << endl;
}

Measured memory_bytes: 215424
#include <iostream>
#include <string>

int main()
{
  std::string str;
  std::cin >> str;

  int counter = 0;
  for (int x = 0; x < str.size() >> 1; ++x)
  {
    int y = str.size() - x - 1;
    if (str.at(x) != str.at(y)) ++counter;
  }

  std::cout << counter << std::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 ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p=-1) {
  for(int u : to[v]) {
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main() {
  int n,q; cin >> n >> q;

  rep(i,n-1) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    
    to[a].push_back(b);
    to[b].push_back(a);
  }

  ans.resize(n);
  rep(i,q) {
    int p,x;

    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  
  rep(i,n) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 24280
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	string S; cin >> S;
	if (S[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
	S[0] = 'a';

	int flg = 0;
	for (int i = 2; i <= S.size()-2; i++) {
		if (S[i] == 'C') { S[i] = 'c'; flg++; }
		if (flg == 2) {
			cout << "WA" << endl;
			return 0;
		}
	}
	if (flg == 0) {
		cout << "WA" << endl;
		return 0;
	}

	rep(i, S.size()) {
		if (isupper(S[i])) {
			cout << "WA" << endl;
			return 0;
		}
	}

	cout << "AC" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int N, A, B;

int main()
{
  cin >> N >> A >> B;
  int maxi = min(A, B);
  int mini = max(A+B-N, 0);
  cout << maxi << " " << mini << endl;

  return 0;
}


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

int main(){
	int n;
	while(cin>>n,n){
		vector<int> v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		int ans=0;
		while(1){
			map<int,int> ma;
			for(int i=0;i<n;i++){
				ma[v[i]]++;
			}
			vector<int> tmp(n);
			for(int i=0;i<n;i++){
				tmp[i]=ma[v[i]];
			}
			bool f=true;
			for(int i=0;i<n;i++){
				if(tmp[i]!=v[i]){
					f=false;
					ans++;
					break;
				}
			}
			if(f){
				cout<<ans<<endl;
				for(int i=0;i<n;i++){
					if(i) cout<<" ";
					cout<<v[i];
				}
				cout<<endl;
				break;
			}
			v=tmp;
		}
	}
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>A>>B>>K;
    set<ll> ans;
    reps(i,A,min(A + K, B+1)) ans.insert(i);
    for(int i = B; i >= max(A, B - K + 1); --i) ans.insert(i);
    for(ll an : ans) cout<<an<<endl;
}

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

using namespace std;

int main(){
    double a, b, c, d, e, f;
    double x, y;
    while(cin >> a >> b >> c >> d >> e >> f) {
        x = (double)((c*e - b*f)/(a*e - b*d) * 1000) / 1000.0;
        y = (double)((d*c - a*f)/(b*d - a*e) * 1000) / 1000.0;
        x = (x == -0.0) ? 0.000 : x;
        y = (y == -0.0) ? 0.000 : y;
        cout << fixed << setprecision(3);
        cout << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    bool n = false, s = false, w = false, e = false;
    string str;
    cin >> str;
    for (auto c : str) {
        if (c == 'N') {
            n = true;
        } else if (c == 'W') {
            w = true;
        } else if (c == 'E') {
            e = true;
        } else {
            s = true;
        }
    }
    if ((n ^ s) || (w ^ e)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}




Measured memory_bytes: 3560
S = int(input())
mod =1000000007


kjs = [1] * 2001
for i in range(1, 2001):
    kjs[i] = kjs[i-1] * i


def combination(n1, n2):
    return kjs[n1]//(kjs[n2] * kjs[n1-n2])


n = S//3

ans = 0
for i in range(1, n+1):
    x = S - 3*i
    ans += combination(x+i-1, min(x, i-1))
    ans %= mod

print(ans)


Measured memory_bytes: 11500
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n)
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

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

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	int x, a, b;
	cin >> x >> a >> b;

	if (abs(x - a) < abs(x - b)) {
		cout << "A" << rt;
	}
	else {
		cout << "B" << rt;
	}

	please AC;
}

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

int main()
{
    long long int n;
    cin>>n;
    long long int a[n],i;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    cout<<abs(a[n-1]-a[0])<<"\n";
    return 0;
}


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

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3) {
		if (s[i] == t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M = sc.nextInt()
  val loads = List.fill(M)(sc.nextInt() -> sc.nextInt())
  val loadMap = loads.:::(loads.map(_.swap)).groupBy(_._1).view.mapValues(_.length)
  1.to(N).foreach(i => println(loadMap.getOrElse(i, 0)))
}


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

#define MAX 100000
#define MAX_E 100000

int par[MAX], rank_[MAX];

void init(int N){
    for(int i = 0; i < N; i++){
        par[i] = i;
        rank_[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    }
    return par[x] = find(par[x]);
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y) return;

    if(rank_[x] < rank_[y]) par[x] = y;
    else{
        par[y] = x;
        if(rank_[x] == rank_[y]) rank_[x]++;
    }
}

bool same(int x, int y){
    return (find(x) == find(y));
}

struct edge{int u, v, cost;};

bool comp(const edge &e1, const edge &e2){
    return e1.cost < e2.cost;
}

int V, E;
edge es[MAX_E];

int kruskal(){
    sort(es, es+E, comp);
    init(V);
    int res = 0;
    for(int i = 0; i < E; i++){
        edge e = es[i];
        if(!same(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main(){
    int s, t, w;
    cin >> V >> E;
    for(int i = 0; i < E; i++){
        cin >> s >> t >> w;
        es[i] = (edge){s, t, w};
    }
    cout << kruskal() << endl;
}


Measured memory_bytes: 4344
#include<bits/stdc++.h>
using namespace std;
int LCM(int x,int y)
{
    return x*y/(__gcd(x,y));
}
int main ()
{
    int N;cin >> N;
    int A[N+10];
    int lc=0;
    for(int i=1;i<=N;i++){
        cin >> A[i];
        if(!lc)lc=A[i];
        else lc = LCM(lc,A[i]);
    }
    double ans=lc,dv=0.0;
    for(int i=1;i<=N;i++){
        dv+= lc/A[i];
    }
    ans = ans/dv;
    cout<<setprecision(10)<<fixed<<ans<<endl;
    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

#define ull unsigned ll

struct LB {
	ull a[64];
	void clr() { memset(a, 0, sizeof(a)); }
	bool ins(ull x) {
		for (int i = 63; ~i; -- i)
			if (x & 1ull << i) {
				if (not a[i]) {
					a[i] = x;
					return 1;
				} else {
					x ^= a[i];
				}
			}
		return 0;
	}
} lb;

int n;
ull a[205];
char s[205];

void Main() {
	scanf("%d", &n);
	rep(i, n) scanf("%llu", &a[i]);
	scanf("%s", s);
	lb.clr();
	for (int i = n - 1; ~i; -- i) {
		bool ok = lb.ins(a[i]);
		if (s[i] == '1' and ok) { puts("1"); return ; }
	}
	puts("0");
}

int main() {
	int T; scanf("%d", &T);
	while (T --) Main();
	return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef tuple<string, int, int> T;

int main() {

    ll n;
    cin >> n;

    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll ans = 0;

    for(ll c = 1 ; c < n ; c ++) {
        ll sum = 0;
        set<ll> used;
        for(ll x = 0; ; x ++) {
            ll b = x * c;
            ll r = (n - 1 ) - (x * c);

            if(!(b < n && r >= 0) ) break;
            if(r <= 0 || (r - c) <= 0) break;
            used.insert(b);
            if(used.find(r) != used.end()) {
                break;
            }

            sum += a[b];
            sum += a[r];
            ans = max(sum , ans);

            
        }

    }

    cout << ans << endl;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int a[maxn],b[maxn],dp[maxn];//dp[i] 伤害为i时的最小花费;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h,n;
    cin>>h>>n;
    rep(i,1,n){
        cin>>a[i]>>b[i];
    }
    rep(i,1,2e4)dp[i]=(int)1e9+5;
    dp[0]=0;
    rep(i,1,n){
        for(int hp=a[i];hp<=2e4;hp++){
            
            dp[hp]=min(dp[hp],dp[hp-a[i]]+b[i]);
            //debug(hp),debug(dp[hp]);
        }
    }
    int ans=(int)1e9+5;
    rep(i,h,2e4)ans=min(ans,dp[i]);
    cout<<ans<<endl;
}
/* 
9 3
8 3
4 2
2 1
 */

Measured memory_bytes: 4480
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

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

int main(){
    ll A,B,C,K; cin >>A>>B>>C>>K;
    ll ans=0;
    ll num = 0;
    
    if(A>=K){
      ans += K;
      K -= A;
    } else {
      ans += A;
      K -= A;
    }

    if (K>0) K -= B;
    if(K>0) {
      ans = ans + (-1)*K;
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, K; cin >> N >> K;
    vector<double> p(N);
    rep(i, N) {
        double num; cin >> num;
        num = (num + 1) / 2;
        p[i] = num;
    }
    //for (auto elem : p) cout << elem << " "; cout << endl;

    double total = 0;
    rep(i, K - 1) {
        total += p[i];
    }
    //cout << "first total: " << total << endl;

    double max_num = 0;
    reprr(i, K - 1, N) {
        total += p[i];
        //cout << "total: " << total << endl;
        max_num = max(max_num, total);
        total -= p[i - K + 1];
    }
    printf("%.12lf\n", max_num);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  //int a,b,c,d;cin>>a>>b>>c>>d;
  int a[3];cin>>a[0]>>a[1]>>a[2];sort(a,a+3);
  if(a[2]==a[1]+a[0]){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

bool check(vector<ll> a, ll key, ll mask) {
	for (int i = 0; i < 9; i++)
		a[i] ^= key;
	ll sum = 0;
	for (int i = 0; i < 8; i++)
		sum += a[i];
	return (sum & mask) == (a[8] & mask);
}

int main() {
	int S; cin >> S;
	while (S--) {
		vector<ll> a(9);
		for (int i = 0; i < 9; i++)
			scanf("%x", &a[i]);
		ll key = 0, x = 1;
		for (int j = 0; j < 32; j++) {
			if (!check(a, key, (x << 1) - 1))
				key |= x;
			x <<= 1;
		}
		printf("%x\n", key);
	}
}

Measured memory_bytes: 1248
n=int(input())
s=0
p=1
for i in range(n):
  m=i+1
  if not(p)%3==0 and not (p)%5==0:
    s=s+m
  i=i+1
  p=p+1
  if p%15==0:
    p=0
print(s)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define F first 
#define S second
#define int long long int
signed main() 
{ 
    fast;
    int a,b;
    cin>>a>>b;
    int ans = (a*b)/(__gcd(a,b));
    cout<<ans;

} 

Measured memory_bytes: 256