akhauriyash/Code-Regression huggingface dataset:
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp*/
#include <iostream>

using namespace std;

void println(int *a,int n){
    for(int i=0;i<n;i++){
        cout<<a[i];
        if(i<n-1){
            cout<<" ";
        }
    }
    cout<<endl;
}

int main()
{
    int n;
    int a[100];

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    println(a,n);
    for(int i=1;i<n;i++){
        int v=a[i];
        int j;
        for(j=i-1;-1<j && a[j]>v;j--){
            a[j+1]=a[j];
        }
        a[j+1]=v;
        println(a,n);
    }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[10];
int main(){
	ll t;
	rep(i,0,4)scanf("%lld",&t),a[t]++;
	puts(a[1]&&a[9]&&a[7]&&a[4]?"YES":"NO");
	return 0;
}

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

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

    for (int i = A; i <= B; ++i) {
        if (i % K == 0) {
            goto OK;
        }
    }

    cout << "NG" << endl;
    return 0;
OK:
    cout << "OK" << endl;
    return 0;
}

Measured memory_bytes: 3596
using System;

	public class Class1
	{
		public static void Main()
		{   
			string op="?";
			do{
			
				string dataSet=Console.ReadLine();
				string[] data=dataSet.Split();
				int a=int.Parse(data[0]);
				 op =data[1];
				int b =int.Parse(data[2]);
		
				switch(op)
				{
				case "+":
				Console.WriteLine(a+b);
				break;
			   
				case "-":
				Console.WriteLine(a-b);
				break;
			
				case "*":
				Console.WriteLine(a*b);
				break;
			
				case "/":
				
			    Console.WriteLine(a/b);
				break;
				
				case "?":
				break;
				}
				
			}while(op!="?");
			
		}
	}
			

Measured memory_bytes: 9032
S = input()


idx_w = 0
idxes_b = []

for i, s in enumerate(S):
    if s == 'B':
        idxes_b.append(i)
    elif s == 'W':
        idx_w = i

idxes_b = [b for b in idxes_b if idx_w > b]

ans = 0
for i, b in enumerate(idxes_b[::-1]):
    ans += idx_w - b - i

print(max(0, ans))

Measured memory_bytes: 17232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> nums[100005];
int main(){
  ll n;
  cin>>n;
  ll max_v=0;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    nums[a].push_back(i);
    max_v=max(a,max_v);
  }
  ll res=3;
  if(nums[0].size()>1) res*=2;
  ll max_num=nums[0].size();
  for(int i=0;i<=max_v;i++){
    if(nums[i].size()>3){
      cout<<0<<endl;
      return 0;
    }
    if(max_num<nums[i].size()){
      cout<<0<<endl;
      return 0;
    }
    max_num=min(max_num,(ll)nums[i].size());
    sort(nums[i].begin(),nums[i].end());
    while(nums[i].size()<3) nums[i].push_back(17441744);
  }
  vector<ll> ans;
  for(int i=0;i<max_v;i++){
    ll ar[]={0,1,2};
    ll kans=0;
    do{
      bool f=true;
      for(int j=0;j<3;j++){
        if(nums[i][j]>nums[i+1][ar[j]]){
          f=false;
          break;
        }
      }
      if(f) kans++;
    }while(next_permutation(ar,ar+3));
    if(nums[i+1][1]==17441744) kans/=2;
    ans.push_back(kans);
  }
  ll mod=1e9+7;
  for(int i=0;i<ans.size();i++) {
    res*=ans[i];
    res%=mod;
  }
  cout<<res<<endl;
}


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

typedef struct restaurant {
	int I;
	string S;
	int P;

bool operator<(const restaurant& another) const {
	if (S != another.S)
		return S < another.S; // 高い順に並べたいので演算子を逆に
	if (P != another.P)
		return P > another.P; // 同様に比較演算子を反転
}
};
int main() {
	int N;
	cin >> N;
	vector<restaurant> S(N);
	string s;
	int p;
	for (int i = 0; i < N; i++) {
		cin >> s >> p;
		S[i].I = i;
		S[i].S = s;
		S[i].P = p;
	}
	sort(S.begin(), S.end());
	
	for (int j = 0; j < N; j++) {
		cout << S[j].I + 1 << endl;
	}

	return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;

  vector<ll> A(N, 0);

  rep0(i, Q) {
    ll temp;
    cin >> temp;
    A[temp - 1]++;
  }

  rep0(i, N) {
    if (K - Q + A[i] > 0) {
      cout << "Yes" << BR;
    } else {
      cout << "No" << BR;
    }
  }

  return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target ("avx,avx2")

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)

void solve(){

}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	ll n; cin >> n;
	ll ans = 0;
	for(int i{1}; i<=n; i++){
		ans += (n-1)/i;
	}

	cout << ans << "\n";


}


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

int main() {
	int n, a, b, h[100000];
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h, h + n);
	int l = h[n - 1] / a;
	int r = h[n - 1] / b + 1;
	int m;
	while (l < r) {
		m = (l + r) / 2;
		int t = m;
		for (int i = 0; i < n; i++) {
			if (h[i] > m * b) {
				t -= (h[i] - m * b - 1) / (a - b) + 1;
				if (t < 0) {
					break;
				}
			}
		}
		if (t < 0) {
			l = m + 1;
		} else {
			r = m;
		}
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<cmath>
#include<limits>

using namespace std;
int main(){
    
    int N,D;
    cin >> N >> D;

    int x[N][D];

    for(int i=0;i<N;i++){
        for(int k=0;k<D;k++){
            cin >> x[i][k];
        }
    }

    int dis=0;
    int ans=0;
    int l=0;
    double Q;
    for(int i=0;i<N;i++){
        for(l=1;i+l<N;l++){
            dis=0;
            for(int k=0;k<D;k++){
            dis+=(x[i+l][k]-x[i][k])*(x[i+l][k]-x[i][k]);
        }
        Q=sqrt(dis);
        if(ceil(Q)==floor(Q)){
            ans++;
        }
        }
    }
    cout <<ans << endl;

 return 0;
}

Measured memory_bytes: 256
while gets do
  a, b, c, d, e, f = $_.split(/\s/).map(&:to_f)
  z = (b*d - a*e)
  y = (c*d - a*f)/z + 0.000
  x = (b*f - c*e)/z + 0.000
  puts sprintf("%.3f\s%.3f", x, y)
end

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

int main() {
    int N, K;
    cin >> N >> K;
    int res = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (h >= K) res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    string s = to_string(N);
    REP(i, 3) {
        if(s[i]=='7') {cout<<YES<<endl; return;}
    }
    cout<<NO<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3196
#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) << " "

int main(void){
    int h,a;cin>>h>>a;
    if(h%a==0)co(h/a);
    else co(h/a+1);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
string s, ans;
int K;

int search(vector<int> &T, int r){
    vector<string> C;
    int a = s.size();
    rep(i, T.size()){
        for(int j=1; j<=min(r, a - T[i]); j++){
            C.push_back(s.substr(T[i], j));
        }
    }
    sort(C.begin(), C.end());
    C.erase(unique(C.begin(), C.end()), C.end());
    if(C.size() < r) return r - C.size();
    
    ans = C[r-1];
    return 0;
}

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

    cin >> s >> K;
    vector<pair<char, int> > S(s.size());
    rep(i, s.size()){
        S[i].first = s[i];
        S[i].second = i;
    }

    sort(S.begin(), S.end());
    if(K==1){
        cout << S[0].first << endl;
        return 0;
    }
    int t = 0;
    while(t < S.size()){
        vector<int> T;
        char trgt = S[t].first;
        T.push_back(S[t].second);
        t++;
        while((t < S.size()) & (trgt == S[t].first)){
            T.push_back(S[t].second);
            t++;
        }
        K = search(T, K);
        if(K == 0) break;
    }

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

Measured memory_bytes: 1660
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;


int main()
{
    char a[3010],b[3010];
    cin>>a>>b;
    int n,m;
    n=strlen(a);
    m=strlen(b);
    int sum=999999;
    for(int i=0; i<n-m+1; i++)
    {
        int ans=0;
        for(int j=0;j<m; j++)
        {
            if(a[i+j]!=b[j])
            {
                ans++;
            }
        }
        sum=min(ans,sum);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
const int MOD=1e9+7;
string s, t;

int main(void) {
	cin >> s>>t;
	bool flag=false;
	int ls = s.length(), lt = t.length();
	string ans="?";
	for (int i = 0; i <= ls - lt; i++) {
		string cur=s;
		int cnt=0;
		for (int j = 0; j < lt; j++) {
			if (s[i + j] == t[j] || s[i + j] == '?')cnt++;
		}
		if (cnt == lt) {
			flag = true;
			for (int r = 0; r < lt; r++) {
				cur[i + r] = t[r];
			}
			for (int e = 0; e < ls; e++) {
				if (cur[e] == '?')cur[e] = 'a';
			}
			if (ans == "?")ans = cur;
			else if(ans > cur)ans = cur;
		}
	}
	if(flag==true)cout << ans<<endl;
	else cout << "UNRESTORABLE" << endl;
	return 0;
}

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

int main() {
  
  int X, Y, C;
  cin >> X >> Y;
  C = 0;
  
  for (int i = 0; i <= X; i++) {
    if (2 * (X - i) + 4 * (i) == Y) {
      C = C + 1;
      break;
    }
  }
  
  if (C == 0) {
    cout << "No";
  }
  else if (C > 0) {
    cout << "Yes";
  }
  
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    string o,e;
    cin >> o >> e;
    vector<char>s(o.size()+e.size()+1);
    int index = 1;
    for(int i=0;i<o.size();i++){
        s[index]=o[i];
        index+=2;
    }
    
    index = 2;
    for(int i=0;i<e.size();i++){
        s[index]=e[i];
        index+=2;
    }
    for(int i=1;i<s.size();i++){
        cout << s[i];
    }
}


Measured memory_bytes: 3612
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	x = int(rl())
	if x >= 30:
		print("Yes")
	else:
		print("No")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 67380
<?php
  $s = trim(fgets(STDIN));
  $t = trim(fgets(STDIN));
  if($s == $t){
    echo "Yes\n";
    exit;
  }
  for($i=0; $i<strlen($s); $i++){
    if($s == $t){
      echo "Yes\n";
      exit;
    }
    $back = substr($t,-1);
    $t = rtrim($t,$back);
    $t = $back.$t;
  }
  echo "No\n";

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	
	

	void solve(){


		ini(n);
		ini(n1);
		vi morty;
		FOR(i,0,n){
			ini(x);
			morty.push_back(x);
		}
		sort(all(morty));
		int rick = 0;
		FOR(i,0,n1){
			rick+=morty[i];
		}
		out(rick);
			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

int main(){
    double a,b;
    cin >> a >> b;
    for(int i=1;i<=1009;i++){
        if(floor(i*0.08) == a && floor(i*0.1) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int     main(void)
{
    int a;
    int b;
    int c;
    int swap;
    
    scanf("%d %d %d",&a,&b,&c);
    if(b < a)
    {
        swap = a;
        a = b;
        b = swap;
    }
    if(c < b)
    {
        swap = b;
        b = c;
        c = swap;
    }
    if(b < a)
    {
        swap = a;
        a = b;
        b = swap;
    }
    printf("%d %d %d\n", a, b, c);
    return(0);
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    vector<int> d;
    while (n>0) {
        d.push_back(n%k);
        n /= k;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def combi(n,k)
  k=n-k if 2*k > n
  return 1 if k == 0
  ((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

S = gets.to_i

max_n = S / 3

ans = 0

r = 10**9 + 7

(1..max_n).each do |n|
  nokori_cnt = S - 3*n
  sikiri_cnt = n - 1
  combi_n = nokori_cnt + sikiri_cnt
  ans += combi(combi_n, sikiri_cnt) % r
end

puts ans % r


Measured memory_bytes: 15052
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define int long long
#define ld long double
#define ll long long

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n), f(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> f[i];
	}
	sort(a.begin(), a.end());
	sort(f.begin(), f.end());
	int l = -1, r = 1e13;
	while (r - l > 1) {
		int mid = (r + l) / 2;
		int sum = 0;
		for (int i = n - 1; i > -1; i--) {
			int j = n - i - 1;
			if (a[j] * f[i] <= mid) continue;
			else {
				int kek = a[j] * f[i] - mid;
				sum += (kek + f[i] - 1) / f[i];
			}
		}
		if (sum <= k) {
			r = mid;
		}
		else {
			l = mid;
		}
	}
	cout << r;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;
typedef unsigned long long int ll;

ll gcd(ll a, ll b)
{
	if(a < b)
	{
		ll c = a;
		a = b;
		b = c;
	}
	if(a % b == 0)
	{
		return(b);
	}
	else
	{
		gcd(b, a % b);
	}
}
//1+2+...+nðßé
ll sum(ll n){
  return n * (n + 1) / 2;
}

//aÆbÌÅ¬ö{ðßé
ll lcm(ll a,ll b){
  return a / gcd(a,b) * b;
}

int main(void){
  ll m,n;
  ll t[22];

  while(cin>>m>>n,m||n){
    for(int i = 0; i < n; ++i)
	{
      cin>>t[i];
    }

    ll to = (1<<n);
    ll p = sum(m), q = m; //úÒlÌªqÆªê

    //x}ÅÌÇÌW©ð2i(i)Åßé
    //á¦Î, Tv1Å, 110 ÈçÎ, 6Ì{ÌW(2Æ3Ìlcm)  
    for(ll i=1;i<to;i++){
      ll bitCnt = 0; //rbgª¢­Â§ÁÄ¢é©ßé
      ll l = 1; //Å¬ö{ª¢­ç©

      for(ll bit=1,j=0;bit<=i;bit<<=1,j++){
        if(i & bit){
          bitCnt++;
          l = lcm(l,t[j]);
        }
      }

      //x}ÅïÂÌWªdÈÁÄ¢éê, }CiX
      if(bitCnt % 2 == 1){
        p -= l * sum(m / l); //l * sum(m / l) : mÈºÌlÌ{Ìv
        q -= m / l;          //m / l : mÈºÌlÌ{Ì
      }
      //x}ÅôÂÌWªdÈÁÄ¢éê, vX
      else{
        p += l * sum(m / l);
        q += m / l;
      }
    }

    printf("%.10f\n",q==0 ? 0 : (double)p/q);
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
    int a,b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }
    else if(a <= 12 && a >= 6){
        cout << b/2 << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

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

int main(){
  string a,b;
  int ans=0;
  cin >>a>>b;
  
  for(int i=0;i<a.size();i++){
   if(a[i]!=b[i])ans++; 
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define pb			push_back
#define vi  		vector<int>
#define all(a)		(a).begin(),(a).end()
#define F 			first
#define S 			second
#define endl		"\n"
#define fast 		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int 		long long int
#define mod			1000000007
#define test		int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)

int32_t main(){

	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)
		cout<<k<<endl;
	else
	{
		if(k> a+b)
			{
				cout<<a-(k-(a+b))<<endl;
			}
		else{
			cout<<a<<endl;
		}
	}

	return 0;

}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int,int> pii;
const int mod = (int) 1000000007;
const int inf = (int) 2e18;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
  	int n;
  	cin >> n;
  	int res = 0;
  	vector<int> v(n);
  	for(int i=0; i<n; i++) cin >> v[i];
  	for(int i=1; i<n; i++){
  	    if(v[i-1] > v[i]){
  	        res += (v[i-1]-v[i]);
  	        v[i] = v[i-1];
  	    }
  	}
  	cout << res << "\n";
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

bool dp[90][90][2 * 80 * 80 * 2 * 2];
int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W)), B(H, vector<int>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> B[i][j];
        }
    }
    int MAX_DIFF = 2 * 2 * 80 * 80;
    int MID = MAX_DIFF / 2;
    int INITIAL_DIFF = B[0][0] - A[0][0];
    dp[0][0][INITIAL_DIFF + MID] = true;
    dp[0][0][-INITIAL_DIFF + MID] = true;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            for(int l = 0; l <= MAX_DIFF; l++) {
                if(dp[i][j][l]) {
                    if(i + 1 < H) {
                        int diff = B[i + 1][j] - A[i + 1][j];
                        dp[i + 1][j][l + diff] = true;
                        dp[i + 1][j][l - diff] = true;
                    }
                    if(j + 1 < W) {
                        int diff = B[i][j + 1] - A[i][j + 1];
                        dp[i][j + 1][l + diff] = true;
                        dp[i][j + 1][l - diff] = true;
                    }
                }
            }
        }
    }
    int ans = MAX_DIFF;
    for(int i = 0; i <= MAX_DIFF; i++) {
        if(dp[H - 1][W - 1][i]) {
            ans = min(ans, abs(i - MID));
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int mxN = 410;
const ll INF = 1e18;
int N, a[mxN];
ll dp[mxN][mxN], pref[mxN];

ll rec(int l, int r) {
	if (l >= r) {
		return 0;
	}
	if (dp[l][r] != -1) {
		return dp[l][r];
	}
	dp[l][r] = INF;
	for (int i = l; i < r; i++) {
		dp[l][r] = min(dp[l][r], rec(l, i) + rec(i + 1, r));
	}
	dp[l][r] = dp[l][r] + pref[r + 1] - pref[l];
	return dp[l][r];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		pref[i + 1] = pref[i] + a[i];
	}
	memset(dp, -1, sizeof(dp));
	ll ans = rec(0, N - 1);
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 4952
class SWAG():
    def __init__(self,unit,f):
        self.fold_r=[unit]
        self.fold_l=[unit]
        self.data_r=[]
        self.data_l=[]
        self.f=f
    def __refill_right(self):
        temp=[]
        n=len(self.data_l)
        for _ in range(n//2):
            temp.append(self.popleft())
        for _ in range(n//2,n):
            self.append(self.popleft())
        for _ in range(n//2):
            self.appendleft(temp.pop())
    def __refill_left(self):
        temp=[]
        n=len(self.data_r)
        for _ in range(n//2):
            temp.append(self.pop())
        for _ in range(n//2,n):
            self.appendleft(self.pop())
        for _ in range(n//2):
            self.append(temp.pop())
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.__refill_right()
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.__refill_left()
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,k,*p=map(int,open(0).read().split())
c=[0]
for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
*c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
x=not f
s_min=SWAG(10**18,min)
s_max=SWAG(0,max)
*_,=map(s_min.append,p[:k-1])
*_,=map(s_max.append,p[1:k])
for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    s_min.append(p[i+k-1])
    s_max.append(b)
    if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1
    s_min.popleft()
    s_max.popleft()
print(x+f)

Measured memory_bytes: 28896
#include<iostream>
#include<string>
using namespace std;
int main(){
	int ans=0;
	string x;
	char c;
	for(;;){
		cin>>x;
		if(x=="0")break;
		for(int i=0;i<x.size();i++){
			c=x[i]-'A';
			ans+=int(c);
		}
		cout<<ans+(x.size()*17)<<endl;
		ans=0;
	}
	return 0;
}


Measured memory_bytes: 3156
#include<stdio.h>
#include<string.h>
typedef long long ll;
const int mod=1e9+7;
int mul(int a,int b){return(ll)a*b%mod;}
void inc(int&a,int b){(a+=b)>=mod?a-=mod:0;}
int a[610],f[310][310],g[310][310];
bool e[610],sp[610];
int main(){
	int n,i,j,k,c,s;
	scanf("%d",&n);
	for(i=1;i<=n*2;i++){
		scanf("%d",a+i);
		if(~a[i])e[a[i]]=1;
	}
	for(i=1;i<=n;i++){
		if(~a[i*2-1]&&~a[i*2])sp[a[i*2-1]]=sp[a[i*2]]=1;
	}
	f[0][0]=1;
	for(i=n*2;i>0;i--){
		if(sp[i])continue;
		memset(g,0,sizeof(g));
		for(j=0;j<=n;j++){
			for(k=0;k<=n;k++){
				if(!f[j][k])continue;
				if(e[i]){
					inc(g[j+1][k],f[j][k]);
					if(k)inc(g[j][k-1],f[j][k]);
				}else{
					inc(g[j][k+1],f[j][k]);
					if(j)inc(g[j-1][k],mul(f[j][k],j));
					if(k)inc(g[j][k-1],f[j][k]);
				}
			}
		}
		memcpy(f,g,sizeof(g));
	}
	c=0;
	for(i=1;i<=n;i++)c+=a[i*2-1]==-1&&a[i*2]==-1;
	s=f[0][0];
	for(i=1;i<=c;i++)s=mul(s,i);
	printf("%d",s);
}

Measured memory_bytes: 896
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

struct bamboo {
	int a;
	int b;
	int c;
};

bool operator <(const bamboo& left,const bamboo& right) {
	if (left.a == right.a && left.b == right.b)
		return left.c < right.c;
	if (left.a == right.a)
		return left.b < right.b;
	return left.a < right.a;

}

lli l[10] = {};

int main(void) {

	std::map<bamboo, int> m;
	std::map<bamboo, int> next_m;

	int N, A, B, C;
	cin >> N >> A >> B >> C;

	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}


	m[bamboo{ 0, 0, 0 }] = 100;

	for (int i = 0; i < N; i++) {
		for (auto itr = m.begin(); itr != m.end(); itr++) {
			{
				bamboo b = itr->first;
				int cost = itr->second + 10;
				b.a += l[i];
				if(next_m[b] == 0)
					next_m[b] = cost;
				else
					CHMIN(next_m[b],cost);
			}
			{
				bamboo b = itr->first;
				int cost = itr->second + 10;
				b.b += l[i];
				if (next_m[b] == 0)
					next_m[b] = cost;
				else
					CHMIN(next_m[b], cost);
			}
			{
				bamboo b = itr->first;
				int cost = itr->second + 10;
				b.c += l[i];
				if (next_m[b] == 0)
					next_m[b] = cost;
				else
					CHMIN(next_m[b], cost);
			}
			{
				bamboo b = itr->first;
				int cost = itr->second;
				if (next_m[b] == 0)
					next_m[b] = cost;
				else
					CHMIN(next_m[b], cost);
			}
		}
		swap(m, next_m);
	}

	int ans = 10000000;

	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if (itr->first.a == 0 || itr->first.b == 0 || itr->first.c == 0)
			continue;
		CHMIN(ans, itr->second - 130 + abs(itr->first.a - A) + abs(itr->first.b - B) + abs(itr->first.c - C));
	}

	COUT(ans);
	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  vector<pair<ll,ll> > cnt(100010);
  vector<ll>pll(100010);
  for(int i=0;i<n;i++){
    int num;cin>>num;
    pll[num]++;
  }

  for(int i=0;i<100010;i++){
    if(pll[i]>0){
      cnt[i%m].F+=pll[i];
      cnt[i%m].S+=pll[i]/2;
    }
  }
  ll ans=0;
  ans+=cnt[0].F/2;
  for(int i=1;i<=m/2;i++){
    if(i==m-i){
      ans+=cnt[i].F/2;
    }else{
      ans+=min(cnt[i].F,cnt[m-i].F);
      if(cnt[i].F>cnt[m-i].F){
	ans+=min(cnt[i].S,(cnt[i].F-cnt[m-i].F)/2);
      }else{
	ans+=min(cnt[m-i].S,(cnt[m-i].F-cnt[i].F)/2);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int array[3];
  int count = 0;
  cin >> array[0] >> array[1] >> array[2];
  sort(array,array+3);
  while(1){
    if(array[0]==array[2]){
	  break;
	}
	if(array[1]<array[2]){
	  array[0]++;
	  array[1]++;
	}else{
	  array[0] += 2;
	}
	sort(array,array+3);
    count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import heapq
 
"""
https://juppy.hatenablog.com/entry/2019/02/18/%E8%9F%BB%E6%9C%AC_python_%E3%83%97%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%AA%E3%83%86%E3%82%A3%E3%82%AD%E3%83%A5%E3%83%BC%28heapq%29%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95
"""
 
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**10]*n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
 
################################
N = int(input())
n = N
w = N
 
edge = tuple([] for i in range(n))
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w-1):
    a,b,c = map(int,input().split())
    edge[a-1].append([c,b-1])
    edge[b-1].append([c,a-1])
 
 
Q,K = map(int,input().split())
dist = dijkstra_heap(K-1,edge)
 
for i in range(Q):
    x,y = map(int,input().split())
    print(int(dist[x-1]+dist[y-1]))

Measured memory_bytes: 102148
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)

#define shosu setprecision(10)

typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int x[101],y[101],n,m;

int main(){
cin>>n>>m>>x[0]>>y[0];
rep1(i,n){cin>>x[i];}rep1(i,m){cin>>y[i];}
sort(x,x+n+1);
sort(y,y+m+1);
if(x[n]<y[0])cout<<"No War"<<endl;
else cout<<"War"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main() {
    int h, w;
    cin >> h >> w;
    int ans = INF;

    rep(i, 2) {
        int h1;
        if(h % 3 == 2) h1 = h / 3 + 1;
        else h1 = h / 3;
        int s1 = h1 * w;
        {
            int h2 = (h - h1) / 2;
            int s2 = h2 * w;
            int s3 = (h - h1 - h2) * w;
            int tmp = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
            ans = min(ans, tmp);
        }
        {
            int w1 = w / 2;
            int s2 = (h - h1) * w1;
            int s3 = (h - h1) * (w - w1);
            int tmp = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
            ans = min(ans, tmp);
        }

        int t = h;
        h = w;
        w = t;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>
#include <deque>

using namespace std;

vector<int> longest_decreasing_subsequence(const vector<int>& X)
{
    int N = X.size();
    vector<int> P(N);
    vector<int> M(N+1);

    int L = 0;
    for (int i = 0; i < N; i++) {
        // Binary search for the largest positive j ≤ L
        // such that X[M[j]] <= X[i]
        int lo = 1;
        int hi = L;
        while (lo <= hi) {
            int mid = (lo+hi)/2;
            if (X[M[mid]] >= X[i])
                lo = mid+1;
            else
                hi = mid-1;
        }

        // After searching, lo is 1 greater than the
        // length of the longest prefix of X[i]
        int newL = lo;

        // The predecessor of X[i] is the last index of 
        // the subsequence of length newL-1
        P[i] = M[newL-1];
        M[newL] = i;

        if (newL > L)
            // If we found a subsequence longer than any we've
            // found yet, update L
            L = newL;
    }

    // Reconstruct the longest decreasing subsequence
    vector<int> S(L);
    int k = M[L];
    for (int i = L-1; i >= 0; i--) {
        S[i] = X[k];
        k = P[k];
    }

    return S;
}

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();
    vector<int> a(n);
    for (int i = 0; i < n; i++) a[i] = get<int>();

    auto b = longest_decreasing_subsequence(a);
    cout << b.size() << endl;
}


Measured memory_bytes: 1792
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

string s;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> s;
   int ans = 0;
   for (int i = 0; i < sz (s) / 2; i ++)
      if (s[i] != s[sz (s) - i - 1])
         ans ++;
   cout << ans;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

void Print(int);
int depth(int, int);

struct Node{
  int parent, left, right;
};

struct Node Tree[MAX];

int Depth[MAX];

int main(){
  int n,i,j,num,dep,c,l,r;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    Tree[i].parent = Tree[i].left = Tree[i].right = NIL;
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&num,&dep);
    for(j = 0 ; j < dep ; j++){
      scanf("%d",&c);
      if(j == 0) Tree[num].left = c;
      else Tree[l].right = c;
      l = c;
      Tree[c].parent = num;
    }
  }
  
  for(i = 0 ; i < n ; i++){
    if(Tree[i].parent == NIL) r = i;
  }

  depth(r,0);
 
  for(i = 0 ; i < n ; i++) Print(i);

  //printf("\n");
  
  return 0;
}

void Print(int x){
  int i,c;

  printf("node %d: ",x);
  printf("parent = %d, ",Tree[x].parent);
  printf("depth = %d, ",Depth[x]);

  if(Tree[x].parent == NIL) printf("root, ");
  else if(Tree[x].left == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i = 0, c = Tree[x].left ; c != NIL ; i++, c = Tree[c].right){
    if(i > 0) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int depth(int x, int y){
  Depth[x] = y;
  if(Tree[x].right != NIL) depth(Tree[x].right, y);
  if(Tree[x].left != NIL) depth(Tree[x].left ,y+1);
}



Measured memory_bytes: 6388
import sys
input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    a = list(map(int,input().split()))
    MOD = 10**9+7
    
    dp = [0 for _ in range(K+2)]
    dp[0] = 1
    for num in a:
        imos = [0 for _ in range(K+2)]
        for i in range(K+2):
            imos[i] += dp[i]
            imos[min(K+1,i+num+1)] -= dp[i]
        for i in range(K+1):
            imos[i+1] += imos[i]
            imos[i+1] %= MOD
        dp = imos
        
    print(dp[K])
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 119412
#![allow(unused)]

use std::io::stdin;
use std::str::FromStr;

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse()
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse())
        .collect()
}

use std::cmp::max;

fn main() {
    let (a, b): (i32, i32) = {
        let tmp = input_vec().unwrap();
        (tmp[0], tmp[1])
    };

    let ans = max(0, a - 2 * b);
    println!("{}", ans);
}



Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int[] a = new int[n];
		for(int i = 0;i < n; ++i){
			a[i] = Integer.parseInt(scan.next());
		}
		int count = 0;
		for(int i = 0; i < n-1; ++i){
			if(a[i] == a[i+1]){
				a[i+1] = -1;
				++count;
			}
		}
		System.out.print(count);

	}

}


//end


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

int main() {
    int n, x, t, i = 0;
    cin >> n >> x >> t;
    if (n % x == 0) {
        cout << (n / x) * t << endl;
    } else
        cout << ((n / x) + 1) * t << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <limits.h>
#define N 200001
#define imax(a,b) (a>b)?a:b
#define imin(a,b) (a<b)?a:b

int main()
{
  int n,r;
  scanf("%d",&n);
  int ans=INT_MIN,rmin;
  
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&r);
    if(i==0) rmin=r;
    else{
      ans=imax(ans,r-rmin);
      rmin=imin(r,rmin);
    }
  }
  
  printf("%d\n",ans);
  return 0;
}

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


int main() {
  int N, a;
  cin >> N;
  a = N % 10;
  if(a == 3){
    cout << "bon";
  }
  else if(a == 0 || a == 1){
    cout << "pon";
  }
  else if(a == 6 || a == 8){
    cout << "pon";
  }
  else{
    cout << "hon";
  }
  return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int h, w, a, b, c, d, e, f, g;
const int k = 400;
signed main() {
	cin >> h >> w >> a >> d;
	b = h / a; c = h % a;
	e = w / d; f = w % d;
	g = c * w + f * h - c * f;
	if (b*e >= g*k) {
		cout << "No\n";
		return 0;
	}
	else {
		cout << "Yes\n";
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (j)cout << ' ';
				if ((i + 1) % a == 0 && (j + 1) % d == 0)cout << -((a*d-1)*k)-1;
				else cout << k;
			}
			cout << endl;
		}
	}
}

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

int main() {
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    bool ok = true;
    REP(i, a, c) {
        if (s.substr(i-1, 2) == "##") ok = false;
    }
    REP(i, b, d) {
        if (s.substr(i-1, 2) == "##") ok = false;
    }
    if (ok && c > d) {
        ok = false;
        REP(i, b, d+1) {
            if (s.substr(i-2, 3) == "...") ok = true;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	h := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	dp := make([]float64, n)
	dp[0] = 0
	for i := 1; i < n; i++ {
		cost1 := dp[i-1] + math.Abs(h[i]-h[i-1])
		if i == 1 {
			dp[i] = cost1
			continue
		}
		cost2 := dp[i-2] + math.Abs(h[i]-h[i-2])
		if cost1 < cost2 {
			dp[i] = cost1
		} else {
			dp[i] = cost2
		}
	}
	fmt.Println(int64(dp[n-1]))
}


Measured memory_bytes: 5504
//Snuke Festival

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#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 " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    vecrep(n,a,int);
    vecrep(n,b,int);
    vecrep(n,c,int);
    sort(range(a));
    sort(range(b));
    sort(range(c));
    int ans = 0;
    for(auto i:b){
        int t = lower_bound(range(a),i)-a.begin();
        int s = c.end()-upper_bound(range(c),i);
        ans+=t*s;
    }
    cout<<ans<<nnn;
    return 0;
}

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

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(int argc, char**argv){
    string w;
    cin >> w;

    map<char, int> c;
    for (auto ch : w){
        c[ch] = 0;
    }

    for (auto ch : w){
        c[ch]++;
    }

    string ans = "Yes";
    for (auto ch : w){
        if (c[ch] % 2 != 0) ans = "No";
    }

    cout << ans << endl;

    return 0;
}






















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

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


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

    vector<string> Name(N + 10, "");
    vector<int> S(N + 10, 0);
    rep(i, N)   cin >> Name.at(i) >> S.at(i);

    vector<tuple<string, int, int>> P(N);
    rep(i, N)  P.at(i) = make_tuple(Name.at(i), S.at(i), i + 1);

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            string rn1 = get<0>(P.at(i));
            string rn2 = get<0>(P.at(j));
            if(rn1 == rn2)
            {
                int score1 = get<1>(P.at(i));
                int score2 = get<1>(P.at(j));
                if(score1 > score2) swap(P.at(i), P.at(j));
            }
            if(rn1 < rn2)
            {
                swap(P.at(i), P.at(j));
            }
        }
    }
    
    rep(i, N)
    {
        int tmp = get<2>(P.at(i));
        cout << tmp << endl;
    } 
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n, m = map(int, input().split())
s = [-1 for _ in range(m)]
c = [-1 for _ in range(m)]
for i in range(m):
    s[i], c[i] = map(int, input().split())

for x in range(1000):
    x = str(x)
    if len(x) != n:
        continue
    ok = True
#    print('x =', x)
    for i in range(m):
#        print('s[i] =', s[i])
#        print('x[s[i]-1] =', x[s[i]-1])
#        print('c[i] =', c[i])
        if x[s[i]-1] != str(c[i]):
            ok = False
    if ok: 
        print(x)
        exit(0)

print(-1)

Measured memory_bytes: 3064
//
//ABC125 C-GCD on Blackboard
//URL-https://atcoder.jp/contests/abc125/tasks/abc125_c
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

#define MAX 100000

int main() {
  int n;
  int a[MAX+1];

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

  int left[MAX+1] = {0};
  for(int i=0; i<n; ++i) {
    left[i+1] = gcd(left[i], a[i]);
  }

  int right[MAX+1] = {0};
  for(int i=n-1; i>=0; --i) {
    right[i] = gcd(right[i+1], a[i]);
  }

  int res = 0;
  for(int i=0; i<n; ++i) {
    int l = left[i];
    int r = right[i+1];

    if(res<gcd(l, r)) res = gcd(l, r);
  }
  cout << res << endl;
}


Measured memory_bytes: 1408