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

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

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

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

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class T> ostream &operator<<(ostream& os, set<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.FI << "," << P.SE << ")";
}

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

const int POM = 1e5 + 5;
int n;
int ilep[POM * 2];
int ilek[POM * 2];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  ilep[POM]++;
  ilek[POM]++;
  R(i,n){
    int a,b;
    cin >> a >> b;
    ilep[POM + a]++;
    ilek[POM + b]++;
  }
  int po = n+1;
  int ko = 0;
  int res = 0;
  R(i,POM*2){
    res += 2 * min(po,ko);
    po -= ilep[i];
    ko += ilek[i];
  }
  cout << res << "\n";
}




Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
//#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    os << '[';
    for (auto p : v) os << p << ",";
    os << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    os << "{";
    for (auto p : v) os << p << ",";
    os << "}";
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const multiset<T, V> &v) {
    os << "{";
    for (auto p : v) os << p << ",";
    os << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    os << "{";
    for (auto p : v) os << p << ",";
    os << "}";
    return os;
}
 
ostream& operator<<(ostream &os, tuple<int, int, int> t) {
    os << "<" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ">";
    return os;
}
 
#ifdef ONLINE_JUDGE
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
auto x = []{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    return 0;
}();

template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int main(void) { 
    int N, K; cin >> N >> K;
    vector<int> v(N);
    rep(i, N) cin >> v[i];

    sort(all(v), greater<int>());
    v.erase(v.begin(), v.begin()+min((int)v.size(), K));

    cout << accumulate(all(v), 0ll) << endl;
}




Measured memory_bytes: 1024
n = int(input())
H = list(map(int, input().split()))

#%%
def change_min(a, b):
    if a > b:
        return b
    else:
        return a

dp_cost = [float('inf')] * n
dp_cost[0] = 0

for i in range(1, n):
    dp_cost[i] = change_min(dp_cost[i], dp_cost[i-1] + abs(H[i] - H[i-1]))
    if i > 1: # i = 1のときi-2は存在しない
        dp_cost[i] = change_min(dp_cost[i], dp_cost[i-2] + abs(H[i] - H[i-2]))

print(dp_cost[-1])


Measured memory_bytes: 20548
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vvi32 = vector<vi32>;
using vi64 = vector<i64>;
using vvi64 = vector<vi64>;
using vstr = vector<string>;

template<typename T> inline bool amin(T &x, T y) { if (y < x) { x = y; return true; } return false; }
template<typename T> inline bool amax(T &x, T y) { if (x < y) { x = y; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vi32 hi, wi;
  vstr board(h);
  rep(i, h) cin >> board[i];
  rep(i, h) {
    bool b = false;
    rep(j, w) {
      if (board[i][j] == '#') b = true;
    }
    if (b) hi.push_back(i);
  }
  rep(i, w) {
    bool b = false;
    rep(j, h) {
      if (board[j][i] == '#') b = true;
    }
    if (b) wi.push_back(i);
  }
  rep(i, hi.size()) {
    rep(j, wi.size()) {
      cout << board[hi[i]][wi[j]];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int X, A, B;
	cin >> X >> A >> B;

	int D = -A + B;
	if (D <= 0) {
		cout << "delicious";
	}
	else if (D > 0 && D <= X) {
		cout << "safe";
	}
	else if (D > X)
	{
		cout << "dangerous";
	}

	return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    if (N == 1) {
        println(1)
        return
    }
    val points: Array<Pair<Long, Long>> = Array(N, { Pair(0L, 0L) })
    (1..N).forEach {
        val (x, y) = readLine()!!.split(" ").map { it.toLong() }
        val pair = Pair(x, y)
        points[it - 1] = pair
    }

    val possiblePairs = mutableListOf<Pair<Long, Long>>()
    (0..(N - 1)).forEach { a ->
        (0..(N - 1)).forEach { b ->
            if (a != b) {
                val p = points[b]!!.first - points[a]!!.first
                val q = points[b]!!.second - points[a]!!.second
                possiblePairs.add(Pair(p, q))
            }
        }
    }

    var cost = Int.MAX_VALUE
    possiblePairs.forEach {
        val p = it.first
        val q = it.second

        var sub = 0
        (0..(N-1)).forEach { i ->
            (0..(N-1)).forEach { j ->
                if (i != j) {
                    if (points[i].first - points[j].first == p && points[i].second - points[j].second == q) {
                        sub++
                    }
                }
            }
        }

        cost = Math.min(cost, N - sub)
    }

    println(cost)
}
class UnionFind(size: Int) {

    var parent: IntArray
    var height: IntArray
    var size: IntArray

    init {
        this.parent = IntArray(size)
        this.height = IntArray(size)
        this.size = IntArray(size)

        for (i in 0 until size) {
            makeSet(i)
        }
    }

    fun merge(x: Int, y: Int) {

        val rootX = root(x)
        val rootY = root(y)

        if (rootX == rootY) {
            return
        }

        if (height[rootX] > height[rootY]) {
            parent[rootY] = rootX
            size[rootX] += size[rootY]

        } else if (height[rootX] < height[rootY]) {
            parent[rootX] = rootY
            size[rootY] += size[rootX]

        } else {
            parent[rootY] = rootX
            size[rootX] += size[rootY]
            height[rootX]++
        }
    }

    fun isSame(x: Int, y: Int) : Boolean {
        return root(x) == root(y)
    }

    fun size(x: Int): Int {
        val rootX = root(x)
        return size[rootX]
    }

    private fun root(x: Int): Int {
        if (x != parent[x]) {
            parent[x] = root(parent[x])
        }
        return parent[x]
    }


    private fun makeSet(i: Int) {
        parent[i] = i
        height[i] = 0
        size[i] = 1
    }
}

Measured memory_bytes: 40608
n = int(input())
b = list(map (int, input().split()))

ans = []
while b != []:
    flag = True
    for i in range(len(b)-1, -1, -1):
        if b[i]-i-1 == 0:
            flag = False
            ans.append(b.pop(i))
            break
    if flag:
        print(-1)
        exit()
for i in range(n-1, -1, -1):
    print(ans[i])


Measured memory_bytes: 3060
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    
    N = II()
    coordinates = []
    diffs = defaultdict(int)
    for i in range(N):
        coordinates.append(LMIIS())
    coordinates.sort()
    for i in range(N):
        x1,y1 = coordinates[i]
        for j in range(i+1,N):
            x2,y2 = coordinates[j]
            diffs[(x1-x2,y1-y2)] += 1
    
    max_diff = ()
    max_count = 0

    for k,v in diffs.items():
        if max_count < v:
            max_count = v
            max_diff = k
    print(N-max_count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 64748
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005
#define il inline
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define  pi  acos(-1)
#define ld  double
#define mod 1000000007
#pragma GCC optimize(2)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main() {
    IOS
    int n,k;
    ll ans=0;
    cin>>n>>k;
    for (ll i = k; i <=n+1 ; ++i) {
        ll l=i*(i-1)/2,r=i*(2*n-i+1)/2;
        ans=(ans+r-l+1)%mod;
    }
    cout<<ans%mod;
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N, K; cin >> N >> K;
  vector<LL> dp(N+1);
  dp[0] = 0; dp[1] = N + 1;
  for (LL k = 2; k <= N + 1; ++k) {
    dp[k] = dp[k-1] + N - 2LL * (k-1);
    dp[k] = (dp[k] + kMod) % kMod;
//    cout << dp[k] << endl;
  }

  LL sum = 0;
  for (int k = K; k <= N + 1; ++k) {
    sum += dp[k];
    sum %= kMod;
  }
  cout << sum << endl;
}


Measured memory_bytes: 4852
/**
 *    author:  zjsdut
 *    created: 2020/03/10 11:40:20
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n)                                                                 \
  for (int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  string s;
  scan(s);
  if (SZ(s) & 1) println("No");
  else {
    for (int i = 0; i < SZ(s); i+=2) {
      if (s[i] != 'h' || s[i + 1] != 'i') {
        println("No");
        return 0;
      }
    }
    println("Yes");
  }
  return 0;
}


Measured memory_bytes: 256
happiness = [list(map(int, input().split())) for _ in range(int(input()))]

n = len(happiness)

for i in range(1, n):
    for j in range(3):
        cur = float("-inf")
        for k in range(3):
            if j != k:
                cur = max(happiness[i - 1][k], cur)
        happiness[i][j] += cur
# print(happiness)
print(max(happiness[-1]))

Measured memory_bytes: 30580
a,b,c,x,y=map(int,input().split())
a_b_all=a*x+b*y
ab_all=(c*2)*max(x,y)
mix_a_all=(c*2)*x+b*(y-x)
mix_b_all=(c*2)*y+a*(x-y)
mix_all=max(mix_a_all,mix_b_all)
print(min(a_b_all,ab_all,mix_all))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
int main()
{
    int N;
    std::cin >> N;
    std::vector<std::vector<char>> Smat(N, std::vector<char>(N, '\0'));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            char c;
            std::cin >> c;
            Smat[i][j] = c;
        }
    }
    int count = 0;
    for (int k = 1; k < N; k++) {
        bool is_symmetry = true;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (Smat[(i + k) % N][j] != Smat[(j + k) % N][i]) {
                    is_symmetry = false;
                    break;
                }
            }
            if (is_symmetry == false) break;
        }
        if (is_symmetry == true)
            count += N;
    }

 
    bool is_symmetry = true;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (Smat[i % N][j % N] != Smat[j % N][i % N]) {
                is_symmetry = false;
                break;
            }
        }
        if (is_symmetry == false) break;
    }
    if (is_symmetry == true)
        count += N;

    std::cout << count << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	char s[102];
	int q=0;
	scanf("%s", s);
	for(int i = 0; i < strlen(s)/2; ++i){
		if(s[i] != s[strlen(s)-1-i]) q++;
	}
	cout<<q<<'\n';
}

Measured memory_bytes: 256
/*
在太阳西斜的这个世界里
置身天上之森。
等这场战争结束之后
不归之人与望眼欲穿的众人
人人本着正义之名
长存不灭的过去
逐渐消逝的未来
我回来了
纵使日薄西山
即便看不到未来
此时此刻的光辉
盼君勿忘
*/

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long LL;
const LL mod=1000000007;

LL power(LL a,LL b,LL p){
    LL ans=1;
    for(;b;b>>=1){
        if(b&1) ans=ans*a%p;
        a=a*a%p;
    }
    return ans;
}

int main(){
    LL n;
    cin>>n;
    if(n==1) {
    	cout<<0;
    	return 0;
	}
    cout<<((power(10,n,mod)-2*power(9,n,mod)+power(8,n,mod))%mod+mod)%mod;
	return 0;
}


Measured memory_bytes: 3632
k = input()
K = int(k)
t = input().split()
T =[int(s) for s in t]
a1 = T[0] // K
b1 = T[1] // K
a2 = T[0] % K
if a1 == b1 and a2 != 0:
    print('NG')
else:
    print('OK')

Measured memory_bytes: 9180
#include <stdio.h>

int main () {

    int a, b, c, d;

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

    d = 1;

    if (a != b) {
        d++;
    }

    if (b != c && a != c) {
        d++;
    }

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

    return 0;
}

Measured memory_bytes: 128
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

# 全文のforで検索可能

for i in range(A+1):
    for k in range(B+1):
        for j in range(C+1):
            total = i * 500 + 100 * k + j * 50
            if(total == X):
                ans = ans + 1

print(ans)

Measured memory_bytes: 3060
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());

int main(){
    llong N,M;
    llong a,b;

    cin >> N >> M;

    vector<llong> A(N,0);

    for(int i=0; i<M; i++){
        cin >> a >> b;
        A[a-1] += 1;
        A[b-1] += 1;
    }
    for(int i=0; i<A.size(); i++){
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3160
#include<iostream>
using namespace std;
int main(){
	int size=19;
	char s[size];
	for(int i=0;i<size;i++){
		cin>>s[i];
	}
	s[5]=' ';
	s[13]=' ';
	
	for(int i=0;i<size;i++)
	   cout<<s[i];
	
	
	
}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 505;
const double PI = acos(-1.0);
const ll mod = 1e6 + 3;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int n,x;
int val[55];
ll dp[51][51][2505];

void solve()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&val[i]);
	}
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<i;j++)
		{
			for(int k=0;k<=2500;k++)
			{
				dp[i][j][k]+=dp[i-1][j][k];
			}
		}
		for(int j=1;j<=i;j++)
		{
			for(int k=0;k<=2500-val[i];k++)
			{
				dp[i][j][k+val[i]]+=dp[i-1][j-1][k];
			}
		}
	}
	//cout<<dp[1][1][7]<<endl;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i*x<=2500)
		{
			ans+=dp[n][i][i*x];
		}
	}
	printf("%lld",ans);
}

int main()
{

    solve();
	return 0;
}

Measured memory_bytes: 51200
#include <iostream>
using namespace std;
int main() {
  int n, y;

  cin >> n >> y;
  int flag = 0;
  int a_max = y / 10000;
  for (int a = a_max; a >= 0; a--) {
    int b_max = n - a;
    for (int b = b_max; b >= 0; b--) {
      int c = n - a - b;
      // cout << "::" << a << " " << b << " " << c << endl;
      if (y == 10000 * a + 5000 * b + 1000 * c) {
        // bingo
        cout << a << " " << b << " " << c << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      break;
    }
  }
  if (flag == 0) {
    cout << "-1 -1 -1" << endl;
  }

  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<algorithm>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <functional>
#include <time.h>
using namespace std;
clock_t fi, endtime;
string n[51];
int dp[21][50002] = { 0 };
int c[21] = { 0 };
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++i) {
		scanf("%d", &c[i]);
	}
	for (int i = 0; i < m; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (i == 0) dp[i][j] = dp[i][j - c[i]] + 1;
			else if (j < c[i]) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = min(dp[i - 1][j], dp[i][j - c[i]] + 1);
			}
		}
	}
	printf("%d\n", dp[m - 1][n]);
}

Measured memory_bytes: 7100
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define MOD 998244353
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

struct modint{
  li num;

  modint(li a=0){
    num=(a%MOD+MOD)%MOD;
  }
  modint operator+(modint a) {return{(num+a.num)%MOD};} 
  modint operator-(modint a) {return{((num-a.num)%MOD+MOD)%MOD};}
  modint operator*(modint a) {return{num*a.num%MOD};}
  modint inv(const modint& a);
  modint operator/(modint a) {return (*this)*inv(a);}
  modint& operator+=(modint a) {
    (num += a.num)%=MOD;
    return *this;
  }
  modint& operator-=(modint a) {
    (num += MOD-a.num)%=MOD;
    return *this;
  }
  modint& operator*=(modint a) {
    (num*=a.num)%=MOD;
    return *this;
  }
};

std::ostream& operator<<(std::ostream& os, const modint& m){
  // ここでストリームに obj を書き込みます。
  li a=m.num;
  a%=MOD;
  a+=MOD;
  a%=MOD;
  cout << a;
  return os;
}

std::istream& operator>>(std::istream& os,modint& m){
  // ここでストリームに obj を書き込みます。
  li a; cin >>a;
  m=a;
  return os;
}

modint pow(modint a,int r){
  modint b=a,ans=1;
  while(r){
    if(r%2) ans*=b;
    b*=b;
    r/=2;
  }
  return ans;
}


int main(){
  int n; cin >>n;
  vector<li> v(n);
  li s=0;
  rep(i,n){
    int a; cin >>a;
    v[i]=a; s+=a;
  }
  li lim=s/2;
  vector<modint> dps(lim+1,0),dp(lim+1,0);
  // dps[i][j]:  棒iまででRをjに塗る．他も塗る．
  // B_{R}=\sum{i>=s/2.0}dps[j], B_{RG}=dp[s/2.0], B_{RGB}=0
  // ans=B_{}-3B_{R}+3B{RG}
  
  dps[0]=1; dp[0]=1;
  if(df)print("dp");
  rep(i,n){
    rep(_j,lim+1){
      int j=lim-_j;
      dp[j]=dp[j]+((j-v[i]>=0)?dp[j-v[i]]:0);
    }
    if(df) print(dp);
  }
  if(df)print("dps");
  rep(i,n){
    rep(_j,lim+1){
      int j=lim-_j;
      dps[j]=dps[j]*2+((j-v[i]>=0)?dps[j-v[i]]:0);
    }
    if(df) print(dps);
  }
  modint ans=0;
  if(df)print(s);
  rep(i,(s+1)/2){
    ans+=dps[i];
  }
  if(df){
    print(pow((modint)3,n));
    print(pow((modint)3,n)-ans);
  }
  ans*=3;
  ans-=pow((modint)3,n)*2;
  if(s%2==0) ans+=dp[s/2]*3;
  print(ans);
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

vector<vector<double>> c;

double pp(int m, int k, double p){
  double ans=c[m][k];
  rep(i,k) ans*=p;
  rep(i,m-k) ans*=1-p;
  return ans;
}

int main(){
  c=vector<vector<double>>(51,vector<double>(51));
  c[0][0]=1;
  repp(i,1,51){
    c[i][0]=1,c[i][i]=1;
    repp(j,1,i){
      c[i][j]=c[i-1][j-1]+c[i-1][j];
    }
  }
  int n,m;
  double l;
  cin >> n >> m >> l;
  vector<vector<double>> time(n,vector<double>(m+1)),prob(n,vector<double>(m+1));
  double p,t,v;
  rep(i,n){
    cin >> p >> t >> v;
    rep(j,m+1){
      time[i][j]=l/v+t*j;
      prob[i][j]=pp(m,j,p/100);
    }
  }
  cout << fixed << setprecision(10);
  rep(i,n){
    double ans=0;
    rep(j,m+1){
      double tmp=prob[i][j];
      rep(k,n){
        if(i==k) continue;
        double tmpp=0;
        per(l,m+1){
          if(time[k][l]<=time[i][j]) break;
          tmpp+=prob[k][l];
        }
        tmp*=tmpp;
      }
      ans+=tmp;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3400
a = []
appear = [[False, False, False], [False, False, False], [False, False, False]]

for i in range(3):
    a.append(list(map(int, input().split())))

n = int(input())
b = [0] * n
for j in range(n):
    b[j] = int(input())

for s in range(3):
    for t in range(3):
        for j in range(n):
            if a[s][t] == b[j]:
                appear[s][t] = True
ans = 'No'
if appear[0][0] and appear[1][1] and appear[2][2]:
    ans = 'Yes'
for s in range(3):
    if appear[s][0] and appear[s][1] and appear[s][2]:
        ans = 'Yes'
    if appear[0][s] and appear[1][s] and appear[2][s]:
        ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
    ans = 'Yes'
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
    	using namespace std;
        
    	int main()
    	{
    		
                int n,size;
                string ans="";
                cin>>n>>size;
                vector<string>s;
                for(int i=0;i<n;i++)
                {
                    string k;
                    cin>>k;
                    s.push_back(k);
                }
                sort(s.begin(),s.end());
                for(auto x:s)
                    ans+=x;
                cout<<ans;
    		return 0;
    	}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
// #define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ld s; cin >> s;
  ll x = ll(ceil(sqrt(s)));
  ll y = x * x - s;
  cout << "0 0 " << x << " " << y << " " << 1 << " " << x << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 512
import java.util.Scanner;

/**
 * DrowingLots
 */
public class Main{

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for (int i = 0; i < values.length; i++) {
                values[i] = i + 1;
            }

            for (int i = 0; i < n; i++) {
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;

                int temp;
                temp = values[a];
                values[a] = values[b];
                values[b] = temp;
            }

            for (int i = 0; i < values.length; i++) {
                System.out.println(values[i]);
            }
        }
    }
}


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

n = int(input())
a_list = list(map(int, input().split()))

m_list = [0]*n
for i in range(0, n, 2):
    m_list[0] += a_list[i]

for i in range(1, n, 2):
    m_list[0] -= a_list[i]


for i in range(1, n):
    m_list[i] = 2 * a_list[i-1] - m_list[i-1]

m_str = [str(m) for m in m_list]
print(' '.join(m_str))

Measured memory_bytes: 21180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main() {
  ll H, W; cin >> H >> W;
  ll a[H][W];
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }
  vector<ll> as;
  vector<ll> bs;
  vector<P> ps;
  for (ll i = 0; i < H; i++) {
    if (i%2 == 0) {
      for (ll j = 0; j < W; j++) {
        as.push_back(a[i][j]);
        bs.push_back(a[i][j]);
        ps.push_back(P(i+1, j+1));
      }
    } else {
      for (ll j = W-1; j >= 0; j--) {
        as.push_back(a[i][j]);
        bs.push_back(a[i][j]);
        ps.push_back(P(i+1, j+1));
      }
    }
  }
  ll num = 0;
  for (ll i = 0; i < H*W-1; i++) {
    if (bs[i] % 2 == 1) {
      bs[i]--; bs[i+1]++; num++;
    }
  }
  cout << num << endl;
  
  for (ll i = 0; i < H*W-1; i++) {
    if (as[i] % 2 == 1) {
      as[i]--; as[i+1]++;
      P fr = ps[i]; P to = ps[i+1];
      cout << fr.first << " " << fr.second << " " << to.first << " " << to.second << endl;
    }
  }
}

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

using std::string;

int main()
{
  string input;
  std::cin >> input;
  int cnt = 0;
  int result = 0;
  for (char ch : input) {
    if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T') {
      cnt++;
    } else {
      cnt = 0;
    }
    result = std::max(result, cnt);
  }
  std::cout << result << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

    int n, min, total;
    scanf("%d", &n);
    int point[n];
    min = 100;
    total = 0;

    for(int i=0; i<n; i++){
	scanf("%d", &point[i]);
	if(point[i]<min && point[i]%10 != 0){
	    min = point[i];
	}
    }
    for(int j=0; j<n; j++){
	total += point[j];
    }

    if(total%10 != 0){
	printf("%d\n", total);
    }else{
	total -= min;
	if(total%10 != 0){
	    printf("%d\n", total);
	}else{
	    printf("0\n");
	}
    }
    return 0;
}

Measured memory_bytes: 128
MOD = 10**9 + 7


def main():
    S = input()
    N = len(S)
    dp = [[0]*13 for _ in range(N+1)]
    dp[0][0] = 1
    from itertools import product
    for i, mod13 in product(range(N), range(13)):
        if S[i] == "?":
            lim = 9
            for d in range(lim+1):
                dp[i+1][(mod13*10 + d) % 13] \
                    += dp[i][mod13]
                dp[i+1][(mod13*10 + d) % 13] \
                    %= MOD
        else:
            d = int(S[i])
            dp[i+1][(mod13*10 + d) % 13] \
                += dp[i][mod13]
            dp[i+1][(mod13*10 + d) % 13] \
                %= MOD
    print(dp[N][5] % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63324
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

string s;
long long k;

int main(){
    cin >> s;
    cin >> k;
    for(int i=0;i<min(k,(long long)s.size());i++){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

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


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

    int N = S.size(), count = 0;
    vector<int> ans(N, 0);
    for(int i = 0; i < N-1; ++i){
        if(S[i] == 'R') ++count;
        if(S[i] == 'R' and S[i+1] == 'L'){
            ans[i] += (count+1)/2;
            ans[i+1] += count/2;
            count = 0;
        }
        //for(int i = 0; i < N; ++i) cout << ans[i] << " ";
        //cout << endl;
    }

    /* reverse して同じことをする方法もあり
    reverse(S.begin(), S,end());
    reverse(ans.begin(), ans,end());
    for(int i = 0; i < N; ++i){
        if(S[i] == 'R') S[i] = 'L';
        else if(S[i] == 'L') S[i] = 'R';
    }
    */
    
    for(int i = N; i > 0; --i){
        if(S[i] == 'L') ++count;
        if(S[i] == 'L' and S[i-1] == 'R'){
            ans[i] += (count+1)/2;
            ans[i-1] += count/2;
            count = 0;
        }
    }
    for(int i = 0; i < N; ++i) cout << ans[i] << " ";
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using i64 = long long;

const i64 MOD = 1000000007;
const int N = 600 + 7;

int n, k;
int to[N];
int cnt[N];
i64 f[N][N], g[N][N];
i64 dfac_[N], *dfac;
i64 ans;

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d%d", &n, &k), n <<= 1;
	for (int i = 1, x, y; i <= k; ++i)
		scanf("%d%d", &x, &y), to[x] = y, to[y] = x;

	for (int i = 1; i <= n; ++i)
		cnt[i] = cnt[i - 1] + (to[i] > 0);
	dfac = dfac_ + 2, dfac[-1] = dfac[0] = 1;
	for (int i = 1; i <= n; ++i) dfac[i] = dfac[i - 2] * i % MOD;

	for (int l = 2; l <= n; l += 2)
		for (int i = 1, j = l; j <= n; ++i, ++j) {
			int ok = 1;
			for (int k = i; k <= j; ++k) ok &= !to[k] || i <= to[k] && to[k] <= j;
			if (!ok) continue;
			f[i][j] = g[i][j] = dfac[l - (cnt[j] - cnt[i - 1]) - 1];
			for (int k = i + 1; k < j; k += 2)
				( f[i][j] -= f[i][k] * g[k + 1][j] ) %= MOD;
			( ans += f[i][j] * dfac[n - l - 2 * k + (cnt[j] - cnt[i - 1]) - 1] ) %= MOD;
		}
	printf("%lld", (ans + MOD) % MOD);
	return 0;
}


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

typedef long long ll;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int b[n-1];
	int a[n];
	for (int i = 0; i<n-1; i++) cin >> b[i];
	a[0] = b[0], a[1] = b[0];
	for (int i = 2; i<n; i++) {
		a[i] = b[i-1];
		if (b[i-1] < a[i-1]) a[i-1] = b[i-1];
	}
	int ret = 0;
	for (int i =0; i<n; i++) ret += a[i];
	cout << ret << '\n';
}



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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    string s; cin >> s;
    int q; cin >> q;
    deque<char> d; bool rev = false;
    for (auto x : s) {
        d.push_back(x);
    }
    while (q--) {
        int x; cin >> x;
        if (x == 1) rev = !rev;
        else {
            int a; char b;
            cin >> a >> b;
            if (a == 1) {
                if (rev) {
                    d.push_back(b);
                } else {
                    d.push_front(b);
                }
            } else {
                if (rev) {
                    d.push_front(b);
                } else {
                    d.push_back(b);
                }
            }
        }
    }
    if (rev) {
        while (!d.empty()) {
            cout << d.back();
            d.pop_back();
        }
        cout << endl;
    } else {
        while (!d.empty()) {
            cout << d.front();
            d.pop_front();
        }
        cout << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 976
// C++ 14
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define EPS 0.000000001
#define fequals(a,b) (fabs((a) - (b)) < EPS)

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (const Vector2 v) const { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (const Vector2 v) const { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (const double k) const { return Vector2(x * k, y * k); }
  Vector2 operator / (const double k) const { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 const v) { return x * v.x + y * v.y; }
  double cross (Vector2 const v) { return x * v.y - y * v.x; }
  
  bool parallel(Vector2 &other) {
    return fequals(fabs(dot(other)), length() * other.length());
  }
  
  bool orthogonal(Vector2 &other) {
    return fequals(0, dot(other));
  }
  
  bool operator < (const Vector2 &v) {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}


void project(Vector2 start_, Vector2 end_, Vector2 p) {
    Vector2 v = end_ - start_;
    Vector2 op = start_ + v * (v.dot(p - start_) / v.norm());
    cout << op.x << ' ' << op.y << endl;
}

#define MAX_N 1001
Int N;
Vector2 start_, end_, p;

void input() {
  cin >> start_ >> end_ >> N;
  while (cin >> p) {
    project(start_, end_, p);
  }
}

int main() {
  cout.precision(15);
  input();
}


Measured memory_bytes: 3276
# A,B,C,Dのおもりの重さを整数で入力
A,B,C,D = map(int,input().split())
if A + B > C + D:
# 左の皿（A+B）の方が重いならLeft、同じならBalanced、左の皿（C+D）が重いならRightを出力
    print("Left")
elif A + B == C + D:
    print("Balanced")
else:
    print("Right")

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int main() {
	int a, b, N;
	cin >> a >> b >> N;
	
	int ans = 0;
	REP(i, N) {
		int s, f;
		scanf("%d %d", &s, &f);
		
		ans |= a == s;
		ans |= b == f;
		ans |= a < s && f < b;
		ans |= s < a && a < f;
		ans |= s < b && b < f;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >>c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
  	  cout << "vowel" << endl;
  }else{
      cout << "consonant" << endl;
  }
  

}

Measured memory_bytes: 3636
A,B = map(int,input().split())
S1,S2 = "",""
for i in range(A):
    S1 = S1 + str(B)
for i in range(B):
    S2 = S2 + str(A)
if(int(S1) > int(S2)):
    print(S1)
else:
    print(S2)


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

int main(){
	int N, X, Y;
	scanf("%d %d %d", &N, &X, &Y);
	X--,Y--;
	int d[N];
	for (int i = 1; i < N; ++i){
		d[i] = 0;
	}
	for (int i = 0; i < N; ++i){
		for (int j = i + 1; j < N; ++j){
			d[min(j - i, abs(j - Y) + abs(i - X) + 1)]++;
		}
	}
	for (int i = 1; i < N; ++i){
		printf("%d\n", d[i]);
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; i++)
        cin >> h[i];

    int wtr = 0;
    int maxz = *max_element(h.begin(), h.end());
    for(int i = 0; i < maxz; i++){
        for(int j = 0; j < N - 1; j++){
            if(h[j] != 0 && h[j + 1] == 0)
                wtr++;
        }
        if(h[N - 1] != 0)
            wtr++;
        for(int j = 0; j < N; j++)
            h[j] = max(0, h[j] - 1);
    }

    cout << wtr << endl;

    return 0;
}

Measured memory_bytes: 256
# 問題文： 大きさ N の順列 ((1, 2, ..., N) を並び替えてできる数列) P, Q があります。大きさ N の順列は N! 通り考えられます。
#         このうち、P が辞書順で a 番目に小さく、Q が辞書順で b 番目に小さいとして、|a−b| を求めてください。
# 注記： 2 つの数列 X, Y について、ある整数 k が存在して Xi=Yi (1≤i<k) かつ Xk<Yk が成り立つとき、X は Y より辞書順で小さいと定義されます。
# 制約: 2≤N≤8　P,Qは大きさNの順列である。入力は全て整数である。

import math

# 数列が何番目かを返却するメソッド
def junban(N, str):
    int_N = int(N)
    int_list = str.split() # 入力文字を配列化
    int_list = [int(i) for i in int_list]
    yet_list = str.split() # まだ出てきていない数字のリスト
    yet_list = [int(i) for i in yet_list]

    num = 1 # 何番目か保持する
    keta = 0 # 上から何桁目か保持する

    while keta < (int_N):
        # 該当桁の数字を確保する
        now_int = int_list[keta]

        # 未出数値のリストを更新する
        yet_list.remove(now_int)

        # 該当桁以下の階乗
   #     print('該当桁以下の桁数は：{}'.format(len(yet_list)))
        # 該当桁の数字より若い数字がいくつ残っているか
    #    print('該当桁の数字より若い数字はあと{}個'.format(len([i for i in yet_list if i < now_int])))

        # 順番をカウント
        # 該当桁以下の階乗 * 未出数値の内、現在より数値の小さいものの個数
        num += math.factorial(len(yet_list)) * len([i for i in yet_list if i < now_int])
        keta += 1

#    print('{}番目'.format(num))
    return num

# 大きさNを受け取る
N = input()
# 数列Pを受け取る
P = input()
# 数列Qを受け取る
Q = input()

# Pが何番目か求める
p_int = junban(N, P)
q_int = junban(N, Q)

print(abs(p_int - q_int))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

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

	int ans = 0, now = 0;
	rep(i, n) {
		if (s[i] == 'I')
			now++, ans = max(ans, now);
		else
			now--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

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

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, N;
  cin >> H >> N;

  vector<int> as(N), bs(N);
  F0R(i, N) {
    cin >> as[i] >> bs[i];
  }

  // dp[i] := モンスターの体力を i 減らすのに必要な魔力の最小値
  vector<int> dp(H + 1, INT32_MAX);
  dp[0] = 0;

  FOR(i, 1, H + 1) {
    F0R(j, N) {
      if (as[j] >= i) {
        chmin(dp[i], bs[j]);
      }
      else {
        chmin(dp[i], dp[i - as[j]] + bs[j]);
      }
    }
  }
  cout << dp.back();
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int table[100][100];
string s;

int dx[] = { 0, 1, 0, -1, 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0, -1, 0, 1, 0 };
char c[] = "URDLURDL";

int main(){
	REP(i, 9){
		cin >> s;
		REP(j, s.size()){
			if (i % 2 == 0)	table[i][2 * j + 1] = s[j] - '0';
			else table[i][2 * j] = s[j] - '0';
		}
	}
	bool f = 0;
	string ans = "";
	int x = 0, y = 0, muki = 0;
	while (1){
		if (f&&x == 0 && y == 0)break;
		int ny, nx;
		for (int i = muki; i < muki + 4; i++){
			nx = x + dx[i], ny = y + dy[i];
			if (nx >= 0 && nx <= 8 && ny >= 0 && ny <= 8){
				if (table[ny][nx] == 1){
					x += 2 * dx[i];
					y += 2 * dy[i];
					ans += c[i];
					if (c[i] == 'U')muki = 3;
					else if (c[i] == 'R')muki = 0;
					else if (c[i] == 'D')muki = 1;
					else muki = 2;
					break;
				}
			}
		}
		f = 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;


int main() 
{
	int a, b;
	cin >> a >> b;
	if(a <= 8 && b <= 8)
		printf("Yay!\n");
	else
		printf(":(\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
// int64_t INF = 1000000007;
int64_t INF = 9223372036854775807;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    // 真ん中を通る区間の、端っこに近い方の距離が正解か
    int64_t sum = 0;
    rep(i,n) sum += a.at(i);
    int64_t sum2 = 0;
    int64_t res = INF;
    rep(i,n){
        sum2 += a.at(i);
        res = min(res, abs(sum-2*sum2));
    }
    cout << res << endl;
}

Measured memory_bytes: 1792