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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int pow10(int n){
    int ret = 1;
    REP(i, n) ret *= 10;
    return ret;
}

signed main(){
    int N, M, s[100], c[100];
    cin >> N >> M;
    REP(i, M) cin >> s[i] >> c[i];
    int beg = pow10(N - 1);
    if(N == 1) beg = 0;
    for(int i = beg; i < pow10(N); i++){
        bool f = true;
        REP(j, M){
            if((i / pow10(N - s[j])) % 10 != c[j]){
                f = false;
            }
        }
        if(f){
            PRINT(i);
            return 0;
        }
    }
    PRINT("-1");
    return 0;
}


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

int main() {
    int n,temp;
    cin>>n;
    ll ans=0,cnt;
    rep(i,n) {
        cnt=0;
        cin>>temp;
        while(temp%2==0) {
            temp/=2;
            cnt++;
        }
        ans+=cnt;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

vector<int> primes(int n) {
    vector<bool> dps(n+1, true);
    vector<int> rets;
    for (int i = 2; i <= n; ++i) {
        if (!dps[i]) continue; 
        int j = 2*i; 
        while (j <= n) {
            dps[j] = false;
            j += i;
        } 
    }
    for (int j = 3; j <= n; j+=2) {
        if (dps[j] && dps[(j+1)/2]) rets.push_back(j);
    }
    return rets;
}

int main() {
    int mx = (1e5)-1;
    auto v = primes(mx);
    int q;
    cin >> q;
    vector<int> ls(q), rs(q);
    rep(i, q) cin >> ls[i] >> rs[i];
    rep(i, q){ 
        int ans = upper_bound(all(v), rs[i]) - lower_bound(all(v), ls[i]);
        cout << ans << endl;
    } 
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

int main(){
  int n, l;
  cin >> n >> l;
  vector<int> fla(n);

  int sum, m=101010;
  for(int i=0; i<n; i++){
    fla[i]=l+i;
    sum+=fla[i];
    m=min(m, abs(fla[i]));
  }

  if(sum<=0) cout << sum+m << endl;
  else cout << sum-m << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 int main(void)
{
 int x, y, k;
 while(1){ scanf("%d %d\n", &x, &y);
 if(x==0 && y==0)
{
 break;
 }
 if(x>y)
{
 k = x;
 x = y;
 y = k;
 }
 printf("%d %d\n", x, y);
 }
 return 0;
 } 


Measured memory_bytes: 2040
# -*- coding: utf-8 -*-
for c in range(3000):
    l = input().strip().split()
    x = int(l[0])
    y = int(l[1])
    if((x < 1) and (y < 1)):
        break
    elif(x > y):
        print("{0} {1}".format(y,x))
    else:
        print("{0} {1}".format(x,y))

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

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

    int n,k;
    cin >> n >> k;
    vector<int> a_cnt(n);
    rep(i, n) {
        int a;
        cin >> a;
        --a;
        ++a_cnt[a];
    }

    sort(a_cnt.begin(), a_cnt.end());
    int ans = 0;
    rep(i, n-k) ans += a_cnt[i];

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

Measured memory_bytes: 3924
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

int64_t S,c;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> S >> c; c = c / 2;

	if (S >= c) {
		out << c << std::endl;
	}
	else {
		out << (c + S) / 2 << std::endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 888
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    string s; cin >> s;

    bool is_bad = s[0] == s[1] || s[1] == s[2] || s[2] == s[3];
    cout << (is_bad ? "Bad" : "Good");
    
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ball = [1] * n  # 各箱のボールの個数。初めは各箱に１つずつ。
red = set([0])  # 赤いボールがある可能性のある箱のインデックス。初めは0番目の箱に赤いボールがある。
for _ in range(m):
  x, y = map(int, input().split())
  ball[x-1] -= 1  # x-1番目の箱のボールを1つ減らす
  ball[y-1] += 1  # y-1番目の箱のボールを1つ増やす
  if x-1 in red:  # x-1番目の箱に赤いボールがあるなら、y-1番目の箱に移動したとする。
  	red.add(y-1)
  if ball[x-1] == 0:  # x-1番目の箱にボールがなくなったら、赤いボールもないはずなので
    red.discard(x-1)  # 可能性のある箱から削除しとく
print(len(red))  # 可能性のある箱の個数を出力

Measured memory_bytes: 12652
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

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

    vector<int> X(M);
    for (int i = 0; i < M; i++) {
        cin >> X[i];
    }

    if (N >= M) {
        cout << "0" << endl;
        return 0;
    }

    sort(X.begin(), X.end());
    
    vector<int> abs(M - 1);
    for (int i = 0; i < M - 1; i++) {
        abs[i] = X[i + 1] - X[i];
    }
    sort(abs.begin(), abs.end());

    int ans = 0;
    for (int i = 0; i < M - N; i++) {
        ans += abs[i];
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int d[110] = {};
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    int sum{};
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            sum += d[i] * d[j];
        }
    }
    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int n, x; cin >> n >> x;
    int cnt = 1;
    int dis = 0;
    rep(i, n){
        int l; cin >> l;
        dis += l;
        if(dis <= x) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os
    import re
    with open(__file__) as f:
        source = f.read().split('###''nbacl')
    for s in source[1:]:
        s = re.sub("'''.*", '', s)
        sp = s.split(maxsplit=1)
        if os.path.dirname(sp[0]):
            os.makedirs(os.path.dirname(sp[0]), exist_ok=True)
        with open(sp[0], 'w') as f:
            f.write(sp[1])
    from nbmodule import cc
    cc.compile()
import numpy as np
from numpy import int64
from nbmodule import solve


f = open(0)
N, K = [int(x) for x in f.readline().split()]
A = np.fromstring(f.read(), dtype=int64, sep=' ')
ans = solve(N, K, A)
print(ans)

'''
###nbacl nbmodule.py
import numpy as np
from numpy import int64
from numba import njit
from numba.types import i8
from numba.pycc import CC
import nbacl.segtree as seg
cc = CC('my_module')


@cc.export('solve', (i8, i8, i8[:]))
@njit
def solve(N, K, A):
    dp = np.zeros(300_001, dtype=int64)
    d = seg.segtree(dp, max, 0)
    for i in range(N):
        x = seg.prod(d, max, (A[i] - K) if A[i] > K else 0, (A[i] + K + 1) if A[i] + K < 300_000 else 300_001) + 1
        seg.set(d, max, A[i], x)
    return seg.all_prod(d)


if __name__ == '__main__':
    cc.compile()
###nbacl nbacl/segtree.py
import numpy as np
from numba import njit
from numba.types import i8


@njit
def ceil_pow2(n):
    x = 0
    while (1 << x) < n:
        x += 1
    return x


@njit
def segtree(a, op, e):
    log = ceil_pow2(a.shape[0])
    size = 1 << log
    d = np.empty(size * 2, dtype=a.dtype)
    d[size:size + len(a)] = a
    d[size + len(a):] = e
    # e
    d[0] = e
    for i in range(size - 1, 0, -1):
        update(d, i, op)
    return d


@njit
def update(d, k, op):
    d[k] = op(d[2 * k], d[2 * k + 1])


@njit
def set(d, op, p, x):
    p += d.shape[0] // 2
    d[p] = x
    while p > 1:
        p >>= 1
        update(d, p, op)


@njit
def get(d, p):
    return d[p + d.shape[0] // 2]


@njit
def prod(d, op, left, right):
    size = d.shape[0] // 2
    sml = d[0]
    smr = d[0]
    left += size
    right += size

    while left < right:
        if left & 1:
            sml = op(sml, d[left])
            left += 1
        if right & 1:
            right -= 1
            smr = op(d[right], smr)
        left >>= 1
        right >>= 1

    return op(sml, smr)


@njit
def all_prod(d):
    return d[1]

'''


Measured memory_bytes: 131040
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int maxn=5e5+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

char s[maxn];
int main(){
	ll n;
	scanf("%lld",&n);
	ll ans=0;
	ans+=n/500*1000;
	n%=500;
	ans+=n/5*5;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, m, c[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
array<int, 10> dp[10007];

int main() {
	cin >> n >> m;
	vector<int> a(m);
	inc(i, m) { cin >> a[i]; }
	sort(RALL(a));
	
	dp[0][0] = 1;
	inc(i, n) {
		if(dp[i][0] == 0) { continue; }
		dp[i][0]++;
		inc(j, m) {
			dp[i][10 - a[j]]++;
			setmax(dp[i + c[a[j]]], dp[i]);
			dp[i][10 - a[j]]--;
		}
	}
	assert(dp[n][0] != 0);
	
	dec1(j, 9) {
		inc(k, dp[n][10 - j]) { cout << j; }
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int k, x; cin >> k >> x;
    for(int i = x - k + 1; i < x + k; ++i){
        cout << i << " ";
    }
    cout << endl;

return 0;
}

Measured memory_bytes: 3644
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int HP = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const ll N = 2e5 + 20;
ll a[N], n, sum, res = LINF, ans[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		a[i] = a[i] - i - 1;
	}
	sort(a, a + n);
	for (int i = max(0LL, n / 2 - 5); i <= min(n - 1, n / 2 + 5); i++) {
		for (int j = 0; j < n; j++)
			ans[i] += abs(a[j] - a[i]);
		res = min(res, ans[i]);
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,x,t;cin>>n>>x>>t;
    int qt=(n+x-1)/x;
    cout<<qt*t<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

int main() {
  int buf[2], index = 0;
  while (cin >> buf[index++ % 2]) {
    if (index % 2 != 0) continue;
    int n = buf[0], x = buf[1];
    if (n + x == 0) return 0;

    int count = 0;
    for (int i = 1; i <= n; i++) {
      if (i + 2 == x) break;
      for (int j = 2; j <= n; j++) {
        for (int k = 3; k <= n; k++) {
          if (i >= j || j >= k) continue;
          if (i + j + k == x) {
            count++;
            break;
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}



Measured memory_bytes: 3116
def resolve():
    N, A, B = list(map(int, input().split()))
    base = (N // (A+B)) * A
    rem = N - (N//(A+B))*(A+B)
    ans = base
    ans += A if rem >= A else rem
    print(ans)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 61800
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0; }
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path; vl A, T; ll key = 0;
//***********//
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
int main() {
	cin >> N >> M;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		A[i] /= 2;
	}
	sort(A.begin(), A.end());
	if (N == 1) {
		key = A[0];
	}
	else {
		//非オーバーフロー検査
		ll test1 = A[1] / gcd(A[0], A[1]);
		ll test2 = (M * 10000) / test1;
		if (test2 < A[1]) { cout << 0; exit(0); }
		ll pre = (A[0] * A[1]) / gcd(A[0], A[1]);
		key = pre;
		for (i = 2; i < N; i++) {
			test1 = pre / gcd(pre, A[i]);
			test2 = (M * 10000) / test1;
			if (test2 < A[i]) { cout << 0; exit(0); }
			key = (pre * A[i]) / gcd(pre, A[i]);
			pre = key;
		}
	}
	for (i = 0; i < N; i++) {
		if ((key / A[i])% 2 ==0) {
			cout << 0;
			exit(0);
		}
	}
	if (M < key) {
		cout << 0;
	}
	else {
		cout << (M / key - 1) / 2 + 1;
	}
}

Measured memory_bytes: 1024
import sys
readline = sys.stdin.buffer.readline
MOD = 10**9+7
INF = float('inf')

def main():
    N = int(readline())
    T = list(map(int, readline().split()))
    M = int(readline())
    total = sum(T)
    for _ in range(M):
        P, X = map(int, readline().split())
        diff = T[P-1] - X
        print(total - diff)




if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
// 解説参照済み
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int zeroNum = 0, oneNum = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '0')
        {
            zeroNum++;
        }
        else
        {
            oneNum++;
        }
    }
    cout << 2 * min(zeroNum, oneNum) << endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        long [] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextLong();
        long [][] odd = new long[n][2];
        long [] even = new long[n];
        for (long [] arr: odd) Arrays.fill(arr, Long.MIN_VALUE / 2);
        Arrays.fill(even, Long.MIN_VALUE / 2);
        odd[0][0] = 0; odd[0][1] = a[0];
        even[1] = Math.max(a[0], a[1]);
        if (n == 2) {
            out.println(even[1]);
        } else {
            odd[2][0] = Math.max(Math.max(a[0], a[1]), a[2]);
            odd[2][1] = a[0] + a[2];
            for (int i = 3; i < n; i++) {
                if (i % 2 == 1) {
                    even[i] = Math.max(even[i - 2] + a[i], odd[i - 3][1] + a[i - 1]);
                } else {
                    odd[i][1] = a[i] + odd[i - 2][1];
                    odd[i][0] = Math.max(a[i] + odd[i - 2][0], even[i - 3] + a[i - 1]);
                }
            }
            out.println(((n - 1) % 2 == 1) ? even[n - 1] : odd[n - 1][0]);
        }
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 56844
#include<iostream>
using namespace std;
int main() {
	int N;
	int A[210];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	int ans = 0;
	for (int j = 0; j < 1000000000; ++j) {
		for (int i = 0; i < N; ++i) {
			if (A[i] % 2 != 0) {
				cout << ans;
				return 0;
			}
			A[i] /= 2;
		}
		ans++;
	}
	return 0;
}

Measured memory_bytes: 256
/*
 * insertionSort.cpp
 *
 *  Created on: 2016/04/12
 *      Author: dkawa
 */

#include <iostream>
#define MAX 100

using namespace std;


int main(void){
	int a[MAX];
	int n;
	int i,j,k;
	int t;

	cin>>n;

	for(i=0;i<n;i++){
		cin>>a[i];
	}

	for(k=0;k<n;k++){
			cout<<a[k];
			if(k!=n-1)cout<<" ";
		}
	cout<<endl;

	for(i=1;i<n;i++){
		t=a[i];
		j=i-1;
		while(j>=0 && a[j]>t){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=t;

		for(k=0;k<n;k++){
				cout<<a[k];
				if(k!=n-1)cout<<" ";
			}
		cout<<endl;



	}

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int min(int a, int b)
{

if(a<b)

return a;

else if(b<a)

return b;

}
int main()
{
    int i,a,b,c,p,q;

        scanf("%d%d%d",&a,&b,&c);

    p=b*a;
    q=min(p,c);
    printf("%d",q);




    return 0;
}


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

#define MAX 110

using namespace std;

int n;
int ans;

int v[MAX];

int main()
{
	scanf("%d",&n);

	for(int i = 1 ; i <= n - 1 ; i++)
		scanf("%d",&v[i]);

	ans += v[ 1 ];
	ans += v[ n - 1 ];

	for(int i = 1 ; i <= n - 2 ; i++)
		ans += min(v[ i ] , v[ i + 1 ]);

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

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int ans[200010] = { 0 };
vector<VI> G(200010);
map<int, int>mp;
int N, Q;


void  dfs(int s,int cnt) {
	//cout << s <<" "<<cnt<< endl;
	cnt += mp[s];
	//cout <<mp[s] << endl;
	//cout << endl;
	ans[s] = cnt;
	REP(i, G[s].size()) {
		dfs(G[s][i], cnt);
	}
	return;
}

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

	cin >> N >> Q;



	REP(i, N-1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
	}
	REP(i, Q) {
		int a, b;
		cin >> a >> b;
		a--;
		//cout << a << " " << b << endl;
		mp[a] += b;
	}

	dfs(0,0);

	REP(i, N) {
		cout << ans[i];
		if (i != N - 1)cout << " ";
		else cout << endl;
	}
	return 0;
}



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

int main() {
    ll n,t;
    std::cin >> n>>t;
    vector<pair<ll,ll>> ab(n);
    for (int i = 0; i < n; i++) {
        std::cin >> ab[i].first >> ab[i].second;
    }
    sort(ab.begin(),ab.end());
    vector<vector<ll>> dp(n+1,vector<ll>(t,0));
    vector<ll> ma(n,0);

    ma[n-1] = ab[n-1].second;
    for (int i = 1; i < n; i++) {
        ma[n-1-i] = max(ab[n-1-i].second, ma[n-1-i+1]);
    }
    ll ans = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = 0; j < t; j++) {
            dp[i+1][j] = dp[i][j];
            if(j-ab[i].first>=0) dp[i+1][j] = max(dp[i+1][j],dp[i][j-ab[i].first]+ab[i].second);
        }
        ans = max(ans, dp[i+1][t-1]+ma[i+1]);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 74112
#include<stdio.h>
#include<string.h>


#define M 1046527
#define Nil (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if (ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}


long long getKey(char str[]){
  long long sum, p=1, i;
  for(i = 0; i < strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }

  return sum;
}


int h1(int key){
  return key % M;
}
int h2(int key){
  return 1 + (key % (M - 1));
}


int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i = 0; ;i++){
    h = (h1(key) + i * h2(key)) % M;
    /* already inserted */
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
  }

  return 0;
}

int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i = 0;  ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int main(){

  int n, i = 0;
  scanf("%d", &n);

  char cmd[8], target[L];
  for(i = 0; i< n; i++){
    scanf("%s %s", cmd, target);
    if(cmd[0] == 'i'){
      insert(target);
    } else {
      if(find(target)){
        printf("yes\n");
      } else{
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 15976
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	char a , b;
	cin >> a >> b;
	if(a == 'H')cout << b << endl;
	else {
		if(b == 'H')cout << "D" << endl;
		else cout << "H" << endl;
		}
	return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define PI 3.14159265359
 
int main(){
  ll X, A, B, i, j;
  
  cin >> X;
  
  for (ll A = -150; A <= 150; A++){
    for(ll B = -150; B <= 150; B++){
      if(pow(A, 5) - pow(B, 5) == X){
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 4032
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF 1<<30

// dist_from_s[u] + dist_from_t[v] = dist_from_s[t] - 2
int main() {
	cin.tie(0); ios::sync_with_stdio(false);

	/* input */
	int N, M; cin >> N >> M;
	int s, t; cin >> s >> t; s--; t--;
	vector<vector<ll>> G(N);
	for (int i = 0; i < M;i++) {
		int x, y; cin >> x >> y; x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	/* initialize */
	vector<ll> d_s(N, INF), d_t(N, INF);
	queue<ll> q_s, q_t;
	
	// d_s(t)[n] := distance n from s(t)
	d_s[s] = 0, d_t[t] = 0;
	q_s.push(s), q_t.push(t);

	/* Dijkstra */
	while (!q_s.empty()) {
		int u = q_s.front(); q_s.pop();
		for (int v : G[u]) {
			if (d_s[v] > d_s[u] + 1) {
				d_s[v] = d_s[u] + 1;
				q_s.push(v);
			}
		}
	}

	while (!q_t.empty()) {
		int u = q_t.front(); q_t.pop();
		for (int v : G[u]) {
			if (d_t[v] > d_t[u] + 1) {
				d_t[v] = d_t[u] + 1;
				q_t.push(v);
			}
		}
	}

	/* solve */
	ll ans = 0;

	// dist_is(t)[i] := sum of distance i from s(t)
	vector<ll> dist_is(N + 1, 0);
	vector<ll> dist_it(N + 1, 0);
	for (int i = 0; i < N;i++) {
		if (d_s[i] != INF) {
			dist_is[d_s[i]]++;
		}
		if (d_t[i] != INF) {
			dist_it[d_t[i]]++;
		}
	}

	ll Const = d_s[t] - 2;
	for (int i = 0; i <= Const;i++) {
		ans += (dist_is[i] * dist_it[Const - i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 13656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

ll t(ll X) {
  if(X == 1)
    return 1;
  return 1 + 2 * t(X / 2);
}

int main() {
  ll H;
  cin >> H;
  cout << t(H) << endl;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<algorithm>
using namespace std;

#define INF 0x3f3f3f3f

struct node{
    int x;
    int l,r;
    bool operator<(node tmp){
        return r<tmp.r;
    }
};

int main(void)
{
    int n; scanf("%d",&n);
    node *a = new node[n];
    for(int i=0;i<n;++i) {
        int l;
        scanf("%d%d",&a[i].x,&l);
        a[i].l = a[i].x-l; a[i].r = a[i].x+l;
    }
    sort(a,a+n);
    int s = 0, r = -INF;
    for(int i=0;i<n;++i){
        if(a[i].l>=r){
            ++s;
            r = a[i].r;
        }
    }
    printf("%d\n",s);
    return 0;
}

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

int main(){
   int x , y , ans;
   cin >> x >> y;
   ans = max(x , y);
   int l = max(x , y);
   int k = min(x , y);
   l--;
   ans+=(max(l , k));
   cout << ans << endl;
   
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int q;
  cin >> q;
  ll c = 0;
  multiset<int> left, right;
  ll dist = 0;
  rep(i, q) {
    int type;
    cin >> type;
    if (type == 1) {
      int x, b;
      cin >> x >> b;
      c += b;
      if (left.size() > 0 && right.size() > 0) {
        if (left.size() == right.size()) { // 偶数
          int lmax = *(--left.end());
          int rmin = *(right.begin());
          if (x < lmax) {
            dist += (lmax - x);
          } else if (rmin < x) {
            dist += (x - rmin);
          }
        }
      }
      if (left.size() > 0) {
        if (left.size() != right.size()) { // 偶数
          int lmax = *(--left.end());
          if (x < lmax) {
            dist += (lmax - x);
          } else if (lmax < x) {
            dist += (x - lmax);
          }
        }
      }
      if (left.size() <= right.size()) {
        left.insert(x);
      } else {
        right.insert(x);
      }
      if (left.size() > 0 && right.size() > 0) {
        int lmax = *(--left.end());
        int rmin = *(right.begin());
        if (lmax > rmin) {
          left.erase(--left.end());
          right.erase(right.begin());
          left.insert(rmin);
          right.insert(lmax);
        }
      }
      dump(dist, left, right);
    } else {
      int lmax = *(--left.end());
      cout << lmax << " " << dist + c << endl;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 9600
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
s=0
for i in range(n+1):
    if i%5!=0 and i%3!=0:
        s+=i
print(s)

Measured memory_bytes: 9100
N, K = map(int, input().split())
L = K.bit_length()
D = [0]*(L+1)
A = list(map(int, input().split()))
res=0
for a in A:
    for i in range(L+1):
        D[i] += (a>>i)&1
for i in reversed(range(L+1)):
    if D[i]*2<=N and res+(1<<i)<=K:
        res+=(1<<i)
print(sum(a^res for a in A))


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

int main(){
    int cnt, n;
    
    while(cin >> n){
        cnt = 0;
        
        for(int i = 0;i <= 9;i++){
            for(int j = 0;j <= 9;j++){
                for(int k = 0;k <= 9;k++){
                    for(int l = 0;l <= 9;l++){
                        if(i + j + k + l > n){
                            break;
                        }
                        if(i + j + k + l == n){
                            cnt++;
                        }
                    }
                }
            }
        }
        
        cout << cnt << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2980
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 100010
ll x[N], w[N], y[N], r[N];
int main(){
	ll n, l, t;
	cin>>n>>l>>t;
	rep(i, n){
		cin>>x[i]>>w[i];
		w[i] = w[i]==1?1:-1;
		y[i] = (x[i]+w[i]*t)%l;
		if(y[i]<0) y[i] += l;
	}
	ll sw = 0, w0 = w[0];
	if(w[0]<0){
		rep(i, n) w[i] *= -1;
		rep(i, n) x[i] *= -1;
	}
	bool just = false;
	rep(i, n){
		if(w[i]>0) continue;
		ll a = x[0]-x[i], b = x[0]-x[i]+2*t;
		cerr<<i<<" "<<a<<" "<<b<<endl;
		if(a<0) sw++;
		sw += b/l;
		if(b%l==0) just = true;
	}
	ll left = 0;
	if(w0<0){
		rep(i, n) w[i] *= -1;
		rep(i, n) x[i] *= -1;
		sw *= -1;
		sw %= n;
		if(sw<0) sw += n;
		left = !left;
	}
	sort(y, y+n);
	int p = -1;
	for(int i = 0; i < n; i++){
		if((x[0]+t*w[0]-y[i])%l==0){
			p = i;
			if(just && !left) p++;
			break;
		}
	}
	//cerr<<just<<" "<<left<<endl;
	//cerr<<sw<<" "<<p<<endl;
	rep(i, n) r[(i+sw)%n] = y[(p+i)%n];
	rep(i, n) cout<<r[i]<<endl;
	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int a[3];
int cnt[10];
signed main() {
	rep(i,3){
		cin>>a[i];
		cnt[a[i]]++;
	}
	rep(i,3){
		if(cnt[a[i]]==2){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll D;
    cin >> D;
    vl c(26);
    rep(i, 26){
        cin >> c[i];
    }
    vll s(D, vl(26));
    rep(i, D){
        rep(j, 26){
            cin >> s[i][j];
        }
    }

    ll v = 0;
    vl last(26, -1);
    vl t(D);
    rep(d, D){
        cin >> t[d]; t[d]--;
    }

    ll M;
    cin >> M;
    rep(i, M){
        ll d, q;
        cin >> d >> q;
        d--; q--;
        t[d] = q;
        last.assign(26, -1);
        v = 0;
        rep(d, D){
            v += s[d][t[d]];
            last[t[d]] = d;
            rep(i, 26){
                v -= c[i] * (d - last[i]);
            }
        }
        
        cout << v << endl;
    }
}


Measured memory_bytes: 3748
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;  
int f(int a[],int b[],int j,int k,int l,int mn){
  int sm;
  while(k!=0&&l!=j){
    if(a[k]==a[l]&&b[k]+b[l]>3){
      k--;
      l++;
    }else
      break;
  }
  sm=0;
  for(;k>0;k--)
    sm+=b[k];
  for(;l<j;l++)
    sm+=b[l];
  if(mn==-1||mn>sm)
    mn=sm;
  return mn;
}
int main(){
  int i,j,k,l;
  int a[10002],b[10002],n;
  int mn;
  a[0]=b[0]=0;
  while(cin>>n&&n){
    j=1;
    for(i=0;i<n;i++){
      cin>>a[j];
      if(a[j-1]==a[j])
	b[j-1]++;
      else{
	b[j]=1;
	j++;
      }
    }
    a[j]=b[j]=0;
    mn=-1;
    for(i=2;i<j;i++){
      if(i+1<j&&b[i]==1&&a[i-1]==a[i+1]&&b[i-1]+b[i]+b[i+1]==4)
	mn=f(a,b,j,i-2,i+2,mn);
      if(b[i-1]>2){
	if(b[i]!=1)
	  l=i;
	else{
	  if(a[i-1]==a[i+1])
	    l=i+2;
	  else
	    l=i+1;
	}
	mn=f(a,b,j,i-2,l,mn);
      }
      if(b[i]>2){
	if(b[i-1]!=1)
	  k=i-1;
	else{
	  if(a[i-2]==a[i])
	    k=i-3;
	  else
	    k=i-2;
	}
	mn=f(a,b,j,k,i+1,mn);
      }	
    }
    if(mn==-1)
      cout<<n<<endl;
    else
      cout<<mn<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
 
int o[101];
char cm[100];
int top = 0;
 
void push(int x) {
  top++;
  o[top] = x; 
  
}
 
 
int pop() {
  top--;
  return o[top+1];
   
}
 
   
   
 
   
int main() {
  int a,b = 0;
  int result;
  int c;
  int d,e;
   
  while(scanf("%s",cm) != EOF) {
     
    if(cm[0] == '+'){
      push(pop() + pop());
    }
    else if(cm[0] == '-'){
      d = pop();
      e = pop();
      push(e - d);
    } else if(cm[0] == '*') {
      push(pop() * pop());
    }   else {
      push(atoi(cm));
    }
     
  }
 
  printf("%d\n",pop());
 
  return 0;
}
   

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

int n;
std::string dep, arr;

int main() {
    while (true) {
        std::cin >> n;
        if (n == 0) {
            return 0;
        }
        std::vector<int> vec(86401, 0);
        for (int i = 0; i < n; i++) {
            std::cin >> dep >> arr;
            int dep_time = std::stoi(dep.substr(0, 2))*3600+std::stoi(dep.substr(3, 2))*60+std::stoi(dep.substr(6,2));
            int arr_time = std::stoi(arr.substr(0, 2))*3600+std::stoi(arr.substr(3, 2))*60+std::stoi(arr.substr(6,2));
            vec[dep_time]++;
            vec[arr_time]--;
        }
        for (int i = 1; i < 86400; i++) {
            vec[i] += vec[i-1];
        }
        std::cout << *std::max_element(vec.begin(), vec.end()) << std::endl;
    }
}



Measured memory_bytes: 3512
n, m = map(int, input().split())
h = list(map(int, input().split()))
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

ans = 0

for i in range(n):
    ma = 0
    for j in graph[i]:
        ma = max(ma, h[j])
    if h[i] > ma:
        ans += 1

print(ans)

Measured memory_bytes: 29480
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a, b;
  int ans=0;
  cin >> a >> b;
  for(int i=0;i<a.size();i++){
    if(a[i]!=b[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n,x=1,ans=0;
	cin >> n;
	vec(a,n);
	vec(s,n+1);
	cin >> a[0];
	s[0]= a[0];
	FOR(i,1,n){
		cin >> a[i];
		s[i] = s[i-1] + a[i];
	}
	s[n]=1e18+7;
	sort(s.begin(),s.end());
	REP(j,n){
        if(s[j]== 0){
            ans++;
        }
    }
	REP(i,n){
		if(s[i] == s[i+1]){
			x += 1;
		}
		else{
			ans = ans + x * (x-1) / 2;
			x = 1;
		}
	}
	cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
//https://qiita.com/drken/items/ae02240cd1f8edfc86fd
// 負の数にも対応した mod
// 例えば -17 を 5 で割った余りは本当は 3 (-17 ≡ 3 (mod. 5))
// しかし単に -17 % 5 では -2 になってしまう
inline long long mod(long long a, long long m) {
	return (a % m + m) % m;
}

// 拡張 Euclid の互除法
// ap + bq = gcd(a, b) となる (p, q) を求め、d = gcd(a, b) をリターンします
long long extGcd(long long a, long long b, long long &p, long long &q) {
	if (b == 0) { p = 1; q = 0; return a; }
	long long d = extGcd(b, a%b, q, p);
	q -= a / b * p;
	return d;
}

// 中国剰余定理
// リターン値を (r, m) とすると解は x ≡ r (mod. m)
// 解なしの場合は (0, -1) をリターン
pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2, long long m2) {
	long long p, q;
	long long d = extGcd(m1, m2, p, q); // p is inv of m1/d (mod. m2/d)
	if ((b2 - b1) % d != 0) return make_pair(0, -1);
	long long m = m1 * (m2 / d); // lcm of (m1, m2)
	long long tmp = (b2 - b1) / d * p % (m2 / d);
	long long r = mod(b1 + m1 * tmp, m);
	return make_pair(r, m);
}

//約数列挙
vector<long long> calc(long long N) {
	vector<long long> x;
	for (long long i = 1; i <= sqrt(N); i++) {
		if (0 == N % i) {
			x.push_back(i);
			if (N != i * i) {
				x.push_back(N / i);
			}
		}
	}
	sort(x.begin(), x.end());
	return x;
}

int main() {
	long long N;
	cin >> N;
	N *= 2;
	vector<long long>v = calc(N);
	long long ans = 1e18;
	for (int i = 0; i < v.size(); ++i) {
		pair<long long, long long> res = ChineseRem(0, v[i], -1, N / v[i]);
		if (-1 != res.second) {
			if (0 != res.first) {
				ans = min(ans, res.first);
			}
			else {
				ans = min(ans, res.second);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3820
N=int(input())
for i in range(N):
    x1,y1,r1,x2,y2,r2=map(float,input().split())
    d=((x1-x2)**2+(y1-y2)**2)**0.5
    if r1-r2>d:
        if r1==r2+d:
            print("1")
        else:
            print("2")
    elif r2-r1>d:
        if r2==r1+d:
            print("1")
        else:
            print("-2")
    elif d<r1+r2:
        print("1")
    elif r1+r2==d:
        print("1")
    elif d>r1+r2:
        print("0")



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

using ll=long long;
#define int ll

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

int countChar(char c,string s){
	if(s.find_first_of(c)==string::npos) return 0;
	return s.find_last_of(c)-s.find_first_of(c)+1;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	// your code goes here
	int n=read();
	string s[n];
	REP(i,n){
		cin >> s[i];
		sort(s[i].begin(),s[i].end());
	}
	int count;
	int count0;
	string ans;
	REP(j,s[0].length()){
		count0 = countChar(s[0][j],s[0]);
		count = count0;
		FOR(i,1,n){
			count = min(count,countChar(s[0][j],s[i]));
		}
		REP(k,count) ans.push_back(s[0][j]);
		j += count0-1;
	}
	cout << ans;
}

Measured memory_bytes: 256