akhauriyash/Code-Regression huggingface dataset:
import sys

def main():
    X = list(map(int, input().split()))
    if max(X) % 2 == sum(X) % 2:
        print((max(X) * 3 - sum(X))//2)
    else:
        print(((max(X)+1) * 3 - sum(X))//2)
    
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,i,k=0,a[100000];
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        cin>>a[i];
        k = k+a[i];
    }
    if(k>=n)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K;
	scan(N>>K);
	ld ans=0;
	rep1(i,N){
		ll now=i;
		ll bunbo=1;
		while(now<K){
			now*=2;
			bunbo*=2;
		}
		ans+=(ld)1.0/bunbo;
	}
	ans/=N;
	if(ans<1e-9) prin(0);
	else prin(setprecision(20)<<ans);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int hist[300002], cnt[300001];

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


	int N;
	cin >> N;
	rep(i, N) {
		int a;
		cin >> a;
		hist[a]++;
	}
	rep1(i, N) cnt[hist[i]]++;
	int k = N;
	for (int i = N; i >= 0; i--) {
		rep(j, cnt[i]) hist[k--] = i;
	}

	k = N + 1;
	int ruiseki = N;
	int mae = 0;
	for (int i = N; i >= 1; i--) {
		while (hist[k - 1] >= i) {
			ruiseki -= hist[--k];
		}
		int ijou = N - k + 1;
		int kei = ijou + ruiseki / i;

		for (int j = mae + 1; j <= kei; j++) co(i);
		mae = kei;
	}
	for (int j = mae + 1; j <= N; j++) co(0);

	Would you please return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10,mod=1e9+7;
string s;
ll n,dp[2][2][2020];

int main ()
{
    FASTIO
    cin >> s;
    n=s.si;
    for(int i=n-1;i>=0;i--){
        for(int k=2018;k>=0;k--){
            for(int j=1;j>=0;j--){
                dp[i%2][j][k]=0;
                if(j==0){
                    dp[i%2][j][k] += dp[(i+1)%2][0][0];
                    dp[i%2][j][k] += dp[(i+1)%2][1][(k*10+s[i]-'0')%2019] + ((k*10+s[i]-'0')%2019==0);
                }
                if(j==1){
                    dp[i%2][j][k] += dp[(i+1)%2][1][(k*10+s[i]-'0')%2019] + ((k*10+s[i]-'0')%2019==0);
                }
            }
        }
    }
    cout << dp[0][0][0] << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 3736
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>
// 多倍長整数型
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
 
#define INF 1e9
#define LINF 1e18
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

//最大公約数
ll gcd(ll a, ll b){
  if(b == 0)return a;
  else return gcd(b, a % b);
}

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

  vector<ll> gl(n, 0), gr(n, 0);
  rep(i, n){
    if(i == 0)gl[i] = a[0];
    else gl[i] = gcd(a[i], gl[i - 1]);
  }

  reverse(ALL(a));
  rep(i, n){
    if(i == 0)gr[i] = a[0];
    else gr[i] = gcd(a[i], gr[i - 1]);
  }
  ll res = 0;
  rep(i, n){
    if(i == 0)chmax(res, gr[n - 2]);
    else if(i == n - 1)chmax(res, gl[n - 2]);
    else chmax(res, gcd(gl[i - 1], gr[n - i - 2]));
  }
  cout << res << endl;
}
 

Measured memory_bytes: 5236
#include <iostream>

using namespace std;

int main()
{
	int a, b, n;
	
	while ( cin >> a >> b >> n ) {
		int sum = 0;
		a %= b;
		for (int i=0; i<n; i++) {
			a *= 10;
			sum += (a/b);
			a %= b;
		}
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using intl = long long;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define debug(x) cout << #x << ":" << x << endl
const intl INF = 1e9;
const intl MOD = 1e9+7;
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl a;
    cin >> a;
    intl b;
    cin >> b;
    intl m;
    cin >> m;
    intl d[a];
    rep(i,a){
        cin >> d[i];
    }
    intl e[b];
    rep(i,b){
        cin >> e[i];
    }
    
    intl x[m];
    intl y[m];
    intl c[m];
    rep(i, m){
        cin >> x[i] >> y[i] >> c[i];
        
    }
    intl mi = 200001;
    rep(i,m){
        mi = min(mi,d[x[i]-1] + e[y[i]-1] - c[i]);
        //debug(mi);
    }
    sort(d,d + a);
    sort(e,e + b);
    mi = min(mi,d[0] + e[0]);
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>
#include <climits>
const int MOD = 1000000007;


ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}

map<ll,ll> mp;

ll calc(ll n,ll a,ll b,ll c,ll d)
{
	ll tmp,m;
	ll ret=LLONG_MAX;
	if (ret/d>n) ret=d*n;

	if (n==0) return 0;
	if (n==1) return d;
	if (mp.count(n)) return mp[n];
	//cerr<<n<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

	m=n%2;
	tmp=calc((n-m)/2,a,b,c,d)+a+d*m;if (tmp<ret)ret=tmp;
	if (m) tmp=calc((n+2-m)/2,a,b,c,d)+a+d*(2-m);if (tmp<ret)ret=tmp;
	
	m=n%3;
	tmp=calc((n-m)/3,a,b,c,d)+b+d*m;if (tmp<ret)ret=tmp;
	if (m) tmp=calc((n+3-m)/3,a,b,c,d)+b+d*(3-m);if (tmp<ret)ret=tmp;

	m=n%5;
	tmp=calc((n-m)/5,a,b,c,d)+c+d*m;if (tmp<ret)ret=tmp;
	if (m) tmp=calc((n+5-m)/5,a,b,c,d)+c+d*(5-m);if (tmp<ret)ret=tmp;

	//cerr<<"cacl("<<n<<")="<<ret<<endl;
	mp[n]=ret;
	return ret;
}


int main(int argc, char *argv[])
{
	int t;
	ll n,a,b,c,d;
	cin>>t;
	for (int i=0;i<t;i++)
	{
		mp.clear();
		cin>>n>>a>>b>>c>>d;
		cout<<calc(n,a,b,c,d)<<endl;
	}
	return 0;
}



Measured memory_bytes: 4444
#encoding: utf-8

intervalTime = STDIN.gets.split(" ").map(&:to_i);

def maxNum(a, c)
	if a < c then
		return c
	else
		return a
	end
	return 0
end

def minNum(b, d)
	if b < d then
		return b
	else
		return d
	end
end

def checkTime(min, max)
	if max > min then
		STDOUT.puts "0";
	else
		STDOUT.puts min - max;
	end
	return 0;
end

checkTime(minNum(intervalTime[1], intervalTime[3]), maxNum(intervalTime[0], intervalTime[2]));

Measured memory_bytes: 3836
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
size = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, size + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int,input().split())
A = list(map(int,input().split()))
MIN = 0
MAX = 0
A.sort()
for i in range(N-K+1):
    MIN += A[i] * cmb(N-1-i,K-1,mod)
for i in range(N-1,K-2,-1):
    MAX += A[i] * cmb(i,K-1,mod)
print((MAX - MIN) % mod)

Measured memory_bytes: 26696
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, h = list(map(int, input().rstrip('\n').split()))
    al = 0
    bl = []
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        al = max(al, a)
        bl.append(b)
    bl.sort()
    cnt = 0
    while True:
        if len(bl) != 0:
            b = bl.pop()
            if h <= 0:
                print(cnt)
                exit()
            elif al < b:
                h -= min(h, b)
                cnt += 1
            else:
                cnt += (h + al - 1) // al
                h -= (h + al - 1) // al * al
                print(cnt)
                exit()
        else:
            cnt += (h + al - 1) // al
            h -= (h + al - 1) // al * al
            print(cnt)
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 49884
#include<iostream>
using namespace std;
int main(){
  int n,a[200001]={};
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  
  int max=a[1]-a[0];
  int min=a[0];
  for(int i=1;i<n;i++){
      if(a[i]-min>max)max=a[i]-min;
      if(min>a[i])min=a[i];
  }
  cout<<max<<endl;
  return 0;
}



Measured memory_bytes: 3896
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int H, W; cin >> H >> W;
	rep(i, H) {
		rep(j, W) {
			string str;
			cin >> str;
			if (str == "snuke") {
				cout << (char)('A' + j) << i + 1 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int a[3];
	for(int i=0; i<3; i++) cin >> a[i];
	sort(a, a+3, greater<int>());
	cout << a[0]*10+a[1]+a[2] << endl;
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp
t = gets.chomp
min = t.size
0.upto(s.size - t.size) do |i|
  tmp = 0
  t.size.times do |j|
    tmp += 1 if s[i, t.size][j] != t[j]
  end
  min = tmp if min > tmp
end
puts min

Measured memory_bytes: 15800
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    std::string a;
    cin >> a;
    int l = a.length();
    std::vector<int> check(26, 0);
    int minus = 0;
    for (int i = 0; i < l; i++) {
        check[(int)(a[i] - 'a')]++;
    }
    for (int i = 0; i < 26; i++) {
        minus += check[i] * (check[i] - 1) / 2;
    }
    cout << (l * (l - 1)) / 2 - minus + 1 << endl;
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define Maxn 100010
#define INF 10010
inline int read()
{
	char c=getchar();re ll f=1,s=0;
	while(!isdigit(c)){if(c=='-')f=-1,c=getchar();}
	while(isdigit(c)){s=s*10+c-48;c=getchar();}
	return f*s;
}
bool cmp(string s1,string s2){return s1<s2;}
int main()
{
	string s[101];
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
	sort(s,s+n,cmp);
    for(int i=0;i<n;i++) cout<<s[i];
    cout<<endl;
	return 0;
}

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

int a[3];
int f=0,s=0,e=0;
int main(){
	cin >> a[0] >> a[1] >> a[2];
	for(int i=0;i<3;i++){
		(a[i]==5?f:(a[i]==7?s:e))+=1;
	}
	cout << (e?"NO":(f==2?"YES":"NO")) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  int sum = 0;
  for (int i=0; i<=n; i++){
    int sum1 = i%100000 / 10000 + i%10000 / 1000 + i%1000 / 100 + i%100 / 10 + i%10;
    if (a <= sum1 && sum1 <= b)
      sum += i;
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  ll n,m;
  cin >> n >> m;
  ll ans = 0;
  ans += min(n,m/2);
  ans += (m-min(n,m/2)*2)/4;
  cout << ans << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  ll a,b; cin>>a>>b;
  cout<<max(max(a+b,a-b),a*b)<<endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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 long long INF = 1LL<<60;

int main(){
    int x;cin >> x;
    for(int i=x;;i++){
        bool flag = true;
        for(int ki=2;ki*ki<x;ki++){
            if(i%ki==0) flag = false;
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

int main(){
    int r, g, b;
    cin >> r >> g >> b;

    int ans =  r * 100 + g * 10 + b;

    if(ans % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

void inc(vector<int> &num) {
  int N = num.size();
  int i = 0;
  while (i < N && (num[i] == 9 || i + 1 < N && num[i] == num[i + 1] + 1)) i++;
  if (i == N)
    num.push_back(1);
  else
    num[i]++;
  for (i--; i >= 0; i--) {
    num[i] = max(num[i + 1] - 1, 0);
  }
}

long long toll(vector<int> &num) {
  long long ret = 0;
  for (int i = num.size() - 1; i >= 0; i--) {
    ret *= 10;
    ret += num[i];
  }
  return ret;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K;
  cin >> K;
  vector<int> num;
  for (int i = 0; i < K; i++) {
    inc(num);
  }
  long long ans = toll(num);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 405;

ll mod_pow(ll a,ll b)
{
    a %= MOD;
    ll res = 1;
    while(b){
        if(b & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

ll add(ll x,ll y)
{
    return (x + y)%MOD;
}

ll sub(ll x,ll y)
{
    return (x+MOD-y)%MOD;
}

ll mul(ll x,ll y)
{
    return x*y%MOD;
}

int sm[MAX_N][MAX_N];
int dp[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,c;
    cin >> n >> c;
    vi a(n),b(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,400){
        rep(j,401){
            sm[i+1][j] = add(sm[i][j],mod_pow(i+1,j));
        }
    }
    dp[0][0] = 1;
    rep(i,n){
        rep(j,c+1){
            if(dp[i][j]){
                rep(k,c+1-j){
                    dp[i+1][j+k] = add(dp[i+1][j+k],mul(sub(sm[b[i]][k],sm[a[i]-1][k]),dp[i][j]));
                }
            }
        }
    }
    cout << dp[n][c] << "\n";
    return 0;
}


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

//コンビネーションの計算
long long com(long long N, long long R) {
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    else if (R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}

long long pow(long long N, long long k) {
    long long res = 1;
    for (int i = 0; i < k; ++i) res *= N;
    return res;
}

string S;
int N, K;

//i桁目を調査中、0以外の数を後k個使える、smaller==1ならもう解が分かる
long long solve(int i, int k, int smaller) {
    if (i == N) { //N桁目(最後)までいったとき
        if (k == 0) return 1; //ちょうど終われば
        else return 0; //ちょうど終わらなければ
    }
    if (k == 0) return 1; //残り桁全部0なので1通り
    
    if (smaller){ //既に小さいことが確定
    	//残りN-i桁の内、k桁が0以外なので[9のk乗*(N-i)Ck]
    	return com(N-i, k) * pow(9, k);
    }
    else { //i桁目までが最大値と一致している時
    	//最大値のi桁目が0なら、i桁目は0一択で、最大値と一致してるので次の桁へ
        if (S[i] == '0') return solve(i+1, k, false);
        else { //最大値のi桁目が0以外なら
        	//i桁目が0か、最大値と一致してるか、その間の数か
        	//i桁目が0のとき最大値のi桁目は0出ないのでsmaller
            long long zero = solve(i+1, k, true);
            //i桁目が間の時最大値より確実に小さく、以降の桁で使える0以外の数が1減る
            long long aida = solve(i+1, k-1, true) * (S[i] - '1');
            //i桁目が最大値と一致するときsmallerか分からない
            long long icchi = solve(i+1, k-1, false);
            return zero + aida + icchi;
        }
    }
}

int main() {
    cin >> S >> K;
    N = S.size();
    cout << solve(0, K, false) << endl;
}

Measured memory_bytes: 384
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    int numContest = Integer.parseInt(data[0]);
    int rate = Integer.parseInt(data[1]);
    
    if(numContest<10){
      rate = rate+100*(10-numContest);
    }
    System.out.println(rate);
  }
}


Measured memory_bytes: 22356
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>


using namespace std;
static const int INF = (1 << 29);
int N;
int a[109];


int main() {

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

	int ans = INF;
	for (int i = (-100); i <= 100; i++) {
		int cost = 0;
		for (int j = 0; j<N; j++) {
			cost += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans, cost);
	}

	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
int x;
cin>>x;
if(x>=30) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 3096
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;



int main(){
	int a,b,c,g;
	char p,q;
	a=1;
	b=0;
	c=0;
	while( scanf("%c,%c",&p,&q) != EOF ){
		if((q=='A'&&p=='B')||(p=='A'&&q=='B')){
			g=a;
			a=b;
			b=g;
		}
		if((q=='A'&&p=='C')||(p=='A'&&q=='C')){
			g=a;
			a=c;
			c=g;
		}
		if((q=='C'&&p=='B')||(p=='C'&&q=='B')){
			g=c;
			c=b;
			b=g;
		}
	}
	if(a) printf("A\n");
	if(b) printf("B\n");
	if(c) printf("C\n");
	
	return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	vector<llint> A;
	for(int i=0;i<3*N;i++){
		llint a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.rbegin(),A.rend());
	llint sum=0;
	auto it=A.begin();
	for(int i=0;i<N;i++){
		it++;
		sum+=*it;
		it++;
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,ans=1;
string s;
int main()
{
	cin>>n>>s;
	for(int i=1;i<s.size();i++)
		if(s[i]!=s[i-1])
			ans++;
	cout<<ans;
    return 0;
}


Measured memory_bytes: 512
g,r,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for _ in range(g):
  f=c
  hj=list(map(int,input().split()))
  for z,x in zip(b,hj):
    f+=z*x
  if f>0:ans+=1
print(ans)

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return abs(x-y)/gcd(x,y); }


int main() {
  string s; cin >> s;
  lint n = (int)s.size()+1;
  vector<int> l(n,0), r(n,0);

  l[0]=0; r[n-1]=0;
  for(lint i=1;i<n;i++) {
    if(s[i-1]=='<') { l[i] = l[i-1]+1; }
    else if(s[i-1]=='>') { l[i] = 0; }
  }

  for(lint i=n-2;i>=0;i--) {
    if(s[i]=='>') { r[i] = r[i+1]+1; }
    else if(s[i]=='<') { r[i] = 0; }
  }

  /*
  for(lint i=0;i<n;i++) { cout << l[i]; }
  cout << endl;
  for(lint i=0;i<n;i++) { cout << r[i]; }
  cout << endl;
  */

  lint sum=0;
  for(lint i=0;i<n;i++) {
    if(l[i] > r[i]) { sum += l[i]; }
    else { sum += r[i]; }
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4740
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        long x = ni();
        long y = ni();
        int div = (int) (y / 2 - x);
        boolean res = div >= 0 && y <= 4*x && y % 2 == 0;
        if (res) {
            out.println("Yes");
        } else {
            out.println("No");
        }

        out.close();
    }

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

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

}


Measured memory_bytes: 25412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int>A(M);
    int sum = 0;
  for(int i=0; i<M; i++){
    cin >> A.at(i);
    sum += A.at(i);
  }
  if(N-sum>-1) cout << N - sum << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3640
import sys
import numpy as np
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([1] + lr())
A = (A-1) % K
N += 1
# 累積和が同じになっている箇所に注目、要素がK-1離れている組み合わせは無理
Acum = (A.cumsum() % K).tolist()
answer = 0
dic = defaultdict(int)
for i, cur in enumerate(Acum): 
    answer += dic[cur]
    dic[cur] += 1
    if i >= K-1:
        vanish = Acum[i-(K-1)]
        dic[vanish] -= 1

print(answer)
# 10

Measured memory_bytes: 43364
#include <iostream>
#include <cctype>

using namespace std;


int main(){
	int r, c;

	cin >> r >> c;

	int **table = new int*[r+1];
	for (int i = 0; i < r+1; i++){
		table[i] = new int[c+1];
	}
	for (int i = 0; i < r + 1; i++){
		for (int j = 0; j < c + 1; j++){
			table[i][j] = 0;
		}
	}
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			cin >> table[i][j];
			table[i][c] +=  table[i][j];
			table[r][j] += table[i][j];
			table[r][c] += table[i][j];
		}
	}
	for (int i = 0; i < r+1; i++){
		for (int j = 0; j < c+1; j++){
			cout << table[i][j];
			if (j != c) cout << " ";
		}
		cout << endl;
	}
	for (int j = 0; j < c + 1; j++){

	}
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define reg register
#define maxn 300001
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
bool hh = true;
int nt[maxn], fi[maxn], go[maxn], deg[maxn], f[maxn], a[maxn], cnt, n, root;
void add(int u, int v){
    nt[++cnt] = fi[u]; fi[u] = cnt; go[cnt] = v;
}
void dfs(int u, int fa){
    int sum = 0;
    if(deg[u] == 1) {f[u] = a[u]; return; }
    for(int i = fi[u]; i; i = nt[i]){
        int v = go[i]; if(v == fa) continue;
        dfs(v, u); sum += f[v];
        if(f[v] > a[u]) hh = false;
    }
    f[u] = a[u] * 2 - sum;
    if(f[u] > a[u]) hh = false;
    if(f[u] < 0) hh = false;
}
int main()
{
    n = read();
    for(int i = 1; i <= n; i++) a[i] = read();
    if(n == 2){
        if(a[1] == a[2]) cout << "YES\n";
        else cout << "NO\n";    
        return 0;
    }
    for(int i = 1; i < n; i++){
        int x = read(), y = read();
        add(x, y); add(y, x);
        deg[x]++; deg[y]++;
    }
    for(int i = 1; i <= n; i++) 
    if(deg[i] > 1) root = i;
    dfs(root, 0);
        if(f[root]) {cout <<"NO"<< endl;
        return 0;}
    if(hh) cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 11264
class Problem
  attr_accessor :a, :b, :k
  def initialize
    @a,@b,@k = gets.split.map &:to_i
  end

  def solve
    ((a..([b, a + k - 1].min)).to_a + (([a, b - k + 1].max)..b).to_a).sort.uniq
  end

  def show(ans)
    puts ans.join("\n")
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14376
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include <iomanip>
#include<stack>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
typedef long double ld;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

ll n, m;
vector<string> b;
vector< vector<ll> > s;
vector<ll> p;

void bit(ll d, string s){
    if(d == n){
        b.push_back(s);
        return;
    }
    else{
        bit(d+1, s+'0');
        bit(d+1, s+'1');
    }
}

int main()
{
    cin >> n >> m;
    bit(0, "");

    ll ans = 0;

    s.resize(m);

    p.resize(m);

    rep(i, m){
        ll k;
        cin >> k;
        s[i].resize(k);
        rep(j, k) cin >> s[i][j];
    }

    rep(i, m) cin >> p[i];


    rep(i, b.size()){
        ll tttp = 0;
        rep(j, m){
            ll tmp = 0;
            rep(k, s[j].size()){
                ll kt = s[j][k]-1;
                if(b[i][kt] == '1') tmp++;
            }
            if(tmp % 2 == p[j]) tttp++;
        }
        if(tttp == m) ans++;
    }

    cout << ans;



}

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

int main()
{
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC" <<endl;
    }else{
        cout << "ABC" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int count = scanner.nextInt();
        final int[] point = new int[count];
        int all = 0;

        for (int i = 0; i < point.length; i++) {
            final int w = scanner.nextInt();
            point[i] = w;
            all += w;
        }

        int result = Integer.MAX_VALUE;
        int re = all;
        for (int i = 0; i < point.length; i++) {
            re -= point[i];
            if(Math.abs(all -re - re) < result){
                result = Math.abs(all - re - re);
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 21972
const fs = require('fs');

function divmod(a, b) {
  var q = Math.floor(a / b);
  var r = a % b;
  return [q, r]
}

function main(input) {
  var arr = input.split(' ');
  arr = arr.map((n) => parseInt(n, 10));
  n = arr[0]; a = arr[1]; b = arr[2];

  var res = 0;
  var tot;
  var q;
  var r;
  var d;
  for (var i = 0; i <= n; i++) {
    q = i;
    tot = 0;
    while (q !== 0) {
      d = divmod(q, 10);
      q = d[0]; r = d[1];
      tot += r;
    }
    if (a <= tot && tot <= b) {
      res += i;
    }
  }
  console.log(res);
}

input = fs.readFileSync('/dev/stdin', 'utf8');
main(input);

Measured memory_bytes: 9036
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 110000
using namespace std;
struct node{int y,nex;}a[2*N];
int n,fir[N],len,f[N],d[N],du[N];
bool bo;
void ins(int x,int y)
{
	a[++len].y=y;a[len].nex=fir[x];fir[x]=len;
}
void dfs(int x,int fa)
{
	if(du[x]==1) {f[x]=d[x];return;}
	int mx=0;
	for(int k=fir[x];k;k=a[k].nex)
	{
		int y=a[k].y;
		if(y==fa) continue;
		dfs(y,x);
		if(bo==0) return;
		f[x]+=f[y];
		mx=max(mx,f[y]);
	}
	if(f[x]<d[x] || f[x]>d[x]*2) {bo=0;return;}
	int t=f[x]-d[x];
	if(mx>f[x]/2 && t>f[x]-mx) {bo=0;return;}
	f[x]=d[x]-t;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&d[i]);
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);ins(y,x);
		du[x]++;du[y]++;
	}
	if(n==2)
	{
		if(d[1]==d[2]) printf("YES\n");
		else printf("NO\n");
		return 0;
	}
	int rt;
	for(int i=1;i<=n;i++) if(du[i]>1) {rt=i;break;}
	bo=1;
	dfs(rt,0);
	if(bo==0 || f[rt]>0) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int dfs(){
}

int main(){
  int n;
  int ans=0;
  cin >> n;
  vector<P> vs[n];
  rep(i,n){
    int a;
    cin >> a;
    rep(j,a){ 
      int x,y; cin >> x >> y;
      vs[i].emplace_back(x-1,y);
    }
  }
  for(int bit=0; bit<(1<<n); bit++){  
    bool flag=true;
    bitset<15> h;
    for(int i=0; i<n; i++){h[i] = (bit>>i&1);}
    for(int i=0; i<n; i++){
      if(h[i]){
        for(auto v:vs[i]){
            if(h[v.F] != v.S){flag=false;}
        }
      }
    }
    if(flag){
      int cnt=0;
      for(int i=0; i<n; i++){ if((1<<i)&bit){ cnt++; } }
      ans = max(ans,cnt); 
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define M 1003
int main() 
{
	int N,T,A,H[M];
	double ret[M],re[M];
	cin>>N>>T>>A;
	for(int i=0;i<N;i++)
	{
		cin>>H[i];
		ret[i]=abs(T-H[i]*0.006-A);
		re[i]=ret[i];
	}
	sort(re,re+N);
	for(int i=0;i<N;i++)
	{
		if(ret[i]==re[0])
		{
			cout<<i+1<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"time"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	s := readString()

	layout := "0601"
	_, err1 := time.Parse(layout, s)
	_, err2 := time.Parse(layout, s[2:]+s[:2])

	if err1 == nil && err2 == nil {
		fmt.Println("AMBIGUOUS")
	} else if err1 == nil {
		fmt.Println("YYMM")
	} else if err2 == nil {
		fmt.Println("MMYY")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 640
import math
a, b, h, m=map(int, input().split())

a_kakudo=30*h+0.5*m
b_kakudo=6*m

diff=abs(a_kakudo-b_kakudo)
# print(a_kakudo)
# print(b_kakudo)
# print(diff)
if diff>180:
    diff=360-diff
l=pow(a, 2)+pow(b, 2)-2*a*b*math.cos(math.radians(diff))
ans=pow(l, 0.5)
print(ans)


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

int main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  for (int i = 0; i < K && i < S.size(); i++) {
    if (S[i] != '1') {
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		cout << char('A' + ((s[i] - 'A')+ n) % 26 ); 
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,a,i,sum;
	scanf("%d %d",&n,&m);
	sum=0;
	for(i=0;i<m;i++){
		scanf("%d",&a);
		sum+=a;
	}
	if(n>=sum){
			printf("%d\n",n-sum);
	}
	else{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 1732
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//dp[i][j][k]:i個目までを選んだ時、aをjグラム、bをkグラムちょうど含む金額の最小値
int dp[45][405][405];

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N,M,K;
    cin >> N >> M >> K;
    for(int i = 0;i<45;i++) for(int j = 0;j<405;j++) for(int k = 0;k<405;k++) dp[i][j][k] = inf;
    dp[0][0][0] = 0;
    
    for(int i = 0;i<N;i++){
        int a,b,c;cin >> a >> b >> c;
        for(int j = 0;j<405;j++){
            for(int k = 0;k<405;k++){
                if(dp[i][j][k] == inf) continue;
                dp[i+1][j+a][k+b] = min(dp[i][j][k]+c,dp[i+1][j+a][k+b]);
                dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
            }
        }
    }

    /*for(int i = 0;i<=N;i++){
        for(int j = 0;j<=3;j++){
            for(int k = 0;k<=3;k++){
                cout << dp[i][j][k] << " ";
            }
        }
        cout << endl;
    }*/

    int ans = inf;
    for(int i = 1;i<405;i++){
        int ratioA = M,ratioB = K;
        ratioA *= i,ratioB *= i;
        if(ratioA > 400 || ratioB > 400) break;
        ans = min(ans,dp[N][ratioA][ratioB]);
    }
    if(ans == inf){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 32436
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
//#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n, dx, dy, dt, dz, ch=0;
  cin >> n;
  vector<tuple<int, int, int>> A(n+1);
  A[0] = make_tuple(0, 0, 0);
  for(int i=1; i<=n; i++) {
    cin >> dx >> dy >> dz;
    A[i] = make_tuple(dx, dy, dz);
}
  for(int i=0; i<n; i++){
    dx = max(get<1>(A[i])-get<1>(A[i+1]), get<1>(A[i+1])-get<1>(A[i]));
    dy = max(get<2>(A[i])-get<2>(A[i+1]), get<2>(A[i+1])-get<2>(A[i]));
    dt = get<0>(A[i+1])-get<0>(A[i]);
    dz = dx+dy;
    if(dz>dt){
    ch = 1;
    cout << "No" << endl; 
    break;
    }
    else if((dt-dz)%2==1){
    ch = 1;
    cout << "No" << endl;
    break;
    }
    
  }
  if(ch == 0) cout << "Yes" << endl;
} 

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

#define N_MAX 100

int main() {
    long n, d;
    cin >> n >> d;

    long X[10][10];
    for (long i = 0; i < n; i++) {
        for (long j = 0; j < d; j++) {
            cin >> X[i][j];
        }
    }

    // for (long i = 0; i < n; i++) {
    //     for (long j = 0; j < d; j++) {
    //         cout << " " << X[i][j];
    //     }
    //     cout << endl;
    // }

    long cnt = 0;
    for (long i = 0; i < n - 1; i++) {
        for (long j = i + 1; j < n; j++) {
            float dist = 0;
            for (long k = 0; k < d; k++) {
                dist += pow(X[j][k] - X[i][k], 2);
            }
            dist = sqrt(dist);
            // cout << dist << endl;
            if (ceil(dist) == floor(dist)) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split(" "))
fir1, sec = "", ""
txt = ""
if ty - sy > 0 and tx - sx > 0:
  fir1 = 'U' * (ty - sy) + 'R' * (tx - sx)
  fir2 = 'D' * (ty - sy) + 'L' * (tx - sx)
  sec = "LU" + fir1 + "RDRD" + fir2 + "LU"
elif ty - sy > 0 and tx - sx < 0:
  fir1 = 'U' * (ty - sy) + 'L' * (sx - tx)
  fir2 = 'D' * (ty - sy) + 'R' * (sx - tx)
  sec = "RU" + fir1 + "LDLD" + fir2 + "RU"
elif ty - sy < 0 and tx - sx > 0:
  fir1 = 'D' * (sy - ty) + 'R' * (tx - sx)
  fir2 = 'U' * (sy - ty) + 'L' * (tx - sx)
  sec = "LD" + fir1 + "RURU" + fir2 + "LD"
else:
  fir1 = 'D' * (sy - ty) + 'L' * (sx - tx)
  fir2 = 'U' * (sy - ty) + 'R' * (sx - tx)
  sec = "RD" + fir1 + "LULU" + fir2 + "RD"
print(fir1 + fir2 + sec)

Measured memory_bytes: 3064
def binary_serch(target, num_list):
    start = 0
    end = len(num_list) - 1

    while(start <= end):
        mid = int((start + end) / 2)
        mid_num = num_list[mid]
        if mid_num == target:
            return True
        elif mid_num > target:
            end = mid - 1
        else:
            start = mid + 1
    return False

if __name__ == '__main__':
    n = int(input())
    S = [int(i) for i in input().split()]
    q = int(input())
    T = [int(i) for i in input().split()]

    counter = 0

    for num in T:
        if binary_serch(num, S):
            counter += 1

    print(counter)



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

long long gcd(long long x, long long y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

long long lcm(long long x, long long y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '1')
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

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

//cout << fixed << setprecision(10);

int main() {
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> dist(N,vector<ll>(N,INF));
    vector<ll> A(M),B(M),C(M);
    for(int i=0;i<M;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        A[i]=a;
        B[i]=b;
        C[i]=c;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) dist[i][j]=0;
        }
    }

    for(int i=0;i<M;i++){
        dist[A[i]][B[i]] = min(dist[A[i]][B[i]], C[i]);
        dist[B[i]][A[i]] = min(dist[A[i]][B[i]], C[i]);
    }

    //WF法
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll ans=M;
    for(int i=0;i<M;i++){
        bool shortest = false;
        for(int s=0;s<N;s++){
            for(int t=0;t<N;t++){
                if(dist[s][t]==dist[s][A[i]]+dist[B[i]][t]+C[i]){
                    shortest=true;
                }
            }
        }
        if(shortest) ans--;
    }

    cout << ans << endl;





    return 0;
}

Measured memory_bytes: 384