akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//当時の自分の方が天才っぽい
int D[100001];
int P[100001];
int to[100001], ne[100001], he[100001];
int sagasu(int A) {
	if (D[A]) return D[A];
	int ret = 1;
	for (int i = he[A]; i; i = ne[i]) {
		int u = to[i];
		int kari = sagasu(u) + 1;
		if (ret < kari) {
			ret = kari;
			P[A] = u;
		}
	}
	return 	D[A] = ret;
}

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


	int N, M;
	cin >> N >> M;
	rep1(i, N + M - 1) {
		int a, b;
		cin >> a >> b;
		to[i] = a;
		ne[i] = he[b];
		he[b] = i;
	}

	rep1(i, N) {
		sagasu(i);
		co(P[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll n, m, q, a[55], b[55], c[55], d[55],A[55],ans;
void dfs(ll keta = 0, ll range = 1) {
	if (keta == n) {
		ll now = 0;
		for (int i = 0; i < q; i++) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				now += d[i];
			}
		}
		ans = max(now, ans);
		return;
	}
	for (int number = range; number <= m; number++) {
		A[keta] = number;
		dfs(keta + 1, number);
	}
}
int main() {
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}
	dfs();
	cout << ans << endl;
	return 0;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

vector<LL> v;

LL ryuka(LL x){
    if (x == 0) {
        return 2;
    }else if (x == 1){
        return 1;
    }

    if (v[x] != -1) {
        return v[x];
    }

    return v[x] = ryuka(x-1) + ryuka(x-2);

}

int main(int argc, char const* argv[])
{
    LL n;
    cin >> n;

    v.resize(n+1);
    for (LL i = 0; i < n+1; i++) {
        v[i] = -1;
    }

    cout << ryuka(n) << endl;
    // printvector(v);

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


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

const ll mod = 1e9 + 7;
string s;
int d, n;
vector<int> v;
vector<vector<vector<ll>>> dp;

ll rec(int pos, int sum, int ok)
{
	if (pos == n)
	{
		if (sum % d == 0)
			return 1;
		return 0;
	}
	if (dp[pos][sum][ok] != -1)
		return dp[pos][sum][ok];
	int ans = 0, lim = 9;
	if (ok)
		lim = v[pos];
	for (int i = 0; i <= lim; i++)
	{
		if (i == v[pos])
			ans = (ans + rec(pos + 1, (sum + i) % d, ok)) % mod;
		else
			ans = (ans + rec(pos + 1, (sum + i) % d, 0)) % mod;
	}
	return dp[pos][sum][ok] = ans;
}

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> s >> d;
	n = s.length();
	for (int i = 0; i < n; i++)
	{
		v.push_back(s[i] - '0');
	}
	dp.resize(n);
	for (int i = 0; i < n; i++)
	{
		dp[i].resize(d, vector<ll> (2, -1));
	}
	ll answer = rec(0, 0, 1);
	answer += (mod - 1);
	answer %= mod;
	cout << answer;

	return 0;
}

Measured memory_bytes: 59028
l = list(map(int, input().split()))

N = l[0]
Y = l[1]
ans = [-1,-1,-1]

if Y/10000 <= N:
    for i in range(int(Y/10000)+1):
        a = i
        n = N - a
        Y1 = Y - (a * 10000)
        if Y1/5000 <= n:
            for j in range(int(Y1/5000)+1):
                b = j
                c = n - j
                if 10000 * a + 5000 * b + 1000 * c == Y:
                    ans = [a,b,c]

print(ans[0],ans[1],ans[2])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  ll x;
  cin >> x;
  ll y = x%11;
  ll step = x/11;
  if(y == 0) cout << step*2 << endl;
  if(0<y && y<=6) cout << step*2+1 << endl;
  if(6<y && y<=10) cout << step*2+2 << endl;
}

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

int main(){
  int n, x, l;
  cin >> n;
  vector<pair<int, int>> r(n);
  rep(i, n){
    cin >> x >> l;
    r[i] = make_pair(x+l, x-l);
  }
  sort(r.begin(), r.end());
  int c = 0, p = -1e9;
  rep(i, n){
    if (p <= r[i].second){
      c++;
      p = r[i].first;
    }
  }
  cout << c << endl;;
  return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r,D,x[11];
    cin >> r >> D >> x[0];
    for (int i = 1;i <= 10; i++)
    {
        x[i] = r*x[i-1] - D;
        cout << x[i] << endl;
    }
    
}

Measured memory_bytes: 3596
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n)
        cin >> a[i];
    vector<ll> ans(n);

    int sign = 1;
    ll x0 = 0;
    REP(i, n){
        x0 += sign * a[i];
        sign *= -1;
    }
    ans[0] = x0;
    FOR(i, 1, n){
        ans[i] = 2*a[i-1]-ans[i-1];
    }
    print_container(ans);


    return 0;
}

Measured memory_bytes: 2944
All=input().split()
W=int(All[0])
H=int(All[1])
x=int(All[2])
y=int(All[3])
r=int(All[4])
if x+r<=W and x-r>=0 and y+r<=H and y-r>=0:
    print('Yes')
else:
    print('No')

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

ll calc(ll n) {
	if (n <= 0) return 0;
	string s = to_string(n);
	int ret = 0;
	for (auto &elem : s) ret += elem - '0';
	return ret;
}

int main(void) {
	ll n;
	cin >> n;

	ll ans = calc(n);

	ll cri = 1LL;

	while (cri < n) {
		chmax(ans, calc(n - n % cri - 1));
		cri *= 10;
	}

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

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

int nn;
int n_digit = 1;
int ans = 0;

int tens(int n){
  int r = 1;
  for(int i=0; i<n; i++)  r *= 10;
  return r;
}

int toInt(int array[]){
  int r = 0;
  for(int i=1; i<=array[0]; i++)
    r = r + array[i] * tens(array[0]-i);
  return r;
}

void dfs(int array[], int n){
  if(array[0] == n){
    int flag[3] = {0};
    for(int i=1; i<=n; i++)
      if(array[i] != 0)
	flag[array[i]/2-1] = 1;
    if(flag[0] == 1 && flag[1] == 1 && flag[2] == 1)
      if(toInt(array) <= nn)
	ans++;
    return;
  }
  int start = (array[array[0]]==0 ? 0 : 1);
  for(int i=start; i<=3; i++){
    if(i == 0)
      array[++array[0]] = 0;
    else
      array[++array[0]] = i * 2 + 1;
    dfs(array, n);
    array[0]--;
  }
}

int main(){
  scanf("%d", &nn);
  int tmp = nn;
  while(tmp / 10){
    n_digit++;
    tmp /= 10;
  }
  int array[10] = {0};
  dfs(array, n_digit);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
"use strict";

class PriorityQueue {
  constructor() {
    this.heap = [];
  }

  push(item) {
    let heap = this.heap;
    let i = heap.length++;
    let j;

    while(i) {
      j = i - 1 >> 1;
      if(heap[j] <= item) break;
      heap[i] = heap[j]
      i = j;
    }

    heap[i] = item;
  }

  pop() {
    let heap = this.heap;
    let r = heap[0];
    let x = heap.pop();

    let i = 0;
    let k = heap.length >> 1;
    let j;

    while(i < k) {
      j = (i << 1) + 1;
      if(heap[j+1] < heap[j]) ++j;

      if(x <= heap[j]) break;

      heap[i] = heap[j];

      i = j;
    }

    if(heap.length) {
      heap[i] = x;
    }

    return r;
  }

  size() {
    return this.heap.length;
  }

  top() {
    return this.heap[0];
  }
}


const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const A = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);

    let pq = new PriorityQueue();
    
    for(let i in A) {
        pq.push(-A[i]);        
    }
    
    for(let i=0; i<M; i++) {
        let highest = -pq.pop();
        pq.push(-Math.floor(highest / 2));
    }
    
    let answer = -1 * pq.heap.reduce((m,n)=>m + n);

    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

struct bit {
    vector<long> t;
    bit() : t(555555) {}
    void upd(int a, long n) {
        for(a++; a < t.size(); a += a & -a)
            t[a] += n;
    }
    long get(int a) const {
        long r = 0;
        for(; a; a &= a - 1)
            r += t[a];
        return r;
    }
} b[26];
int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    for(int i = 0; i < n; i++)
        b[s[i] - 'a'].upd(i, 1);
    for(int i = 0; i < q; i++) {
        int x, l, r;
        scanf("%d%d", &x, &l);
        if(x == 1) {
            char c;
            scanf(" %c", &c);
            b[s[l - 1] - 'a'].upd(l - 1, -1);
            b[c - 'a'].upd(l - 1, 1);
            s[l - 1] = c;
            continue;
        }
        scanf("%d", &r);
        x = 0;
        for(int j = 0; j < 26; j++)
            if(b[j].get(l - 1) < b[j].get(r))
                x++;
        cout << x << '\n';
    }
    cout << flush;
    return 0;
}


Measured memory_bytes: 113924
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

void io(string s = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (sz(s)) {
    	setIn(s+".in");
    	setOut(s+".out");
    }
}

int n, num[MX], par[MX];
ll d[MX], ans;
vi rpar[MX];
map<ll,int> m;

void gen(int x, int d = 0) {
    ans += d;
    for (int i: rpar[x]) gen(i,d+1);
}

int main() {
    io();
    cin >> n;
    
    priority_queue<pl> q;
    FOR(i,1,n+1) {
        cin >> d[i];
        num[i] = 1;
        m[d[i]] = i;
        q.push({d[i],i});
    }
    while (1) {
        auto a = q.top(); q.pop();
        par[a.s] = m[a.f-n+2*num[a.s]];
        if (2*num[a.s] >= n) par[a.s] = 0;
        if (par[a.s] == 0) {
            if (sz(q) != 0) {
                cout << -1;
                exit(0);
            } else {
                gen(a.s);
                if (d[a.s] != ans) {
                    cout << -1;
                    exit(0);
                }
                FOR(i,1,n+1) if (par[i]) cout << i << " " << par[i] << "\n";
                exit(0);
            }
        } else {
            rpar[par[a.s]].pb(a.s);
            num[par[a.s]] += num[a.s];
        }
    }
}

/* 
* (Actually read this pls)
    * Rlly bad errors: int overflow, array bounds
    * Less bad errors: special cases (n=1?), set tle
    * Common sense: do smth instead of nothing
*/

Measured memory_bytes: 17648
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int c;
        cin >> c;
        v.push_back(c);
    }
    vector<pair<int, int>> rl({{v[0], 1}});
    for(int i=1;i<n;++i){
        if(v[i] == rl.back().first)rl.back().second++;
        else rl.emplace_back(v[i], 1);
    }

    vector<i64> dp(rl.size()+1);
    map<int, int> prev;
    dp[0] = 1;
    for(int i=1;i<=(int)rl.size();++i){
        dp[i] += dp[i-1];
        dp[i] %= MOD;
        if(prev.count(rl[i-1].first)){
            dp[i] += dp[prev[rl[i-1].first]];
            dp[i] %= MOD;
        }
        prev[rl[i-1].first] = i;
        //cerr << dp[i] << endl;
    }

    cout << dp[rl.size()] << endl;

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

ll N,A,B;
void input()
{
    cin>>N>>A>>B;
}

void solve()
{
    ll ans=(N/(A+B))*A+min(A,N%(A+B));
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

int main()
{
	int n = 0;
	int a[10000];
	for (int input;std::cin >> input , input;n++)
	{
		a[n] = input;
	}
	for (int i = 1; i <= n; i++)
	{
		std::cout << "Case " << i << ": " << a[i - 1] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    int ans=0;
    for(int i=1;i<=N;i++){
        string str = to_string(i);
        if(str.length()%2==1) ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for _ in range(M)]

C = [list(map(int, input().split())) for _ in range(3)]
 
Dif_H = [[] for _ in range(3)]
Dif_V = [[] for _ in range(3)]
 
for i in range(3):
    Dif_H[i] = [C[i][0] - C[i][1], C[i][1] - C[i][2], C[i][2] - C[i][0]]
for i in range(3):
    Dif_V[i] = [C[0][i] - C[1][i], C[1][i] - C[2][i], C[2][i] - C[0][i]]
 
if Dif_H[0] == Dif_H[1] == Dif_H[2] and Dif_V[0] == Dif_V[1] == Dif_V[2]:
    print('Yes')
else:
    print('No')

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

struct UnionFind {
	vector<int> value;
	UnionFind(int size = 0): value(size, -1){}
	int find(int x){
		if (value[x] < 0) return x;
		return value[x] = find(value[x]);
	}
	int size(int x){
		return -value[find(x)];
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	bool unite(int x, int y){
		x = find(x);
		y = find(y);
		if (x == y) return false;
		if (value[x] > value[y]) swap(x, y);
		value[x] += value[y];
		value[y] = x;
		return true;
	}
};

int main()
{
	int n, q;
	scanf("%d %d", &n, &q);
	
	UnionFind uf(n);
	
	for (int i = 0; i < q; i++){
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		
		if (com == 0){
			uf.unite(x, y);
		}
		else {
			printf("%d\n", uf.same(x, y));
		}
	}
	
	return 0;
}

Measured memory_bytes: 1224
#include "bits/stdc++.h"
using namespace std;

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int n = 0; n < H; ++n) {
		cin >> S[n];
	}
	for (int n = 0; n < H; ++n) {
		for (int m = 0; m < W; ++m) {
			if ('.' == S[n][m]) {
				int count = 0;
				for (int l = 0; l < 8; ++l) {
					int x1 = n + dx[l];
					int y1 = m + dy[l];
					if ((0 <= x1) && (H > x1) && (0 <= y1) && (W > y1) && ('#' == S[x1][y1])) {
						count++;
					}
				}
				S[n][m] = (char)('0'+count);
			}
		}
	}
	for (int n = 0; n < H; ++n) {
		cout << S[n] << endl;;
	}
	return 0;
}

Measured memory_bytes: 3612
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,w =mi()
a = [tuple(int(i) for i in input().split()) for _ in range(n)]
dp=[0]*(w+1)
for v,ww in a:
    for i in range(ww,w+1)[::-1]:
        dp[i] = max(dp[i], dp[i-ww]+v)
print(dp[w])


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

using namespace std;

const int N=1e4+10;
int p[N];

void init(int n)
{
    for(int i=0;i<n;i++) p[i]=i;
}

int fnd(int x)
{
    return p[x]==x?p[x]:p[x]=fnd(p[x]);
}

void unite(int x,int y)
{
    int px=fnd(x),py=fnd(y);

    if(px!=py)
    {
        p[px]=py;
    }
}

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

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

    init(n);

    while(q--)
    {
        int op,x,y;
        cin>>op>>x>>y;

        if(!op)
        {
            unite(x,y);
        }else
        {
            cout<<same(x,y)<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3140
#include <stdio.h>

int main(void)
{
	long H,W;
	scanf("%ld%ld", &H,&W);
	long i;
	long j;
	long height = 0;
	long width = 0;
	long sum = 0;
	// while (i < W)
	// {
	// 	j = 0;
	// 	while (j < H)
	// 	{
	// 		if (i % 2 == 0 && j % 2 == 0)
	// 			rep++;
	// 		else if (i % 2 && j % 2)
	// 			rep++;
	// 		j++;
	// 	}
	// 	i++;
	// }
	if (H == 1 || W == 1)
	{
		printf("%d", 1);
		return 0;
	}
	if (H % 2 == 0 && W % 2 == 0)
	{
		height = (H / 2);// 4 / 2 = 2
		width = (W / 2); // 
		sum = (height * width) * 2;
	}
	if (H % 2 && W % 2)
	{
		sum = (H / 2) * W;
		sum += (W / 2 + 1);
	}
	if (H % 2 == 0 && W % 2)
		sum = (H / 2) * W;
	if (H % 2 && W % 2 == 0)
		sum = (W / 2) * H;
	printf("%ld", sum);
	return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (ll i = 0; i < n; i++)
#define forr(i,a,b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const ll MX = 150005;
const ll inf = 1e9;
#define tam 1234567
int dp[tam][10];
int N;
string txt;

int f(int pos,int last)
{
    if (pos==N)
        return last;
    if(dp[pos][last]!=-1)
        return dp[pos][last];
    int res=1e9,num=txt[pos]-'0';

    if (last==0)
    {
        res=f(pos+1,(10-num)%10)+1+(num==0);
        res=min(res,f(pos+1,0)+num);
    }
    else
    {
        res=f(pos+1,(10-num)%10)+last-1+(num==0);
        res=min(res,f(pos+1,0)+last+num);
    }
    return dp[pos][last]=res;
}

int main () 
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>txt;
    memset(dp,-1,sizeof dp);
    N=txt.size();
    cout<<f(0,0)<<endl;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    ll ans = 0, n;
    cin >> n;
    vector<ll> v;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    for(ll i = 0; i < n; i++)
    {

        for(ll j = i+1; j < n; j++)
        {

            ans+=v[i]*v[j];
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <cstdio>
#include <math.h>
#include <utility>
#include <list>
#include <functional>
using namespace std;

#define ll long long
#define vecint vector<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007
#define NIL -1

ll N;
ll X;

void solve(){

  ll height=N-X;
  ll width=X;
  ll ans=0;
  ll i;

  while(height>0&&width>0){
    ll c=min(height,width);
    if(height>=width){
      i=(height-width)/c+1;
      height-=c*i;
    }else{
      i=(width-height)/c+1;
      width-=c*i;
    }
    ans+=3*i*c;
  }
  print(ans);
}

int main(){
  cin>>N>>X;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
    using namespace std;
     
    int main() {
    	long A,B,m,n,temp;
    	cin >> A >> B;
        m=A;
        n=B;
		while (m % n != 0)
		{
			temp = n;
			n = m % n;
			m = temp;
		}
      
      cout << A/n*B << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string n;
ll k;
ll dp[110][110][2];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>k;
    rep(i,110){
        rep(j,4){
            rep(l,2){
                dp[i][j][l] = 0;
            }
        }
    }
    dp[1][1][1]=n[0]-'0'-1;
    dp[1][1][0]=1;
    dp[1][0][1]=1;

    repi(i,1,n.size()){
        rep(j,k+1){
            rep(l,2){
                if(dp[i][j][l]!=0){
                    ll now = dp[i][j][l];
                    if(j==k){
                        dp[i+1][j][l]+=now;
                    }else if(l==0){
                        if(n[i]=='0'){
                            dp[i+1][j][0] += now;
                            continue;
                        }
                        dp[i+1][j+1][1] += now *(n[i]-'0'-1);
                        dp[i+1][j][1] += now;
                        dp[i+1][j+1][0] += now;
                    }else{
                        dp[i+1][j+1][1] += now*9;
                        dp[i+1][j][1] += now;
                    }
                }
            }
        }
    }
    print(dp[n.size()][k][0]+dp[n.size()][k][1]);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int> >cost(n,vector<int>(n));
	rep(i,n)rep(j,n)cost[i][j]=inf;
	int a,b,c,e;char x;
	rep(i,m){
		cin>>a>>x>>b>>x>>c>>x>>e;
		a--;b--;
		cost[a][b]=c;
		cost[b][a]=e;
	}
	cin>>a>>x>>b>>x>>c>>x>>e;
	a--;b--;
	vector<bool>used(n);
	vector<int>d(n,inf);
	d[a]=0;
	while(1){
		int v=-1;
		rep(i,n)if(!used[i]&&(v==-1||d[v]>d[i]))v=i;
		if(v==-1)break;
		used[v]=true;
		rep(i,n)d[i]=min(d[i],d[v]+cost[v][i]);
	}
	c-=d[b];
	rep(i,n){used[i]=false;d[i]=inf;}
	d[b]=0;
	while(1){
		int v=-1;
		rep(i,n)if(!used[i]&&(v==-1||d[v]>d[i]))v=i;
		if(v==-1)break;
		used[v]=true;
		rep(i,n)d[i]=min(d[i],d[v]+cost[v][i]);
	}
	c-=d[a];
	cout<<c-e<<endl;
	
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <stdlib.h>
int main(){
int n;
scanf("%d\n",&n);
char *s=malloc(n*sizeof(char));
scanf("%s",s);
int c=0;
int l=-1;
for(int i=0;i<n;i++){
char n=s[i];
if(n!=l){
l=n;
c++;
}
}
printf("%d",c);
return 0;
}

Measured memory_bytes: 256
//バイナリハックイージー

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    string s;cin>>s;
    string t;
    rep(i,0,s.size()){
        if(s[i]=='B'){
            if(t.empty())continue;
            t.erase(t.size()-1,1);
            continue;
        }
        t+=s[i];
    }
    cout<<t<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll k;
int main(){
	cin>>k;
	ll a[55];
	for(int i=0;i<50;i++) a[i] = i+k/50;
	for(int i=0;i<k%50;i++){
		a[0]+=50LL;
		for(int i=1;i<50;i++) a[i]--;
		sort(a,a+50);
	}
	cout << 50 << endl;
	for(int i=0;i<50;i++){
		cout << a[i] << (i==49?'\n':' ');
	}
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include <time.h>
#include<map>
#include<set>
#include<algorithm>
#include<vector>
#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;


int main() {
   
    int m,d;
    cin>>m>>d;
    int ans=0;
    for(int i=22;i<=d;i++)
    {
        if(i%10<2)
            continue;
        for(int j=1;j<=m;j++)
        {
            if(j==(i%10)*(i/10%10))
                ans++;
        }
    }
    cout<<ans;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	vector<long long> T(N,0);
	vector<long long> A(N,0);
	int i;
	for (i=0;i<N;i++){
		cin>>T[i]>>A[i];
	}
	for (i=1;i<N;i++){
		long long c1=1,c2=1;
		if (T[i]<T[i-1]){
			c1=T[i-1]/T[i];
			if (T[i-1]%T[i]!=0){
				c1++;
			}
		}
		if (A[i]<A[i-1]){
			c2=A[i-1]/A[i];
			if (A[i-1]%A[i]!=0){
				c2++;
			}
		}
		c1=max(c1,c2);
		T[i] = T[i]*c1;
		A[i] = A[i]*c1;
	}
	cout<<T[N-1]+A[N-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		int max_i = 0;
		int max = 0;
		int second_i = 0;
		int second = 0;
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		    if(a[i] >= max){
		        second = max;
		        second_i = max_i;
		        max = a[i];
		        max_i = i;
		    }else if(a[i] >= second){
		        second = a[i];
		        second_i = i;
		    }
		}
		
		// 計算
		
		// 出力
		for(int i = 0; i < n; i++){
		    if(i == max_i){
                System.out.println(a[second_i]);
		    }else{
		        System.out.println(a[max_i]);
		    }
		}
	}

}


Measured memory_bytes: 87136
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long 
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi <vector<vector<vector<int>>> 
#define vc vector<char> 
#define vvc vector<vector<char>>
#define vvvc vector<vector<vector<char>>> 

using namespace std;

int main() {
	int n, k;
	int p = 1;
	cin >> n >> k;
	rep(i, 0, n) {
		if (p * 2 - p > p + k - p) p += k;
		else p *= 2;
	}

	cout << p << endl;

	return 0;
}


Measured memory_bytes: 256
import math
def make_divisors(m, n):
    divisors = []
    numi = min(m, n)
    numa = max(m, n)
    for i in range(1, int(math.sqrt(numi)) + 1):
        if numi % i == 0:
            if numa % i == 0:
                divisors.append(i)
            # √nで無い数についてもう一個プラス
            if i != numi // i and numa % (numi // i) == 0:
                divisors.append(numi // i)
    return sorted(divisors)

a, b = map(int, input().split())
lista = make_divisors(a, b)
listb = [1]
lista.pop(0)
while len(lista) > 0:
    listb.append(lista[0])
    lista = [i for i in lista if i % lista[0] != 0]
print(len(listb))

Measured memory_bytes: 39408
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, h[MAXN], a[MAXN];
LL ans, t[MAXN];

LL query(int x)
{
    LL sum=0;
    for(; x; x-=(x&-x)) sum=max(sum, t[x]);
    return sum;
}

void add(int x, LL y)
{
    for(; x<=n; x+=(x&-x)) t[x]=max(t[x], y);
}


int main()
{
    scanf("%d", &n);
    for(rint i=1; i<=n; ++i) scanf("%d", &h[i]);
    for(rint i=1; i<=n; ++i) scanf("%d", &a[i]);
    for(rint i=1; i<=n; ++i)
    {
        LL temp=query(h[i]);
        add(h[i], temp+a[i]);
        ans=max(ans, temp+a[i]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> G[100010];

int color[100010];

// 頂点を1と-1で塗っていく
bool dfs(int v, int c) {
    color[v] = c;
    for (int i = 0; i < G[v].size(); i++) {
        // 隣接している頂点が同じ色ならfalse
        if (color[G[v][i]] == c) return false;
        // 隣接している頂点がまだ塗られていないなら-cで塗る
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }

    // すべての頂点を塗れたらtrue
    return true;

}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    if(dfs(0, 1)) {
        int k1 = 0, k2 = 0;
        rep(i, 100010) {
            if (color[i] == 1) k1++;
            else if (color[i] == -1) k2++;
        }
        cout << k1 * k2 - M << endl;
    } else {
        cout << N * (N - 1) / 2 - M << endl;
    }



    return 0;
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 300001
int mod=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
void solve()
{
    int n; cin>>n;
    vector<int> dp(n+1);
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
        dp[j]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    ans+=i*dp[i];
    cout<<ans<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1; //cin>>test;
    int x=1;
    while(test--)
    {
        //cout<<"Case #"<<x++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 81332
def resolve():

    n = int(input())

    list_t = [0] * 100010
    list_x = [0] * 100010
    list_y = [0] * 100010

    for i in range(n):
        list_t[i], list_x[i], list_y[i] = map(int, input().split())

    for i in range(n):

        if i == 0:
            delta_t = list_t[i]
            delta_xy = list_x[i] + list_y[i]

        else:
            delta_t = list_t[i] - list_t[i-1]
            delta_xy = abs(list_x[i] + list_y[i] - list_x[i-1] - list_y[i-1])

        if delta_t < delta_xy:
            print('No')
            return

        if delta_t % 2 != delta_xy % 2:
            print('No')
            return

    print('Yes')
    
resolve()

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

struct Arc { int to, d; };

int N, M;
vector< vector< Arc > > arc;

void solve() {
	vector< int > indeg(N, 0);
	for (int v=0; v<N; ++v) for (const Arc& a : arc[v]) indeg[a.to]++;
	
	vector< int > x(N, -1);
	queue< int > que;
	for (int v=0; v<N; ++v) {
		if (indeg[v] == 0) {
			que.push(v);
			x[v] = 0;
		}
	}
	
	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (const Arc& a : arc[v]) {
			if (x[a.to] == -1) {
				x[a.to] = x[v] + a.d;
			} else {
				if (x[a.to] != x[v] + a.d) {
					puts("No");
					return;
				}
			}
			--indeg[a.to];
			if (indeg[a.to] == 0) que.push(a.to);
		}
	}
	
	if (find(x.begin(), x.end(), -1) != x.end()) puts("No");
	else puts(*max_element(x.begin(), x.end()) <= (int)1e9 ? "Yes" : "No");
}

int main() {
	cin >> N >> M;
	arc.assign(N, vector< Arc >());
	
	for (int i=0; i<M; ++i) {
		int L, R, D;
		cin >> L >> R >> D;
		--L; --R;
		arc[L].push_back(Arc{R, D});
	}
	
	solve();
}

Measured memory_bytes: 6784
#include<stdio.h>
#include<math.h>

int sosu(int num){
	int i,j;
	int flag=0;
	int ans=1;
	
	for(i=3;i<=num;i+=2){
		for(j=3;j<=sqrt(num);j+=2){
			if(i==j)j++;
			if(i%j==0){
				flag=1;
				break;
			}
		}
	if(flag==0)ans++;
	flag=0;
	}
	return ans;
}

int main(){
	int num;
	int ans=0;
	int i,j,k;
	int box[1000000];
		
	while(scanf("%d",&num)!=EOF){
		
		for(i=2;i<=num;i++)box[i]=1;
		
		for(i=2;i<=sqrt(num);i++){
			if(box[i]==1){
				for(j=2;i*j<=num;j++){
					box[i*j]=0;
				}
			}
		}
		for(i=0;i<=num;i++)if(box[i]==1)ans++;
		printf("%d\n",ans);
		ans=0;
	}
	return 0;
}

Measured memory_bytes: 4928
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int a = scan.nextInt();
	int b = scan.nextInt();

	int ans = 0;
	if(a <= 5){
	    ans = 0;
	}else if(a <= 12){
	    ans = b/2;
	}else{
	    ans = b;
	}

	System.out.println(ans);
    }
}



Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    map<int64_t,int64_t> mp;
    int64_t ans = 0;
    for(int i=0; i<N; i++) {
        int A;
        cin >> A;
        ans += A;
        mp[A]++;
    }

    int Q;
    cin >> Q;
    while(Q--) {
        int B, C;
        cin >> B >> C;
        ans += C*mp[B] - B*mp[B];
        mp[C] += mp[B];
        mp[B] = 0;
        cout << ans << endl;
    }
    return 0;
}


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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    REP(i,n)cin >> x[i];

    int ans = 0;
    REP(i,n){
        int m = INF;
        chmin(m,x[i]);
        chmin(m,k - x[i]);
        ans += (m * 2);
    }

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;

  string S;
  cin >> S;
  
  for( int i = 1; i < S.size(); i++ ){
    if( S.at(i) == S.at(i-1) ){
      S.erase(i, 1);
      i--;
    }
  }
  
  cout << S.size() << endl;
  
  
  
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, l;
  cin >> n >> l;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n-1) {
    if (a[i]+a[i+1] >= l) {
      cout << "Possible" << endl;
      rep(j, i)
        cout << j+1 << endl;
      for (int j = n-2; j >= i; j--)
        cout << j+1 << endl;
      return 0;
    }
  }
  cout << "Impossible" << endl;
  return 0;
}

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



int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<int>> vc(h, vector<int>(w, 0));
    vector<string> s(h);
    for(int i = 0; i < h; i++) cin>>s[i];

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                vc[i][j] = -1;
                for(int dy = -1; dy <= 1; dy++){
                    for(int dx = -1; dx <= 1; dx++){
                        int ny = dy + i;
                        int nx = dx + j;
                        if(ny>=0 && ny<h &&
                           nx>=0 && nx<w &&
                           vc[ny][nx]>=0){
                            vc[ny][nx]++;
                        }
                    }
                }
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(vc[i][j] == -1) cout << '#';
            else cout << vc[i][j];
        }
        cout << endl;
    }
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
/*
 * Be careful of overflow
 * Array bounds
 * Assert a!=0 when performing x/a
 * Check base condition for recursion
 * Iterator -> O(1), Element -> O(log n) while using erase
 * 1LL<<x when x>32
 * Be sure of what you are going to code (exception dp)
 * Don't try fancy tricks during contest
 * You can always make a bad round to a good enough round
 */ 

int l[110];
void solve()
{
	int n,i,j,k;
	ll cnt=0;
	cin>>n;
	for(i=0;i<n;i++) cin>>l[i];
	sort(l,l+n);
	for(i=0;i<n;i++)
	for(j=i+1;j<n;j++)
	for(k=j+1;k<n;k++)
	if(l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k] && l[i]+l[j]>l[k]) cnt++;
	cout<<cnt<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3648
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;

//namespace mp = boost::multiprecision;
int main() 
{
	ll l,r;
	cin>>l>>r;
	r=min(r,l+4038);
	ll ans=2018;
	for(ll i=l;i<=r;i++)
	{
		for(ll j=i+1;j<=r;j++)
		{
			ll now=(i*j)%2019;
			ans=min(ans,now);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

bitset<N * N>s;
int a[N],t[N * N];
int n,sum,cnt;

inline int read(){
	int x = 0,f = 1;char c = getchar();
	while(!isdigit(c)){if(c == '-')f = -1;c = getchar();}
	while(isdigit(c)){x = x * 10 + c - '0';c = getchar();}
	return f * x;
}

int main(){
	n = read();
	fr(i,1,n)a[i] = read(),sum += a[i];
	s[0] = 1;
	fr(i,1,n)s |= (s << a[i]);
	fr(i,1,sum)if(s[i])t[++cnt] = i;
	printf("%d",t[(cnt + 1) / 2]);
	return 0;
}

Measured memory_bytes: 9856
H,W = map(int, raw_input().split())
ans = 10**10

s = [0]*3
for i in range(1,H):
    s[0] = i*W
    s[1] = (H-i)*(W/2)
    s[2] = (H-i)*((W+1)/2)
    s.sort()
    ans = min(ans, s[2]-s[0])

for i in range(1,W):
    s[0] = i*H
    s[1] = (W-i)*(H/2)
    s[2] = (W-i)*((H+1)/2)
    s.sort()
    ans = min(ans, s[2]-s[0])

if H>=3:
    ans = min(ans, 0 if H%3==0 else W)

if W>=3:
    ans = min(ans, 0 if W%3==0 else H)

print ans


Measured memory_bytes: 5876
n, m = map(int, input().split())
g = [[] for i in range(n)]
for _ in range(m):
    a, b = map(lambda x:int(x) - 1, input().split())
    g[a].append(b)
    g[b].append(a)

def dfs(s, path):
    if len(path) == n:
        return 1
    cnt = 0
    for next in g[s]:
        if next in path:
            continue
        cnt += dfs(next, path + [next])
    return cnt

print(dfs(0, [0]))

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N, K; cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];

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

    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += p[i];
    }

    cout << sum << endl;
}


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

Measured memory_bytes: 3632