akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
void norm(int& x,int& y){
  if(y<x){
    int tmp=x;
    x=y;
    y=tmp;
  }
}
int main(){
  int n,m;cin>>n>>m;
  vector<int> a(n+1,0);
  vector<int> b(n+1,0);
  rep(i,m){
    int x,y;cin>>x>>y;
    norm(x,y);
    a[x]++;
    b[y]++;
  }
  vector<int> sum_a(n+1,0);
  vector<int> sum_b(n+1,0);
  rep1(i,n){
    sum_a[i]=sum_a[i-1]+a[i];
    sum_b[i]=sum_b[i-1]+b[i];
  }
  int ans=0;
  rep1(i,n-1){
    if((sum_a[i]-sum_b[i])%2!=0){
      ans++;
      //      cout<<i<<endl;
    }
    //    if(sum_a[i-1]-sum_b[i]==0)ans++;
  }
  if(ans==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	int ans(0);
	map<int, int>m;
	rep(i, 0, N) {
		int a; cin >> a;
		m[a]++;
	}
	for (auto &x : m) {
		ans += x.second & 1;
	}
	cout << ans << endl;
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int q;
  cin >> q;
  rep(i, 0, q) {
    int c, a, n;
    cin >> c >> a >> n;
    int ans = 0;
    int k = 0;

    k = min({c, a, n});
    ans += k;
    c -= k;
    a -= k;
    k = min(c / 2, a);
    ans += k;
    c -= k * 2;
    ans += c / 3;
    cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 3184
#include <iostream>
using namespace std;
//using ll=long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    int N, K;
    cin >> N >> K;
    if(N>=2*K-1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#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 max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	scanf("%lld",&n);
	printf("%lld",n*800-n/15*200);
}

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

int main(){
    ll v,e;
    cin >> v >> e;
    ll a[v][v];
    
    for(ll i=0;i<v;i++){
        for(ll j=0;j<v;j++){
            if(i==j){
                a[i][j]=0;
            }else{
                a[i][j]=INF;
            }
        }
    }
    
    for(ll i=0;i<e;i++){
        ll s,t,d;
        cin >> s >> t >> d;
        a[s][t]=d;
    }
    
    for(ll k=0;k<v;k++){
        for(ll i=0;i<v;i++){
            if(a[i][k]==INF) continue;
            for(ll j=0;j<v;j++){
                if(a[k][j]==INF) continue;
                a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
            }
        }
    }
    
    for(ll i=0;i<v;i++){
        if(a[i][i]<0){
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    
    for(ll i=0;i<v;i++){
        for(ll j=0;j<v;j++){
            if(j!=0) cout << " ";
            if(a[i][j]==INF) cout << "INF";
            else cout << a[i][j];
        }
        cout << endl;
    }
    
    
    return 0;
}










Measured memory_bytes: 3200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    List<Integer> array = new ArrayList<>();
    int[] ans;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ans = new int[N+1];

        array.add(1);

        for(int i=6; i<=N; i*=6){
            array.add(i);
        }

        for(int i=9; i<=N; i*=9){
            array.add(i);
        }

        Collections.sort(array);

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

        ans[0] = 0;

        for(int i=1; i<=N; i++){
            for(int j: array){
                if(i < j) break;
                ans[i] = Math.min(ans[i], ans[i - j]+1);
            }
        }

        System.out.println(ans[N]);
    }

}

Measured memory_bytes: 26904
#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;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int x;
	cin >> x;


	if(x >= 30)cout << "Yes";
	else cout << "No";
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3612
#include <stdio.h>
#define maxn 100010
int n,m,k,f[maxn],fn[maxn],cnt[maxn],tot[maxn],ans[maxn];;
int getf(int u){
	return f[u]==u?u:f[u]=getf(f[u]);
}
void merge(int u,int v){
	int f1=getf(u),f2=getf(v);
	if(f1!=f2)f[f2]=f1;
}
int main(){
	int i,j,a,b;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;i++)f[i]=i;
	for(i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		cnt[a]++,cnt[b]++,merge(a,b);
	}
	for(i=1;i<=n;i++)f[i]=getf(i);
	for(i=1;i<=n;i++)fn[f[i]]++;
	for(i=1;i<=k;i++){
		scanf("%d%d",&a,&b);
		if(f[a]==f[b])tot[a]++,tot[b]++;
	}
	for(i=1;i<=n;i++)ans[i]=fn[f[i]]-cnt[i]-tot[i]-1;
	for(i=1;i<n;i++)printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
	return 0;
}

Measured memory_bytes: 2944
def main():
  n,m,c = list(map(int,input().split()))
  b = list(map(int,input().split()))
  a = [input().split() for l in range(n)]
  ans=0
  for i in range(0,n):
    sum=0
    for j in range(0,m):
      sum+=int(a[i][j])*b[j]
    if sum+c>0:
      ans+=1
  print(ans)
main()

Measured memory_bytes: 9088
#create date: 2020-06-29 13:35

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    x, a = na()
    print(0 if x<a else 10)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9140
import java.util.Scanner;

/**
 * Created by 5st7 on 2016/07/23.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count_5 = 0;
        int count_7 = 0;
        boolean[] b = new boolean[3];
        for (int i = 0; i < 3; i++) {
            int a = sc.nextInt();
            if(a==5){
                count_5++;
            }else if(a==7){
                count_7++;
            }
        }
        if (count_5==2&&count_7==1){
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }
}


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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#endif

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

    int N;
    cin >> N;

    vector<pair<string, pair<int, int> > > v;  // (name, (-score, i))
    string S;
    int P;
    for (int i=1; i<=N; ++i) {
        cin >> S >> P;
        v.push_back(make_pair(S, make_pair(-P, i)));
    }
    sort(v.begin(), v.end());

    for (int i=0; i<N; ++i) {
        cout << v[i].second.second << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,m,ans;
map <str,int> blue,red;
map <str,int> :: iterator itr;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        str temp;cin>>temp;
        blue[temp]++;
    }
    cin>>m;
    for(int i=1;i<=m;i++){
        str temp;cin>>temp;
        red[temp]++;
    }
    for(itr=blue.begin();itr!=blue.end();itr++){
        str s;
        int temp;
        s = itr->first;
        temp = blue[s] - red[s];
        ans = max(ans,temp);
    }
    cout<<ans<<newl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    while(cin>>n>>m&&n&&m){
	int data[101]={},d,v,sum=0;
	for(int i=0;i<n;++i){
	    cin>>d>>v;
	    data[d]=max(data[d],v);
	}
	for(int i=1;i<=m;++i) sum+=data[i];
	cout<<sum<<endl;
    }
    return 0;
}  


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

long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
  
    vector<long long> L(N + 1);
    vector<long long> R(N + 1);
    L[0] = 0;
    R[N] = 0;
    for (int i = 0; i < N; i++) L[i + 1] = gcd(L[i], A[i]);
    for (int i = N - 1; i >= 0; i--) R[i] = gcd(R[i + 1], A[i]);

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        if (ans < gcd(L[i], R[i + 1])) ans = gcd(L[i], R[i + 1]);
    }
    cout << ans << endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, K; cin >> N >> K;
    vector<ll> a(N+1);
    rep(i, N+1){
        a[i] = i;
    }

    // 累積和
    vector<ll> s(N+2, 0); // s[0] = 0 になる
    vector<ll> sr(N+2, 0);
    for (int i = 0; i < N+1; ++i) s[i+1] = s[i] + a[i];
    for (int i = 0; i < N+1; ++i) sr[i+1] = sr[i] + a[N-i];

    ll res=0;
    Rep1(i, K, N+1){
        res = modint(modint(res) + modint(sr[i]) - modint(s[i]) + modint(1));
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

#define MAXN 100000
#define MAXQ 100000

long long occ[MAXQ+5], ans[MAXN+5];

int main()
{
    int n, q;
    scanf("%d%d", &n, &q);
    stack<long long> S;
    S.push(n);
    for (int i = 0; i < q; ++i) {
        long long a;
        scanf("%lld", &a);
        while (!S.empty() && S.top() >= a) {
            S.pop();
        }
        S.push(a);
    }

    vector<long long> op;
    while (!S.empty()) {
        op.push_back(S.top());
        S.pop();
    }
    reverse(op.begin(), op.end());

    occ[op.size()-1] = 1;
    for (int i = op.size()-1; i >= 0; --i) {
        long long k = op[i];
        int upper = i-1;
        int ok = 1;
        while (ok && upper >= 0) {
            ok = 0;
            int l = 0, r = upper;
            while (l < r) {
                int m = (l+r)/2;
                if (k < op[m]) {
                    r = m-1;
                }
                else {
                    l = m+1;
                }
            }
            for (; l+1 <= upper && k >= op[l]; ++l);
            for (; l-1 >= 0 && k < op[l]; --l);
            int j = l;
            if (k >= op[j]) {
                occ[j] += occ[i] * (k/op[j]);
                k %= op[j];
                ok = 1;
            }
            upper = j-1;
        }
        ans[1] += occ[i];
        ans[k+1] -= occ[i];
    }
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
        sum += ans[i];
        printf("%lld\n", sum);
    }
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll a[100200];
ll dp[100200];
vector<int> children[100200];
int parent[100200];
vector<int> path[102000];
void verify(int from){
    for(int i = 0; i < path[from].size(); i++){
        int to = path[from][i];
        if(to == parent[from]) continue;
        parent[to] = from;
        children[from].push_back(to);
        verify(to);
    }
    return;
}

void dfs(int now){
    if(children[now].empty()){
        dp[now] = a[now];
        return;
    }
    ll sum = 0;
    ll maxi = 0;
    for(int i = 0; i < children[now].size(); i++){
        dfs(children[now][i]);
        if(dp[children[now][i]] == -1){
            dp[now] = -1;
            return;
        }
        sum += dp[children[now][i]];
        maxi = max(maxi, dp[children[now][i]]);
    }
    if(children[now].size() == 1){
        if(a[now] == dp[children[now][0]]){
            dp[now] = a[now];
        } else {
            //cout << now << " " << a[now] << " " << children[now][0] << endl;
            dp[now] = -1;
        }
        return;
    }
    //cout << "Searching " << now << endl;
    ll UpperBound = sum;
    ll LowerBound = max((ll)0, 2 * maxi - sum);
    /*if((a[now] > UpperBound) || (a[now] < LowerBound)){
        dp[now] = -1;
        return;
    }
    if((a[now] % 2) != (UpperBound % 2)){
        dp[now] = -1;
        return;
    }*/
    dp[now] = a[now] - (sum - a[now]);
    if((dp[now] > UpperBound) || (dp[now] < LowerBound)){
        dp[now] = -1;
    }
    return;
}

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        parent[i] = 0;
        cin >> a[i];
    }
    parent[1] = 1;
    for(int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    verify(1);
    for(int i = 1; i <= n; i++){
        //cout << "parent " << i << " " << parent[i] << endl;
    }
    dfs(1);
    for(int i = 1; i <= n; i++){
        //cout << dp[i] << endl;
    }
    if(children[1].size() == 1){
        if(dp[1] != -1){
            cout << "YES" << endl;
            return 0;
        }
        cout << "NO" << endl;
        return 0;
    }
    if(dp[1] == 0){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 19840
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const int INF = 1000000007;
int N;
typedef queue<int> que;
que Mp[1002];

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

  cin >> N;
  int a;
  rep(i,N){
    rep(j, N-1){
      cin >> a;
      a--;
      Mp[i].push(a);
    }
  }

  int cnt = 0;
  bool flag = true;
  int maxDay=N*(N-1)/2;
  while(flag){
    if (maxDay<0){
      cout << -1 << "\n";
      return 0;
    } 
    rep(i, N){
      if (!Mp[i].empty()){
        flag = false;
        break;
      }
    }
    if (flag) break;
    vector<bool> Today(N, false);
    rep(i, N){
      if (Mp[i].empty()) continue;
      int a = Mp[i].front();
      if (Mp[a].front()==i && !Today[a] && !Today[i]){
        flag = true;
        Mp[i].pop();
        Mp[a].pop();
        Today[i] = true;
        Today[a] = true;
      }
    }
    if (flag) cnt++;
    else {
      cout << -1 << "\n";
      return 0;
    }
  }

  
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 6784
#include<stdio.h>
int main()
{
	int a, b,c,i,j,d;


    scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	d = 0;
	for (i = a; i <= b; i++)
	{
		 
		if (c%i==0 )
			d=d+1;
	};
	printf("%d\n", d);
	return 0;
}

Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int k;
    string s;
    cin>>k>>s;
    int n=s.size();
    if(n<=k) cout<<s<<endl;
    else{
        string t=s.substr(0,k);
        t+="...";
        cout<<t<<endl;
    }
}



Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if((a + b) % 2 != 0){
            System.out.println("IMPOSSIBLE");
        }else{
            System.out.println((a + b) / 2);
        }
    }
}

Measured memory_bytes: 23508
HP, n = map(int, input().split())
AB = [list(map(int,input().split())) for _ in range(n)]

# DP
## DP[i]は、モンスターにダメージ量iを与えるのに必要な魔力の最小コスト
## DPの初期化
DP = [float('inf')] * (HP+1); DP[0] = 0
## HP分だけDPを回す.
for now_hp in range(HP):
    ## 全ての魔法について以下を試す.
    for damage, cost in AB:
        ### 与えるダメージは、現在のダメージ量＋魔法のダメージか体力の小さい方
        next_hp = min(now_hp+damage, HP)
        ### 今の魔法で与えるダメージ量に必要な最小コストは、->
        ####->現在わかっている値か今のHPまでの最小コスト＋今の魔法コストの小さい方
        DP[next_hp] = min(DP[next_hp], DP[now_hp]+cost)
print(DP[-1])

Measured memory_bytes: 73872
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	string s;
	cin>>s;
	if(s[0]==s[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
  ll n; string s; cin >> n >> s;
  ll count = 0;
  rep(a, 10) {
    rep(b, 10) {
      rep(c, 10) {
        rep(i, n) {
          if(s[i] - '0' == a) {
            Rep(j, i+1, n) {
              if(s[j] - '0' == b) {
                Rep(k, j+1, n) {
                  if(s[k] - '0' == c) {
                    //cout << a << ' ' << b << ' ' << c << endl;
                    count++;
                    break;
                  }
                }
                break;
              }
            }
            break;
          }
        }
      }
    }
  }
  cout << count << endl;
}

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

int mid, n;
int used[111];

int calc(int mid) {
	for(int i=0;;i++) {
		int x = mid-i;
		if(x<0 || !used[x]) return x;
		x = mid+i;
		if(!used[x]) return x;
	}
	return -1;
}

int main() {
	scanf("%d%d", &mid, &n);
	for(int i=0;i<n;i++) {
		int x;
		scanf("%d", &x);
		used[x] = true;
	}
	printf("%d\n", calc(mid));
	
	return 0;
}

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

int main() {
    int i = 1;
    while (true)
    {
        int x;
        cin >> x;
        if (x == 0)
        {
            break;
        }
        else
        {
            cout << "Case " << i << ": " << x << "\n";
        }
        i++;
    }
    return 0;
}


Measured memory_bytes: 3100
nom,dis = gets.split(" ").map!{|i| i.to_i}
yoko=Array.new(nom)
tate=Array.new(nom)

for i in 0..nom-1
  yoko[i],tate[i]= gets.split(" ").map!{|i| i.to_i}
end
kazu=0
for j in 0..nom-1
  if dis**2>=(yoko[j]**2+tate[j]**2)
    kazu+=1
  end
end
puts kazu


Measured memory_bytes: 17480
N, A, B = map(int, input().split())
head = N // (A + B) * A
tail = 0
if  N % (A + B) > 0:
    if N % (A + B) >= A:
        tail = A
    else:
        tail = N % (A + B)
#print(head, tail)
print(head + tail)

Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
const ll MOD=1000000007LL;
int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int>a(q);
  rep(i,q)cin>>a[i];
  vector<int>ans(n);
  rep(i,n)ans[i]=k-q;
  rep(i,q)ans[a[i]-1]++;
  rep(i,n){
    if(ans[i]>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
// #include <array>

using namespace std;

class MSTree
{
public:
  int solve();
};

int MSTree::solve()
{
  int n;
  cin >> n;
  
  vector<vector<int>> adj(n, vector<int>(n));
  list<int> t, vt;

  for ( auto i = 0; i < n; ++i )
    for ( auto j = 0; j < n; ++j )
      cin >> adj[i][j];

  t.push_back( 0 );

  for ( auto i = 1; i < n; ++i )
    vt.push_back( i );

  int w = 0;

  while ( vt.size() )
    {
      int mw = 4000;
      list<int>::iterator itm;
      
      for ( auto ita = t.begin(); ita != t.end(); ++ita )
        for ( auto itb = vt.begin(); itb != vt.end(); ++itb )
          {
            if ( adj[*ita][*itb] >= 0 && mw > adj[*ita][*itb] )
              {
                itm = itb;
                mw = adj[*ita][*itb];
              }
          }
      
      w += mw;
      t.push_back( *itm );
      vt.erase( itm );
    }

  cout << w << endl;
    
  return 0;
}

int main()
{
  MSTree m;

  m.solve();

  return 0;
}

Measured memory_bytes: 1260
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}



int main() {
	string S;
	cin >> S;
	cout << S.substr(0,4) << " " << S.substr(4) << endl;
}

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

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

  if (a < 3200) cout << "red" <<endl;
  else cout << s << endl;
}


Measured memory_bytes: 256
s = list(input())
n = len(s)
s_r = s[::-1]
s_h = s[:(n-1)//2]
s_h_r = s_h[::-1]
s_3 = s[(n+3)//2-1:]
s_3_r = s_3[::-1]

if s==s_r and s_h == s_h_r and s_3 and s_3_r:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  double a,b,c;
  while(cin>>a){
    b=0;int s=0; 
    while(1){if(9.8*b>=a)break;b+=0.0000001;}
    while(1){
      if(4.9*b*b<=s)break;
      s+=5;
    }cout<<s/5+1<<endl;
  }
}

Measured memory_bytes: 3132
use proconio::{input, fastout};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        n : Chars,
    }

    if n.iter().map(|&c| c == '7').any(|c| c) {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

int N, M, K;

struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int N) : par(N), rank(N) {
        for(int i = 0; i < N; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) swap(rx, ry);
        if (rank[rx] == rank[ry]) rank[rx]++;
        par[ry] = rx;
    }

    bool is_same(int x, int y) {
        return root(x) == root(y);
    }
};


int main() {
    cin >> N >> M >> K;
    UnionFind uf(N);
    vector<int> G[N];
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        uf.merge(a-1, b-1);
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    for (int i = 0; i < K; i++) {
        int c, d;
        cin >> c >> d;
        if (uf.is_same(c-1, d-1)) {
            G[c-1].push_back(d-1);
            G[d-1].push_back(c-1);
        }
    }

    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        mp[uf.root(i)]++;
    }

    for (int i = 0; i < N; i++) {
        cout << mp[uf.root(i)] - G[i].size() - 1 << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll n;

bool f(ll a[], ll b[])
{
    repf(i,0,n) if(a[i]!=b[i]) return false;
    return true;
}

int main()
{
    IOS;
    ll n,m;
    cin>>n>>m;
    ll a[n];
    repf(i,0,n) 
    {
        cin>>a[i];
        a[i]/=2;
    }
    ll val=1;
    repf(i,0,n) 
    {
        val=(val*a[i])/__gcd(val,a[i]);
        if(val>m)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    repf(i,0,n)
    {
        if((val/a[i])%2==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    ll c=m/val;
    if(c%2) cout<<c/2+1<<endl;
    else cout<<c/2<<endl;
}  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    ll n;
    cin>>n;

    if( n%2 == 1 )
    {
        cout<<0,nl;
    }
    else
    {
        n /= 2;
        ll ans = 0;
        while( n )
        {
            ans += n/5;
            n /= 5;
        }
        cout<<ans,nl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define MOD (1000000007ll)

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	ll ans=1ll,n,m,i;
	cin >> n >> m;
	if(abs(n-m)>1){
		cout << "0" << endl;
		return 0;
	}
	for(i=1ll; i<=n; ++i){
		mul_mod(ans,i);
	}
	for(i=1ll; i<=m; ++i){
		mul_mod(ans,i);
	}
	if(n == m){
		mul_mod(ans,2ll);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<algorithm>
#include<limits.h>
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(i,n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;
int main(){
int n,cntA=0,cntB=0;
string s;
cin >> n >>  s;
lp(i,s.size()){
if(s[i] == '#')cntA++;
else cntB++;
}
int tempA=0,tempB=0,ans= INT_MAX;
lp(i,s.size()){
ans = min(ans,(cntB- tempB +tempA));
    if(s[i] == '#')tempA++;
    else tempB++;
}
ans = min(ans,(cntB- tempB +tempA));
cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b;
	char op;
	while(1)
	{
		scanf("%d %c %d",&a,&op,&b);
		if(op=='?')
		break;
		if(op=='+')
		printf("%d\n",a+b);
		else if(op=='-')
		printf("%d\n",a-b);
		else if(op=='*')
		printf("%d\n",a*b);
		else if(op=='/')
		printf("%d\n",a/b);
	}	
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> buttom;

    for (int i = 0; i < N; i++)
    {
        int next_button;
        cin >> next_button;
        next_button--;
        buttom.push_back(next_button);
    }
    int now = 0, c = 0;

    while (1)
    {
        if(now == 1)//ボタン2が光る
        {
            cout << c << endl;
            break;
        }
        if(c >= N)
        {
            cout << -1 << endl;
            break;
        }
        c++;
        now = buttom.at(now);
    }
    
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
const int maxm=2e5+5;
vector<int>g[maxm];
int ans[maxm];
int d[maxm],len;
int a[maxm];
void dfs(int x,int fa){
    int f=0;
    int pos=0;
    int temp=0;
    if(a[x]>d[len]){
        d[++len]=a[x];
        f=1;
    }else{
        int l=1,r=len;
        while(l<=r){//二分插入位置
            int mid=(l+r)/2;
            if(a[x]<=d[mid])pos=mid,r=mid-1;
            else l=mid+1;
        }
        temp=d[pos];
        d[pos]=a[x];
    }
    ans[x]=len;
    for(int v:g[x]){
        if(v==fa)continue;
        dfs(v,x);
    }
    if(f){//回溯的时候撤销
        len--;
    }else{
        d[pos]=temp;
    }
}
signed main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<n;i++){
        int a,b;scanf("%d%d",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

/*

*/


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    int A, B;
    cin >> A >> B;

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

Measured memory_bytes: 256
<?php
	$w = trim( fgets( STDIN ) );
	$cnt = 0;
	
	while( FALSE != ($inputs = fgets( STDIN )) ) {
		$strs = explode( " ", trim( strtolower( $inputs ) ) );
		for( $i=0; $i<count($strs); $i++ ) {
			$t = trim( $strs[$i] );
			if( $w == $t ) {
				$cnt++;
			}
		}
	}
	print $cnt;
?>

Measured memory_bytes: 15368
#include <cstdio>
#define LOOP(index,times) for(int index=0;index<times;index++)
using namespace std;

int main(){
long a,b,r;
while(scanf("%ld %ld",&a,&b) != EOF){
	
	long c=a*b;
			
	if(b>a){r=a; a=b; b=r;}

	while(1){
	r=a%b;
	if(r==0) break;
	a=b; b=r;		
	}
	printf("%ld %ld\n",b,c/b);
}
return 0;		
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
class SegmentTree {
private:
	int siz;
	vector<int> dat;
	
public:
	SegmentTree(vector<int> v) {
		siz = 1;
		while(siz < (int) v.size()) siz <<= 1;
		dat.resize(2 * siz - 1, 0);
		for(int idx = 0; idx < (int) v.size(); idx++) {
			dat[idx + siz - 1] = v[idx];
		}
		for(int idx = siz - 2; idx >= 0; idx--) {
			dat[idx] = dat[2 * idx + 1] + dat[2 * idx + 2];
		}
	}
	
	void add(int idx, int val) {
		idx += (siz - 1);
		dat[idx] += val;
		while(idx > 0) {
			idx = (idx - 1) / 2;
			dat[idx] = dat[2 * idx + 1] + dat[2 * idx + 2];
		}
	}
	int get(int a, int b, int idx = 0, int l = 0, int r = -1) {
		if(r < 0) r = siz;
		if(r <= a || b <= l) return 0;
		if(a <= l && r <= b) return dat[idx];
		int val1 = get(a, b, 2 * idx + 1, l, (l + r) / 2);
		int val2 = get(a, b, 2 * idx + 2, (l + r) / 2, r);
		return val1 + val2;
	}
};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, q;
	cin >> n >> q;
	vector<int> a(n, 0);
	SegmentTree t(a);
	while(q--) {
		int c, x, y;
		cin >> c >> x >> y;
		if(c == 0) {
			t.add(x - 1, y);
		}
		else {
			cout << t.get(x - 1, y) << '\n';
		}
	}
	return 0;	
}



Measured memory_bytes: 4556
a, b, c = map(int, input().split())
if c <= (b - a + 1) // 2:
  for i in range(a, a+c):
    print(i)
  for i in range(b-c+1, b+1):
    print(i)
else:
  for i in range(a, b+1):
    print(i)

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

h = []
for i in range(N):
    h.append(int(input()))

h.sort()

minDistance = 10 ** 9
for i in range(0, N - K + 1):
    if h[i + K - 1] - h[i] < minDistance:
        minDistance = h[i + K - 1] - h[i]

print(minDistance)

Measured memory_bytes: 7384
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		List<Integer> nList = new ArrayList<>();

		int total = 0;
		for (int i = 0; i < n; i++) {
			nList.add(sc.nextInt());
		}
		for (int i = 0; i < n; i++) {
			int cost = sc.nextInt();
			int currentValue = nList.get(i);

			if(currentValue>cost){
				total += currentValue - cost;
			}
		}

		System.out.println(total);


	}
}


Measured memory_bytes: 23124
import sys
from copy import deepcopy
N = int(input())
b = [int(i) for i in input().split()]

ans = []
for i, x in enumerate(b):
    if x > i+1:
        print(-1)
        sys.exit()
while len(b) != 0:
    for i, x in enumerate(b[::-1]):
        if len(b)-i == x:
            ans.append(x)
            b.pop(len(b) - i - 1)
            break
print(*ans[::-1], sep='\n')

Measured memory_bytes: 9288
H, W = map(int, input().split())
maze = [0] * H
for i in range(H):
  maze[i] = str(input())

ans = 0  
for i in range(H):#20
  for j in range(W):#20
    if maze[i][j] != "#":
      visited = [[float("inf")] * W for _ in range(H)]
      visited[i][j] = 0
      queue = [[i, j]]
      while queue:#400
        x, y = queue.pop()
        for p, q in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
          if (0 <= x + p < H) and (0 <= y + q < W):
            if (maze[x+p][y+q] !="#"):       
              if visited[x+p][y+q] > visited[x][y] + 1:
                queue.append([x+p, y+q])
                visited[x+p][y+q] = visited[x][y] + 1
      #print(visited)        
      now = 0
      for k in range(H):
        for k2 in range(W):
          if visited[k][k2] < 10 ** 10:
            now = max(now, visited[k][k2])
      ans = max(ans, now)
      
print(ans)

            
            
            
            
        


Measured memory_bytes: 77756
//https://codeforces.com/contest/1335/problem/

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    int s = 0;
    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        s += x;
    }
    if (s > n)
    {
        cout << "-1\n";
    }
    else
    {
        cout << n - s << '\n';
    }
    return 0;
}

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

bool dp[4001][16001];
int x,y,tx,ty,ax[8001],ay[8001];

void dfsx(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<tx){
		dfsx(t+1,n+ax[t]);
		dfsx(t+1,n-ax[t]);
	}
	dp[t][n+8000]=1;
}

void dfsy(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<ty){
		dfsy(t+1,n+ay[t]);
		dfsy(t+1,n-ay[t]);
	}
	dp[t][n+8000]=1;
}

int main()
{
	string s;
	cin>>s>>x>>y;
	bool fx=1;
	for(int i=0;i<s.length();i++){
		if(s[i]=='F'){
			if(fx) ax[tx]++;
			else ay[ty]++;
		}
		else{
			if(fx) fx=0,tx++;
			else fx=1,ty++;
		}
	}
	if(s[s.length()-1]=='F'){
		if(fx) tx++;
		else ty++;
	}
	dfsx(1,ax[0]);
	bool xx=dp[tx][8000+x]==1?1:0;
	memset(dp,0,sizeof(dp));
	dfsy(0,0);
	bool yy=dp[ty][8000+y]==1?1:0;
	if(xx&&yy) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

const ll Mod = 1e9 + 7;
// const ll Mod = 998244353;
const ll MAXN = 1e6;

void solve(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans=0;
    if(k>a){
        ans+=a;
        k-=a;
    }else{
        ans+=k;
        k=0;
    }
    if(k>b){
        k-=b;
    }else{
        k=0;
    }
    if(k>c){
        ans-=c;
        k-=c;
    }else{
        ans-=k;
        k=0;
    }
    cout<<ans<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652