akhauriyash/Code-Regression huggingface dataset:
d,g= map(int, input().split())
x = [list(map(int, input().split())) for i in range(d)]
ans2=float('inf')

for i in range(2**d):
    v=[0]*d
    ans=0
    ans1=0
    for j in range(d):
        if (i>>j)&1==1:
            ans+=(x[j][0]*100*(j+1))+x[j][1]
            ans1+=x[j][0]
            v[j]=1


    if ans<g:
        for k in range(d):
            if v[d-k-1]==0:
                if g-ans<=(x[d-k-1][0]-1)*100*(d-k):
                    w=-(-(g-ans)//(100*(d-k)))

                    ans2=min(ans2,ans1+w)
                else:
                    break
    else:
        ans2=min(ans2,ans1)
print(ans2)

Measured memory_bytes: 3064
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  let
    f :: [Int] -> (Int, Int)
    f = foldl step (0, 0)
      where
        step :: (Int, Int) -> Int -> (Int, Int)
        step (s, m) x = (s', m')
          where
            m' = m `max` x :: Int
            d = m' - x :: Int
            s' = s + d :: Int
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print . fst . f $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 17688
for i in range(int(input())):
    res = 0
    c,a,n = list(map(int,input().split()))
    res = min(n,a,c)
    c -= res
    a -= res
    if c >= 2 and a >= 1:
        cca = min(c//2,a)
        c -= cca*2
        res += cca

    if c >=3:
        res += c//3

    print(res)

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

int main() {
    int n, k; scanf("%d%d", &n, &k);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i + k - 1 <= n)
            ++ans;
    }
    printf("%d\n", ans);
}


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

const int n_max=111;

ll C[n_max+1][n_max+1];

void comb_table(int N){
  for(int i=0;i<=N;i++){
    for(int j=0;j<=i;j++){
      if(j==0||j==i){
        C[i][j]=1LL;
      }else{
        C[i][j]=(C[i-1][j-1]+C[i-1][j]);
      }
    }
  }
}


int main(){
  comb_table(n_max);
  int N,P; cin>>N>>P;
  int ki=0,gu=0;
  rep(i,N){
    int a; cin>>a;
    if(a%2==0) gu++;
    else ki++;
  }
  ll ans=(P==0)?1:0;
  if(P==0) for(int i=2;i<=ki;i+=2) ans+=C[ki][i];
  else for(int i=1;i<=ki;i+=2) ans+=C[ki][i];
  ans<<=gu;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
P = list(map(int, input().split()))


kitaiti = {}

k = 1.0
for i in range(1, 1001):
    kitaiti[i] = k
    k += 0.5

index = 0

for i in range(K):
    index += kitaiti[P[i]]

s = index
ans = index

for i in range(1, len(P)-K+1):
    s = index - kitaiti[P[i-1]] + kitaiti[P[i+K-1]]
    if s > ans: ans = s
    index = s
print(ans)



Measured memory_bytes: 71792
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
cost = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (n + 10)
dp[0] = 0

for i in range(n):
    for ai in a:
        if dp[i] >= 0:
            dp[i + cost[ai]] = dp[i] + 1

ans = []
i = n
while dp[i] > 0:
    for ai in a:
        if dp[i - cost[ai]] == dp[i] - 1:
            ans.append(str(ai))
            i -= cost[ai]
            break

print(''.join(ans))

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0, 0,-1,1,-1, 1,-1};
int dy[]={0,1,-1, 0,1,-1,-1, 1};


int main(){
    int n;cin >> n;
    string s;cin >> s;
    vector<bool> f(n,false);
    for (int i = 0; i < n-1; i++) {
        if(s[i] == '0' && s[i+1] == '0'){
            f[i] = f[i+1] = true;
        }
    }
    vector<string> v;
    string t="";
    for (int i = 0; i < n; i++) {
        if(f[i]){
            if(t!=""){
                v.pb(t);
                t = "";
            }
        }
        else{
            t += s[i];
        }
        if(i==n-1&&t!=""){
            v.pb(t);
        }
    }
    int ans = 0;
    for(auto vp:v){
        vector<int> a,b;
        int N = vp.size();
        for (int i = 0; i < N; i++) {
            if(vp[i] == '0'){
                int cnta = 0,cntb = 0;
                for (int j = i-1; j >= 0; j--) {
                    if(vp[j] == '0') break;
                    else cnta++;
                }
                for (int j = i+1; j < N; j++) {
                    if(vp[j] == '0') break;
                    else cntb++;
                }
                if(cnta&&cntb){
                    a.pb(cnta);
                    b.pb(cntb);
                }
            }
        }
        int sz = a.size();
        vector<vector<vector<int>>> dp(sz+1,vector<vector<int>> (3,vector<int>(2,0)));
        for (int i = 0; i < sz; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 2; k++) {
                    chmax(dp[i+1][0][0], dp[i][j][k]);
                }
                chmax(dp[i+1][2][b[i]==1], dp[i][j][0] + b[i] - 1);
                chmax(dp[i+1][2][1], dp[i][j][0] + b[i]);
            }
            chmax(dp[i+1][1][b[i]==1], dp[i][0][0] + a[i]);
            chmax(dp[i+1][1][b[i]==1], dp[i][1][0] + (a[i] - 1));
        }
        int mx = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 2; j++) {
                chmax(mx,dp[sz][i][j]);
            }
        }
        ans += mx;
    }
    cout << ans << endl;
    return 0;
}


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

struct dorinku {
	long long int A;
	int B;
};

int asc(const void *a, const void *b) {
	struct dorinku *x = (struct dorinku *)a;
	struct dorinku *y = (struct dorinku *)b;
	if (x->A > y->A) return 1;
	if (x->A < y->A) return -1;
	return 0;
}

int main() {
	int N, M, i;
	long long int sum = 0;
	struct dorinku AB[100000];

	scanf("%d %d", &N, &M);
	for (i = 0; i < N; i++) {
		scanf("%lld %d", &AB[i].A, &AB[i].B);
	}

	qsort(AB, N, sizeof(struct dorinku), asc);

	for (i = 0; M > 0; i++) {
		if (M >= AB[i].B) {
			M = M - AB[i].B;
			sum = sum + AB[i].A * AB[i].B;
		}
		else {
			sum = sum + M * AB[i].A;
			M = 0;
		}
	}

	printf("%lld", sum);

	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, cnt = 0;
    cin >> N;
    vector<int> A(N);
    for (int& i : A) cin >> i;
    cout << (count_if(A.begin(), A.end(), [](int a) { return a % 2; }) % 2 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <cstdlib>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string str;
    cin >> str;
    string str_;
    cin >> str_;

    int sz = str.size();
    int sz_ = str_.size();
    if(sz != sz_-1){
        cout << "No";
        return 0;
    }

    str_.erase(sz_-1);

    if(str_ == str){
        cout << "Yes";
        return 0;
    }else{
        cout << "No";
        return 0;
    }


    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>

int main()
{
    int a,b,i,j,sum;
    scanf("%d %d",&a,&b);
    if(a<b){

        for(i=0,j=1,sum;i<b;i++,j=j*10){
            sum = sum + a*j;
        }
        printf("%d\n",sum);
    }
    else{
        for(i=0,j=1,sum;i<a;i++,j=j*10){
            sum = sum + b*j;
        }
        printf("%d\n",sum);
    }

    return 0;
}

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

int main(){
  char a;
  cin >> a;
  string b = "aiueo";
  for (int i=0; i<5; i++){
    if (a==b[i]){
      cout << "vowel" << endl;
      exit(0);
    }
  }
  cout << "consonant" << endl;

}

Measured memory_bytes: 256
k=int(input())
if k==7:
    print(1)
    exit()
if k%7==0:
    k//=7

x=9
for i in range(1,9000000):
    if x%(9*k)==0:
        print(i)
        exit()
    x%=(9*k)
    x*=10
    x+=9
print(-1)



Measured memory_bytes: 80036
#include<cstdio>
#include<cstring>
using namespace std;
char s[25];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++)
		if(s[i]==',') putchar(' ');
		else printf("%c",s[i]);
	putchar('\n'); 
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <bit>
#include <bitset>
// #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);
	vector<int> values(n);

	rep(i, n)
	{
		cin >> p[i];
	}
	rep(i, n)
	{
		cin >> q[i];
	}

	rep(i, n)
	{
		values[i] = i + 1;
	}

	int index = 1;
	int aIndex = -1;
	int bIndex = -1;

	do
	{
		bool oka = true;
		bool okb = true;

		// for (auto i = values.begin(); i != values.end(); ++i)
		// 	std::cout << *i << ' ';

		cout << endl;
		rep(i, n)
		{
			if (values[i] != p[i])
			{
				oka = false;
			}

			if (values[i] != q[i])
			{
				okb = false;
			}
		}

		if (oka)
		{
			aIndex = index;
		}

		if (okb)
		{
			bIndex = index;
		}

		index++;

	} while (next_permutation(values.begin(), values.end()));

	cout << abs(aIndex - bIndex) << endl;
}
//g++ -std=c++17 -g main.cpp -o mai	n

Measured memory_bytes: 3128
a, b, k = list(map(int, input().split()))
if b - a + 1 > 2 * k:
    [print(i) for i in range(a, a + k)]
    [print(i) for i in range(b - k + 1, b + 1)]
else:
    [print(i) for i in range(a, b + 1)]

Measured memory_bytes: 3060
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N,X,T = inm()

a = N//X

if N%X != 0:
    print(a*T+T)
else:
    print(a*T)



Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> g[100000];
int dist[2][100000],id;

void dfs(int idx,int par =-1){
	if(par!=-1)dist[id][idx]=dist[id][par]+1;
	for(int j=0;j<g[idx].size();j++)if(g[idx][j]!=par)dfs(g[idx][j],idx);
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		--a;
		--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	id=0;
	dfs(0);
	id=1;
	dfs(n-1);
	int ret=0;
	for(int i=0;i<n;i++){
		if(dist[0][i]<=dist[1][i])++ret;
	}
	if(ret>=(n+2)/2)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> H) {
  ll prev = H[N - 1];
  rep1(i, N) {
    if (prev - H[N - i - 1] < 0) {
      if (prev - (H[N - i - 1] - 1) == 0) {
        H[N - i - 1]--;
      } else {
        cout << NO << endl;
        return;
      }
    }

    prev = H[N - i - 1];
  }
  cout << YES << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


Measured memory_bytes: 1024
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
  for j in range(i+1, N):
    A = L[i] + L[j]
    highbound = bisect_left(L, A)
    ans += highbound - j - 1    
print(ans)

Measured memory_bytes: 3188
import sys
def input():
	return sys.stdin.readline().strip()


X, Y = list(map(int, input().split()))

if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:
	print(0)
	exit()

times = (X + Y) // 3

times2 = X - times


def fact(n, mod=1000000007):
	ans = 1
	for i in range(n):
		ans *= i + 1
		if mod != 0 and ans >= mod:
			ans = ans % mod
	return ans


def mod_rev(x, mod):

	return pow(x, mod - 2, mod)



def comb(a, b, mod=1000000007):
	"""
	関数mod_rev, fact, powが必要
	"""
	if a < b or b < 0:
		return 0
	if a == b or b == 0:
		return 1
	a_fact = fact(a, mod)
	b_fact = fact(b, mod)
	a_b_fact = fact(a - b, mod)
	if mod != 0:
		return (a_fact * mod_rev(b_fact, mod) * mod_rev(a_b_fact, mod))%mod
	else:
		return a_fact//(b_fact*a_b_fact)

mod = 10**9 + 7

print(comb(times, times2, mod))

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

using namespace std;
typedef long long ll;
const int maxN = 2e5 + 100;
int n;
ll k;
ll a[maxN];
ll pref[maxN];
int f[maxN];
void upd(int v) {
    while (v < maxN) {
        f[v]++;
        v = (v | (v - 1)) + 1;
    }
}
int get(int v) {
    int ans = 0;
    while (v > 0) {
        ans += f[v];
        v &= (v - 1);
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    vector < pair < ll, int > > all;
    vector < ll > cords;
    for (int i = 0; i <= n; i++) {
        all.emplace_back(pref[i] - k * i, i);
    }
    sort(all.begin(), all.end());
    ll cnt = 0;
    for (auto it : all) {
        cnt += get(it.second + 1);
        upd(it.second + 1);
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 9456
N = int(input())
A = list(map(int,input().split()))
dic = {i:0 for i in range(1,N+1)}
for i in range(N):
    dic[A[i]] = i + 1
ans = []
#print(dic)
for i in dic.keys():
    ans.append(str(dic[i]))
print(' '.join(ans))

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

int main(){
  long long x,a,b,c,d,ansa,ansb;
  cin>>x>>a;
  if(x!=1&&a!=1){
    cout<<1<<endl;
  }
  else   if(x!=2&&a!=2){
    cout<<2<<endl;
  }
  else{
    cout<<3<<endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int a, b, c;

int calc(int x, int y, int z) {
    int m = max(x, max(y, z));
    return (m - x) / 2 + (m - y) / 2 + (m - z) / 2;
}

int solve() {
    if (a % 2 == b % 2 && b % 2 == c % 2) return calc(a, b, c);
    if (a % 2 == b % 2) return calc(a+1, b+1, c)+1;
    if (a % 2 == c % 2) return calc(a+1, b, c+1)+1;
    return calc(a, b+1, c+1)+1;
}

void input() {
    cin >> a >> b >> c;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<stack>
#include<string.h>
#include<map>
#include<set>
#include<deque>
#include<queue>
#include<list>
#include<bitset>
#include<sstream>

#define ln 1e6
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1000000000
#define ll long long

#define sortvac(a,b) sort(akash.begin(),akash.end())
#define sortvdc(a,b) sort(akash.begin(),akash.end(),greater<int>())

#define sortaac(a,b) sort(arr,arr+b)
#define sortadc(a,b) sort(arr,arr+b,greater<int>())

#define searchv(data) binary_search(akash.begin(),akash.end(),data)
#define searcha(data) binary_search(arr,arr+b,data)

#define reversev(akash) reverse(akash.begin(),akash.end())
#define reversea(arr) reverse(arr,arr+b)

#define removev(data) remove(akash.begin(),akash.end(),data);
#define removea(data) remove(arr,arr+b,data);

#define maxv(akash) *max_element(akash.begin(),akash.end())
#define maxa(arr) *max_element(arr,arr+b)

#define minv(akash) *min_element(akash.begin(),akash.end())
#define mina(arr) *min_element(arr,arr+b)

#define fori(i,a,b) for(int i=0;i<b;i++)
#define ford(i,a,b) for(int i=b-1;i>=0;i--)

using namespace std;

int main()
{
    ll a,b,c,k,total=0;
    cin>>a>>b>>c>>k;
    
    for(int i=0;i<a;i++){
        total++;
        k--;
        
        if(k==0){
            cout<<total<<"\n";
            return 0;
        }
    }
    for(int i=0;i<b;i++){
        k--;
        
        if(k==0){
            cout<<total<<"\n";
            return 0;
        }
    }
    for(int i=0;i<c;i++){
        total--;
        k--;
        
        if(k==0){
            cout<<total<<"\n";
            return 0;
        }
    }
    
    return 0;
}







     



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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define all(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COUT(x) cout << x << endl
//#define int long long

template<typename T> constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

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

	VI A(N);
	rbf(a, A) {
		cin >> a;
	}

	VI B = A;
	sort(B.begin(), B.end(), greater<int>());
	const int max = B[0], max2 = B[1];

	rbf(a, A) {
		if (a == max) COUT(max2);
		else COUT(max);
	}

	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#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 << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> t(n);
	int sum = 0;
	rep(i,n) {
		cin >> t[i];
		sum += t[i];
	}
	int m;
	cin >> m;
	vector<P> p(m);
	int a,b;
	rep(i,m){
		cin >> a >> b;
		a--;
		p[i] = mp(a,b);
	}
	rep(i,m){
		cout << sum - t[p[i].first] + p[i].second << endl;
	}
    return 0;
}

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

#define int long long
const int _ = 2003;
int X[_] , Y[_] , len[_] , N , M , all , sum;

void work(int p , int q){
	int x = p + q , y = p - q , nposx = (all + x) / 2 , nposy = (all + y) / 2;
	for(int i = 0 ; i < M ; ++i){
		int flgx = (nposx >> i & 1) || nposx == all , flgy = (nposy >> i & 1) || nposy == all;
		switch(flgx * 2 + flgy){
		case 3: putchar('R'); break;
		case 2: putchar('U'); break;
		case 1: putchar('D'); break;
		case 0: putchar('L'); break;
		}
	}
}

signed main(){
	cin >> N;
	for(int i = 1 ; i <= N ; ++i){
		cin >> X[i] >> Y[i]; all = max(all , max(abs(X[i] + Y[i]) , abs(X[i] - Y[i])));
		if(i != 1 && ((X[i] + Y[i] + X[i - 1] + Y[i - 1]) & 1)){puts("-1"); return 0;}
	}
	int sum = 0; for(int i = 0 ; sum <= all ; ++i) sum += (len[++M] = 1 << i);
	if((all - sum) & 1){len[++M] = 1; ++sum;}
	all = sum; printf("%lld\n" , M);
	for(int i = 1 ; i <= M ; ++i) printf("%lld " , len[i]);
	putchar('\n'); for(int i = 1 ; i <= N ; ++i , putchar('\n')) work(X[i] , Y[i]);
	return 0;
}

Measured memory_bytes: 256
n,s=map(int,input().split())
*A,=map(int,input().split())
mod=998244353
dp=[[0]*(s+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(s+1):
        if A[i]+j<s+1:
            dp[i+1][j+A[i]]=(dp[i+1][j+A[i]]+dp[i][j])%mod
        dp[i+1][j]=(dp[i+1][j]+2*dp[i][j])%mod
print(dp[-1][-1])

Measured memory_bytes: 138980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[2]-a[0]<<endl;
	return 0;
}

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

const long double pi = 3.141592653589793;

int main(){
    long double a, b, h, m;
    std::cin >> a >> b >> h >> m;
    long double zi_th, hun_th;
    zi_th = 30.0 * h + 0.5 * m;
    hun_th = 6.0 * m;
    long double th = std::min(std::fabs(zi_th - hun_th), std::fabs(360.0 - std::fabs(zi_th - hun_th)));
    long double c = std::sqrt(a * a + b * b - 2.0 * a * b * cos((pi * th) / 180.0));
    printf("%.10Lf\n", c);
    return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  vector<int> a(3 * N);
  for (int i = 0; i < 3 * N; i++) {
    cin >> a[i];
  }

  vector<long long> m_f(N + 1);
  {
    long long sum = 0;
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0; i < N; i++) {
      sum += a[i];
      pq.push(a[i]);
    }
    m_f[0] = sum;
    for (int i = N; i < 2 * N; i++) {
      int m_in_sum = pq.top();
      if (m_in_sum < a[i]) {
        sum -= m_in_sum;
        sum += a[i];
        pq.pop();
        pq.push(a[i]);
      }
      m_f[i + 1 - N] = sum;
    }
  }

  vector<long long> m_b(N + 1);
  {
    priority_queue<int> pq;
    long long sum = 0;
    for (int i = 2*N; i < 3*N; i++) {
      sum += a[i];
      pq.push(a[i]);
    }
    m_b[N] = sum;
    for (int i = 2 * N - 1; i >= N; i--) {
      int m_in_sum = pq.top();
      if (m_in_sum > a[i]) {
        sum -= m_in_sum;
        sum += a[i];
        pq.pop();
        pq.push(a[i]);
      }
      m_b[i - N] = sum;
    }
  }

  long long ret = -1e18;
  for (int i = 0; i <= N; i++) {
    ret =  max(ret, m_f[i] - m_b[i]);
  }
  cout << ret << endl;

  return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;

  bool sign = true; // Positive
  if(a < 0){
    sign = sign != ((-a) % 2 == 1);
  }
  if(b + 1 < 0){
    sign = sign != ((-( b + 1)) % 2 == 1);
  }

  if(a <= 0 && b >= 0){
    cout << "Zero" << endl;
  }else if(sign){
    cout << "Positive" << endl;
  }else{
    cout << "Negative" << endl;
  }
}



Measured memory_bytes: 508
#include <stdio.h>

int main()
{
    int a=0,b=0,c=0,menor=0;
    scanf("%d%d%d",&a,&b,&c);
    if(c>=a && c>=b)
    {
        menor=a+b;
    } else if(a>=c && a>=b)
    {
        menor=c+b;
    } else if(b>=a && b>=c)
    {
        menor=a+c;
    }

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


    return 0;
}


Measured memory_bytes: 128
//! Generic utility for reading data from standard input, based on [voxl's
//! stdin wrapper](http://codeforces.com/contest/702/submission/19589375).
#![allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    #[allow(dead_code)]
    buffer: Vec<String>,
}

impl Scanner {
    #[allow(dead_code)]
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            io::stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn solve<T: Write>(scan: &mut Scanner, out: &mut BufWriter<T>) {
    let s: Vec<char> = scan.next::<String>().chars().collect();

    if s[2] == s[3] && s[4] == s[5] {
        writeln!(out, "Yes").ok();
    } else {
        writeln!(out, "No").ok();
    }
}

fn main() {
    let mut scan = Scanner::default();
    let mut out = BufWriter::new(io::stdout());
    solve(&mut scan, &mut out);
}


Measured memory_bytes: 4352
// atcoder/m-solutions2019/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> g[n];
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    vector<int> c(n);
    cin >> c;

    int deg[n];
    fill(deg, deg + n, 0);
    vector<int> v;
    for (int i = 0; i < n; ++i) {
      v.push_back(i);
      deg[i] = g[i].size();
    }

    queue<int> q;
    for (int i = 0; i < n; ++i) {
      if (deg[i] == 1) q.push(i);
    }

    map<int, int> m;
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    lli sum = 0;
    for (int i = 1; i < n; ++i) {
      sum += c[i];
    }

    while (q.size()) {
      int curr = q.front();
      q.pop();
      m[curr] = c.back();
      c.pop_back();
      each (next, g[curr]) {
        --deg[next];
        if (deg[next] == 1) q.push(next);
      }
    }

    cout << sum << endl;
    for (int i = 0; i < n; ++i) {
      cout << m[i] << ' ' ;
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1536
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){

    string N;
    cin>>N;
    
    if(N[0]=='9'||N[1]=='9') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
using ll = long long;
using P = pair<int, int>;
int main(){
  int n;
  cin >> n;
  int d[n];
  rep(i, n){
    cin >> d[i];
  }
  sort(d,d+n);
  if(d[n/2-1]==d[n/2]){
    cout << "0" << endl;
  } else {
    cout << d[n/2]-d[n/2-1] << endl;
  }
}


Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

int count(long long x, long long N, bool s, bool f, bool t)
{
	if (x > N)
	{
		return 0;
	}

	auto num = 0ull;
	if (s && f && t)
	{
		++num;
	}

	x *= 10;
	num += count(x + 3, N, s, f, true);
	num += count(x + 5, N, s, true, t);
	num += count(x + 7, N, true, f, t);

	return num;
}

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

	cout << count(0, N, false, false, false) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll A, B;
  cin >> A >> B;

  ll ans = max(0LL, A - 2 * B);
  cout << ans << endl;
}

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

int main(void){
    long long ans = 0;
    std::string S;
    std::cin >> S;
    int N = S.size();
    std::vector<long long> A(N + 1, 0);

    for (int i = 0; i < N; ++i){
        if (S.at(i) == '<'){
            A.at(i + 1) = A.at(i) + 1;
        }
    }
    for (int i = N - 1; i >= 0; --i){
        if (S.at(i) == '>'){
            if (A.at(i) <= A.at(i + 1)){
                A.at(i) = A.at(i + 1) + 1;
            }
        }
    }
    for (int i = 0; i <= N; ++i){
        ans += A.at(i);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 7696
#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=10000+10,mo=998244353;
char s[maxn];
int f[maxn][maxn],fac[maxn],inv[maxn],bz[maxn];
int i,j,k,l,t,n,m,ans,x,y;
int qsm(int x,int y){
	if (!y) return 1;
	int t=qsm(x,y/2);
	t=(ll)t*t%mo;
	if (y%2) t=(ll)t*x%mo;
	return t;
}
int C(int n,int m){
	if (n<m||m<0) return 0;
	return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	fo(i,1,n)
		if (s[i]=='1') y++,bz[i]++;
	scanf("%s",s+1);
	fo(i,1,n)
		if (s[i]=='1'&&bz[i]) x++;
	y-=x;
	fac[0]=1;
	fo(i,1,n) fac[i]=(ll)fac[i-1]*i%mo;
	inv[n]=qsm(fac[n],mo-2);
	fd(i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
	f[0][0]=1;
	fo(i,1,y) f[0][i]=(ll)fac[i]*fac[i]%mo;
	fo(i,1,x)
		fo(j,1,y)
			f[i][j]=(ll)((ll)f[i-1][j]*i%mo+(ll)f[i][j-1]*j%mo)*j%mo;
	fo(i,0,x)
		(ans+=(ll)f[x-i][y]*qsm(fac[i],2)%mo*C(x,i)%mo*C(x+y,i)%mo)%=mo;
	(ans+=mo)%=mo;
	printf("%d\n",ans);
}

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

struct Cake {
	int h, w;
	Cake(int h, int w): h(h), w(w){}
	int size() const {
		return h * w;
	}
	bool operator < (const Cake &t) const {
		return size() < t.size();
	}
};

int n;
vector<Cake> cake;

pair<Cake, Cake> cut(const Cake& cake, int pos)
{
	pos %= (cake.w + cake.h) * 2;
	int y = cake.h, x = cake.w;
	if (pos < y) return make_pair(Cake(pos, cake.w), Cake(cake.h - pos, cake.w));
	else if ((pos -= y) < x) return make_pair(Cake(cake.h, pos), Cake(cake.h, cake.w - pos));
	else if ((pos -= x) < y) return make_pair(Cake(pos, cake.w), Cake(cake.h - pos, cake.w));
	else if ((pos -= y) < x) return make_pair(Cake(cake.h, pos), Cake(cake.h, cake.w - pos));
	else assert(false);
}

void solve()
{
	for (int i = 0; i < n; i++){
		int p, s;
		scanf("%d %d", &p, &s);
		--p;
		auto cutcake = cut(cake[p], s);
		if (cutcake.second < cutcake.first) swap(cutcake.first, cutcake.second);
		cake.push_back(cutcake.first);
		cake.push_back(cutcake.second);
		cake.erase(cake.begin() + p, cake.begin() + p + 1);
	}
	sort(cake.begin(), cake.end());
	for (int i = 0; i < cake.size(); i++){
		if (i) printf(" ");
		printf("%d", cake[i].h * cake[i].w);
	}
	puts("");
}

int main()
{
	int h, w;
	while (scanf("%d %d %d", &n, &h, &w), h){
		cake.assign(1, Cake(h, w));
		solve();
	}
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  int n, a, b;
  cin >> n >> a >> b;
  vector<ll> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  a = a - b;
  ll ub = 1000000000;
  ll lb = 0;
  while (ub != lb) {
    ll t = (ub + lb) / 2;
    ll need = 0;
    for (int i = 0; i < n; i++) {
      ll rest = h[i] - b * t;
      if (rest <= 0) continue;
      need += (rest + a - 1) / a;
    }
    if (need == t) {
      cout << t << endl;
      return 0;
    } else if (need < t) {
      ub = t;
    } else {
      lb = t + 1;
    }
  }
  cout << ub << endl;
  return 0;
}

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

int D,G;

int dfs(int i, int sum, int solved, int p[], int c[], bool completed[]) {
    if (sum >= G) {
        return solved;
    } else if (i == 0) {
        int max_i=D;
        while (completed[max_i-=1] && max_i >= 0);
        if (max_i >= 0 && sum + 100*(max_i+1)*(p[max_i]-1) >= G) 
            return solved + (G-sum+(100*(max_i+1)-1))/(100*(max_i+1));
        else 
            return 1000;
    } else {
        i--;
        completed[i] = true;
        int a = dfs(i, sum+100*(i+1)*p[i]+c[i], solved+p[i], p, c, completed);
        completed[i] = false;
        return min(a,dfs(i, sum, solved, p, c, completed));
    }
}

int main() {
    scanf("%d %d",&D,&G);
    int p[D],c[D];
    bool completed[D];
    for (int i=0; i<D; i++) {
        scanf("%d %d",&p[i],&c[i]);
        completed[i] = false;
    }
    printf("%d\n",dfs(D,0,0,p,c,completed));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n;
  cin >> n;
  for(int i=n;i<1000;i++){
    if(i/100==(i%100)/10&&i/100==i%10){
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

int main(void){
	int n;
	double mv;
	while(scanf("%lf",&mv) != EOF){
		for(n = 1;sqrt(19.6 * (5 * n - 5)) < mv;n++);
		printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 1056
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


a = S()
ans = 0
for i in a:
    if i == '1':
        ans += 1
print(ans)


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0;(i) < (ll)(n);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1;(i) >= 0LL;(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll maxi = 0;
    vector<map<ll, bool>> A;
    cin >> N;
    A.resize(N);
    rep(i, N) {
        ll temp;
        cin >> temp;
        rep(j, temp) {
            ll x, y;
            cin >> x >> y;
            A[i][x] = y;
        }
    }
    rep(i, 1 << N) {
        ll count = 0;
        rep(j, A.size()) {
            if(i & (1 << j)) {
                iter(k, A[j]) {
                    if(!!(i & (1 << (k.first - 1))) ^ k.second) {
                        goto aaa;
                    }
                }
            }
        }
        for(ll j = i;j != 0;j >>= 1) {
            if(j & 1) count++;
        }
        maxi = max(count, maxi);
        aaa:;
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
nums = gets.split.map(&:to_i)
ans = 0
(n - 2).times do |i|
  if (nums[i] < nums[i + 1] && nums[i + 1] < nums[i + 2]) || (nums[i] > nums[i + 1] && nums[i + 1] > nums[i + 2])
    ans += 1
  end
end
puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int K;
  while(cin >>K && K){
    int sum = 0, L = K * (K - 1) / 2;
    REP(i, L){ int tmp; cin >>tmp; sum += tmp; }
    cout <<sum / (K - 1) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
from bisect import bisect_left

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def fact(n):
    num = 1
    for i in range(1, n+1):
        num *= i
    return num


def order(N, P):
    order = 0
    L = [i for i in range(1, N + 1)]
    """
    下からN桁目が一定なグループは(N-1)!個
    下から(N-1)桁目が一定なグループは(N-2)!個
    ...
    下からi桁目(1 <= i <= N)が一定なグループは(i-1)!個
    ...
    下から1桁目が一定なグループは0!個
    """
    for i in range(N):
        order += bisect_left(L, P[i]) * fact(N - i - 1)
        L.remove(P[i])
        #print("bisect={}, fact={}, order={}, L={}".format(bisect_left(L, P[i]), fact(N - i - 1), order, L))
    return order + 1

print(abs(order(N, P) - order(N, Q)))


Measured memory_bytes: 38256
#include<stdio.h>
int main()
{
	char s[100005];
	scanf("%s", s);
	int n = 0;
	while (s[n] != '\0')
		n++;
	int i;
	int f = 0;
	if (s[0] == '0' || s[n - 1] == '1')
		f++;
	for (i = 0; i < n - 1; i++)
		if (s[i] != s[n - i - 2])
			f++;
	if (f > 0)
	{
		printf("-1\n");
		return 0;
	}
	int v = 2;
	printf("1 2\n");
	for (i = 2; i < n; i++)
	{
		printf("%d %d\n", v, i + 1);
		if (s[i - 1] == '1')
			v = i + 1;
	}
	return 0;
}

Measured memory_bytes: 1800
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){

    ll A, B;
    cin >> A >> B;

    if(A >= 13){
        cout  << B << endl;
        return 0;
    }else if(A >= 6 && A <= 12){
        cout << B / 2 << endl;
        return 0;
    }

    cout << "0" << endl;

}

Measured memory_bytes: 256
from collections import Counter
from operator import itemgetter
N=int(input())
As=Counter([int(i) for i in input().split()])
Aslist=As.most_common()
Aslist=sorted(Aslist,key=itemgetter(0))
for num in range(N):
    if num+1 not in As.keys():
        print(0)
    else:
        print(As[num+1])







Measured memory_bytes: 44648
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    str = (input().rstrip())
    W = 0
    N = 0
    S = 0
    E = 0

    for s in str:
        if(s == 'W'):
            W += 1
        elif(s =='E'):
            E += 1
        elif(s == 'N'):
            N += 1
        else:
            S += 1
    

    if(S*N*E*W > 0 or (S + N == 0 and E*W > 0) or(E +W == 0 and S*N > 0)):
        print("Yes")
    else:
        print("No")
    
if __name__ == '__main__':
    solve()


Measured memory_bytes: 3952
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;
const ll INF = LLONG_MAX;


void print() {
    cout << endl;
}
 
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}
 
template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}
 
template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}
 

int main(){
  ll n,k;cin >> n >> k;
  vector<ll> h(n);
  rep(i,n)cin >> h[i];
  sort(h.begin(),h.end());
  ll ret=INF;
  rep(i,n){
    if(i < k-1)continue;
    ret=min(ret, h.at(i) - h.at(i-k+1));
  }
  print(ret);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

int main(){
	ll H,W;
	cin>>H>>W;
	ll ans=H*W;
	ll s[3];
	REP(i,2){		
		REP(h,H-1){
			s[0]=(H-h-1)*W;
			if ((h+1)%2==0){
				s[1]=s[2]=(h+1)/2*W;
			}else if (W%2==0){
				s[1]=s[2]=(h+1)*W/2;
			}else{
				if (h+1<W){
					s[1]=(h+1)*(W/2+1);
					s[2]=(h+1)*(W/2);
				}else{
					s[1]=((h+1)/2+1)*W;
					s[2]=(h+1)/2*W;
				}
			}
			ans=min(ans,*max_element(s,s+3)-*min_element(s,s+3));
		}
		swap(H,W);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=[int(i)for i in input().split()]
B=[int(i)for i in input().split()]
c=0
for i in range(n):
    x=B[i]-A[i]
    if x<=0:
        c+=B[i]
    elif x>A[i+1]:
        c+=A[i]+A[i+1]
        A[i+1]=0
    else:
        c+=A[i]+x
        A[i+1]-=x
print(c)

Measured memory_bytes: 18624
import java.io.*;

class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		String str=br.readLine();
		
		int i=0;
		
		do{
			i++;
			sb.append("Case ").append(i).append(": ").append(str).append("\n");
			str=br.readLine();
			
		}while(!str.equals("0"));
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 29100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX_V = 100000;
ll V,Par[MAX_V],Rank[MAX_V] = {};
void init(ll n){
  for(ll i=0;i<n;i++) Par[i] = i;
}
ll find(ll x){
  if(x == Par[x]) return x;
  else return Par[x] = find(Par[x]);
}
void unite(ll x,ll y){
  x = find(x);y = find(y);
  if(x == y) return;
  if(Rank[x] < Rank[y]) swap(x,y);
  Par[y] = x;
  if(Rank[x] == Rank[y]) Rank[x]++;
}
bool same(ll x,ll y){
  return find(x) == find(y);
}
bool priY(const pair<pair<ll,ll>,ll> &l,const pair<pair<ll,ll>,ll> &r){
  return l.first.second < r.first.second;
}
int main(){
  ll i,ans = 0;scanf("%lld",&V);
  pair<pair<ll,ll>,ll> P[V];pair<ll,pair<ll,ll>> Dis[V*2-2];
  init(V);
  for(i=0;i<V;i++){
    scanf("%lld%lld",&P[i].first.first,&P[i].first.second);
    P[i].second = i;
  }
  sort(P,P+V);
  for(i=0;i<V-1;i++){
    Dis[i].first = P[i+1].first.first-P[i].first.first;
    Dis[i].second.first = P[i].second;
    Dis[i].second.second = P[i+1].second;
  }
  sort(P,P+V,priY);
  for(i=0;i<V-1;i++){
    Dis[i+V-1].first = P[i+1].first.second-P[i].first.second;
    Dis[i+V-1].second.first = P[i].second;
    Dis[i+V-1].second.second = P[i+1].second;
  }
  sort(Dis,Dis+V*2-2);
  for(i=0;i<V*2-2;i++){
    if(!same(Dis[i].second.first,Dis[i].second.second)){
      ans += Dis[i].first;
      unite(Dis[i].second.first,Dis[i].second.second);
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 8832
#include<stdio.h>
#include<stdlib.h>
#include<string.h> 
int top, S[1000];

void push(int n)
{
	S[++top] = n;
}

int pop()
{	
	top--;
	return S[top+1];
}

int main()
{	
	int a, b;
	top = 0;
	char s[100];

	while(scanf("%s", s) != EOF) {
		if(s[0] == '+') {
			a = pop();
			b = pop();
			push(a+b);
		}
		else if(s[0] == '-') {
			b = pop();
			a = pop();
			push(a-b);
		}else if(s[0] == '*') {
			a = pop();
			b = pop();
			push(a*b);
		}else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
    return 0;
}

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


void solve(long long A, long long B){
    if (A >= 10 || B >= 10)
        cout << "-1" << endl;
    else
    {
        cout << A*B << endl;
    }
    
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;

		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();

			String[] tmp = line.split(" ");

			int numA = Integer.parseInt(tmp[0]);
			int numB = Integer.parseInt(tmp[1]);
			int numC = Integer.parseInt(tmp[2]);

			int tmpNum = Math.min(numA, numB);
			int cnt = 0;
			while (true) {

				if (numA % tmpNum == 0 && numB % tmpNum == 0) {
					cnt++;

					if (cnt == numC) {
						break;
					}

				}

				tmpNum--;
			}

			System.out.println(tmpNum);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

using namespace std;

using ll = long long;

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

    ll n;
    cin >> n;

    const string name = "MARCH";
    map<char, ll> cnt;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        for (int j = 0; j < 5; ++j)
            if (s[0] == name[j]) ++cnt[name[j]];
    }

    ll ans = 0;
    for (int i = 0; i < 5; ++i)
        for (int j = i + 1; j < 5; ++j)
            for (int k = j + 1; k < 5; ++k)
                ans += cnt[name[i]] * cnt[name[j]] * cnt[name[k]];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int main(void){
    
    char s[10];
    scanf("%s", &s);
    
    int n = 10;
    int ans = 0;
    int count = 0;
    rep(i, n){
        if ((s[i] == 'A') or (s[i] == 'G') or (s[i] == 'C') or (s[i] == 'T')){
            count++;
            if (ans < count) ans = count;
        }
        else {
            count = 0;
        }
    }
    
    printf("%d", ans);
    
    return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;

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

	N = N % 10;

	if (N == 3) {
		cout << "bon" << endl;
	}
	else if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon" << endl;
	}
	else cout << "hon" << endl;

	return 0;
}

Measured memory_bytes: 3600